diff --git a/config/puppet-modules/puppet-drbd-0.5.2/debian/patches/0013-Ensure-drbd-becomes-primary.patch b/config/puppet-modules/puppet-drbd-0.5.2/debian/patches/0013-Ensure-drbd-becomes-primary.patch new file mode 100644 index 000000000..8fc6f6faf --- /dev/null +++ b/config/puppet-modules/puppet-drbd-0.5.2/debian/patches/0013-Ensure-drbd-becomes-primary.patch @@ -0,0 +1,56 @@ +From 463dec51aae0a996a3ca9c781a6d3eeffd501bd2 Mon Sep 17 00:00:00 2001 +From: Erickson Silva de Oliveira +Date: Thu, 9 Nov 2023 15:00:31 -0300 +Subject: [PATCH] Ensure drbd becomes primary + +Sometimes BnR does not complete because the drbd-cephmon manifest +is not applied when trying to make it primary. To ensure that +drbd becomes primary, a loop was added so that multiple +attempts are made, not just one. + +Signed-off-by: Erickson Silva de Oliveira +--- + manifests/resource/up.pp | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/manifests/resource/up.pp b/manifests/resource/up.pp +index 8d2f901..732634b 100644 +--- a/manifests/resource/up.pp ++++ b/manifests/resource/up.pp +@@ -72,12 +72,23 @@ define drbd::resource::up ( + # these resources should only be applied if we are configuring the + # primary node in our HA setup + if $ha_primary { ++ $cmd = "/bin/true # comment to satisfy puppet syntax requirements ++set -ex ++if ! drbdadm primary ${name} ; then ++ for i in {1..10}; do ++ if drbdadm primary ${name} --force ; then ++ exit 0 ++ fi ++ sleep 0.1 ++ done ++ drbdadm primary ${name} --force ++fi ++" + # these things should only be done on the primary during initial setup + if $initial_setup { + exec { "drbd_make_primary_${name}": +- command => "drbdadm -- --overwrite-data-of-peer primary ${name}", ++ command => $cmd, + unless => "drbdadm role ${name} | egrep '^Primary'", +- onlyif => "drbdadm dstate ${name} | egrep '^Inconsistent'", + notify => Exec["drbd_format_volume_${name}"], + before => Exec["drbd_make_primary_again_${name}"], + require => Service['drbd'], +@@ -96,7 +107,7 @@ define drbd::resource::up ( + } + + exec { "drbd_make_primary_again_${name}": +- command => "drbdadm primary ${name}", ++ command => $cmd, + unless => "drbdadm role ${name} | egrep '^Primary'", + require => Service['drbd'], + } +-- +2.34.1 diff --git a/config/puppet-modules/puppet-drbd-0.5.2/debian/patches/series b/config/puppet-modules/puppet-drbd-0.5.2/debian/patches/series index 2a9c32a60..e77c41dc5 100644 --- a/config/puppet-modules/puppet-drbd-0.5.2/debian/patches/series +++ b/config/puppet-modules/puppet-drbd-0.5.2/debian/patches/series @@ -10,3 +10,4 @@ 0010-Format-DRBD-resource-cpu-mask-to-support-64-or-larger-cpus.patch 0011-Fix-DRBD-cephmon-resize.patch 0012-Convert-strings-to-Numeric-type-to-avoid-warnings.patch +0013-Ensure-drbd-becomes-primary.patch