Whamcloud - gitweb
EX-4973 lipe: remove changelog user registration from config
authorJohn L. Hammond <jhammond@whamcloud.com>
Tue, 12 Apr 2022 18:03:37 +0000 (13:03 -0500)
committerJohn L. Hammond <jhammond@whamcloud.com>
Thu, 12 May 2022 13:30:16 +0000 (13:30 +0000)
In stratagem-hp-config.sh, remove the changelog user registration
code. If no chnagelog user is configured then lamigo will register a
new named changelog user with the required mask.

Test-Parameters: trivial
Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Change-Id: I457f4539451e93bf7980fc7fb807f67e67abf247
Reviewed-on: https://review.whamcloud.com/47045
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Nathaniel Clark <nclark@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
lipe/scripts/stratagem-hp-config.sh

index b95a459..d55faef 100755 (executable)
@@ -15,9 +15,6 @@
 # /etc/lamigo/$FS-MDTXXXX.conf (for each MDT)
 # /etc/lpurge/$FS/OSTXXXX.conf (for each OST in fast pool)
 # /etc/fstab updated with client mount line
-#
-# Lustre Changes
-# changelog user created for each MDT
 
 # CONFIGURATION VARIABLES
 
@@ -131,7 +128,6 @@ if [ -z "$MDSHOST" ]; then
     exit 5
 fi
 
-# reuse of changelog user handled below
 # get lpurge options - this gets the first OST from the FAST pool
 if $AUTO; then
     AUTO_FAST_POOL=$(awk -F = '/^src=/{ print $2 }' /etc/lamigo/$FS-MDT0000.conf)
@@ -287,55 +283,66 @@ echo "Setting up lamigo (From $FAST_POOL to $SLOW_POOL aged at least $LAMIGO_MIN
 
 # MDTLIST is derived from resources so it's already in decimal but formatted %04d
 for INDEX in $MDTLIST; do
-    MDT=$(printf "%04x" $((10#$INDEX)) )
+    MDT=$(printf "%s-MDT%04x" $FS $((10#$INDEX)))
     MDSHOST=$(locate_resource mdt$INDEX-$FS)
     CL=""
 
-    # reuse existing changelog user
-    if [ -f /etc/lamigo/$FS-MDT$MDT.conf ]; then
-        CL=$(awk -F = '/^user=/{ print $2 }' /etc/lamigo/$FS-MDT$MDT.conf)
-        # ensure changelog user exists
-        if [ -z "$(ssh $MDSHOST lctl get_param -n mdd.$FS-MDT$MDT.changelog_users|grep $CL[[:space:]])" ]; then
-            echo "Previous changelog user for $FS-MDT$MDT: $CL is missing"
+    # Reuse any existing changelog user. If none was found then lamigo
+    # will register a new user with the mask it needs.
+    if [[ -f /etc/lamigo/$MDT.conf ]]; then
+        CL=$(awk -F = '/^user=/{ print $2 }' /etc/lamigo/$MDT.conf)
+    fi
+
+    if [[ -z "$CL" ]]; then
+        CL=$(ssh $MDSHOST cat /var/lib/lamigo-$MDT.chlg)
+    fi
+
+    if [[ -n "$CL" ]]; then
+        # Ensure that the changelog user we found still exists.
+        if ssh $MDSHOST lctl get_param -n mdd.$MDT.changelog_users | grep "$CL[[:space:]]"; then
+            echo "Reusing changelog user '$CL' for $MDT"
+        else
             CL=""
         fi
     fi
-    # create new user if none was previously configured
-    if [ -z "$CL" ]; then
-        CL=$(ssh $MDSHOST lctl --device $FS-MDT$MDT changelog_register | awk -F \' '{print $2 }')
-        echo "Registered new changelog user for $FS-MDT$MDT: $CL"
-    fi
 
-    echo Creating lamigo config for $FS-MDT$MDT
-    cat << EOF > /etc/lamigo/$FS-MDT$MDT.conf
-mdt=$FS-MDT$MDT
+    echo Creating lamigo config for $MDT
+    (
+        cat << EOF
+mdt=$MDT
 mount=$ROOT/$FS/client
-user=$CL
 min-age=$LAMIGO_MINAGE
 src=$FAST_POOL
 tgt=$SLOW_POOL
 EOF
-    for HOST in $OSSLIST; do
-        echo oss=$HOST >> /etc/lamigo/$FS-MDT$MDT.conf
-    done
-    for HOST in $(cluset -e @all); do
-        echo agent=$HOST:$ROOT/$FS/client:4 >> /etc/lamigo/$FS-MDT$MDT.conf
-    done
 
-    clush -Sa mkdir -p /etc/systemd/system/lamigo@$FS-MDT$MDT.service.d/
-    cat <<EOF > /etc/systemd/system/lamigo@$FS-MDT$MDT.service.d/override.conf
+        if [[ -n "$CL" ]]; then
+            echo user=$CL
+        fi
+
+        for HOST in $OSSLIST; do
+            echo oss=$HOST
+        done
+
+        for HOST in $(cluset -e @all); do
+            echo agent=$HOST:$ROOT/$FS/client:4
+        done
+    ) > /etc/lamigo/$MDT.conf
+
+    clush -Sa mkdir -p /etc/systemd/system/lamigo@$MDT.service.d/
+    cat <<EOF > /etc/systemd/system/lamigo@$MDT.service.d/override.conf
 [Unit]
 After=lustre-$FS-client.mount
 EOF
 
-    clush -Sca /etc/lamigo/$FS-MDT$MDT.conf /etc/systemd/system/lamigo@$FS-MDT$MDT.service.d/override.conf
+    clush -Sca /etc/lamigo/$MDT.conf /etc/systemd/system/lamigo@$MDT.service.d/override.conf
 
-    echo Creating lamigo resource for $FS-MDT$MDT
+    echo Creating lamigo resource for $MDT
     clush -qS --group=ha_heads "crm_resource -QW -r mdt$INDEX-$FS >/dev/null 2>&1 && crm configure << EOF || true
-primitive lamigo-$FS-MDT$MDT systemd:lamigo@$FS-MDT$MDT.service op monitor interval=30s op start timeout=15m op stop timeout=120s
-colocation lamigo-$FS-MDT$MDT-with-mdt inf: lamigo-$FS-MDT$MDT mdt$INDEX-$FS
-order lamigo-$FS-$MDT-after-mdt mdt$INDEX-$FS lamigo-$FS-MDT$MDT
-rsc_ticket ticket-$FS-hotpool-allocated-lamigo-$FS-MDT$MDT $FS-hotpool-allocated: lamigo-$FS-MDT$MDT loss-policy=stop
+primitive lamigo-$MDT systemd:lamigo@$MDT.service op monitor interval=30s op start timeout=15m op stop timeout=120s
+colocation lamigo-$MDT-with-mdt inf: lamigo-$MDT mdt$INDEX-$FS
+order lamigo-$MDT-after-mdt mdt$INDEX-$FS lamigo-$MDT
+rsc_ticket ticket-$FS-hotpool-allocated-lamigo-$MDT $FS-hotpool-allocated: lamigo-$MDT loss-policy=stop
 EOF"
 done