BryanDavis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/228299

Change subject: Send $LOGUSER with dologmsg messages
......................................................................

Send $LOGUSER with dologmsg messages

Follow up to I1d7cccd to ensure that $LOGUSER has a non-null value in the
scripts where it is being used as input to dologmsg. The l10nupdate logs
from 2015-07-31 showed that $USER@$HOSTNAME was expanding to '@tin'
rather than the expected 'l10nupdate@tin' value. My random conjecture is
that this is an artifact of the job being spawned from the l10nupdate
user's crontab without a controlling login shell.

The use of logname will reveal the true UID that spawned the job rather
than just the EUID that is in use via sudo or other means. This should
provide additional disambiguation in the event of manual execution of
the l10nupdate script for debugging over the naive solution.

Change-Id: I03e21ace687c80db60e2c314c7816bb0c28054dd
---
M modules/scap/files/clear-profile
M modules/scap/files/l10nupdate-1
2 files changed, 10 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/99/228299/1

diff --git a/modules/scap/files/clear-profile b/modules/scap/files/clear-profile
index 5256afb..4f64f5e 100755
--- a/modules/scap/files/clear-profile
+++ b/modules/scap/files/clear-profile
@@ -1,3 +1,4 @@
 #!/bin/bash
+: ${LOGUSER:=$(logname)}
 echo "-truncate" | nc -q0 -u statsd.eqiad.wmnet 3811
-/usr/local/bin/dologmsg "!log $USER@$HOSTNAME cleared profiling data"
+/usr/local/bin/dologmsg "!log $LOGUSER@$HOSTNAME cleared profiling data"
diff --git a/modules/scap/files/l10nupdate-1 b/modules/scap/files/l10nupdate-1
index b400de6..65ece1a 100755
--- a/modules/scap/files/l10nupdate-1
+++ b/modules/scap/files/l10nupdate-1
@@ -12,6 +12,8 @@
 GITURL=https://gerrit.wikimedia.org/r/p/mediawiki
 GITREPOS="core extensions skins"
 QUIET=--quiet
+# Ensure that $LOGUSER is set and has a non-null value.
+: ${LOGUSER:=$(logname)}
 
 umask 0002
 BEGAN=$(date +"%s")
@@ -46,7 +48,7 @@
                then
                        echo "Updated $path"
                else
-                       $BINDIR/dologmsg "!log $USER@$HOSTNAME 
LocalisationUpdate failed: git pull of $path failed"
+                       $BINDIR/dologmsg "!log $LOGUSER@$HOSTNAME 
LocalisationUpdate failed: git pull of $path failed"
                        echo "Updating $path FAILED."
                        exit 1
                fi
@@ -59,7 +61,7 @@
                then
                        echo "Cloned $path"
                else
-                       $BINDIR/dologmsg "!log $USER@$HOSTNAME 
LocalisationUpdate failed: git clone of $path failed"
+                       $BINDIR/dologmsg "!log $LOGUSER@$HOSTNAME 
LocalisationUpdate failed: git clone of $path failed"
                        echo "Cloning $path FAILED."
                        exit 1
                fi
@@ -70,7 +72,7 @@
 # Get all MW message cache versions (and a wiki DB name for each)
 mwVerDbSets=$(mwversionsinuse --withdb)
 if [ -z "$mwVerDbSets" ]; then
-       $BINDIR/dologmsg "!log $USER@$HOSTNAME LocalisationUpdate failed: 
mwversionsinuse returned empty list"
+       $BINDIR/dologmsg "!log $LOGUSER@$HOSTNAME LocalisationUpdate failed: 
mwversionsinuse returned empty list"
        echo "Obtaining MediaWiki version list FAILED"
        exit 1
 fi
@@ -114,11 +116,11 @@
                dsh -g mediawiki-installation -M -F 40 -- "sudo -u mwdeploy 
$SCAPDIR/scap-rebuild-cdbs"
                SYNC_END=$(date +%s)
 
-               $BINDIR/dologmsg "!log $USER@$HOSTNAME LocalisationUpdate 
completed ($mwVerNum) at `date --rfc-3339=seconds`"
+               $BINDIR/dologmsg "!log $LOGUSER@$HOSTNAME LocalisationUpdate 
completed ($mwVerNum) at `date --rfc-3339=seconds`"
                echo "All done at `date --rfc-3339=seconds`"
                $BINDIR/deploy2graphite l10nupdate-sync $((SYNC_END-SYNC_START))
        else
-               $BINDIR/dologmsg "!log $USER@$HOSTNAME LocalisationUpdate 
failed ($mwVerNum) at `date --rfc-3339=seconds`"
+               $BINDIR/dologmsg "!log $LOGUSER@$HOSTNAME LocalisationUpdate 
failed ($mwVerNum) at `date --rfc-3339=seconds`"
                echo "FAILED"
        fi
 done
@@ -133,4 +135,4 @@
 ENDED=$(date +"%s")
 LENGTH=$(($ENDED-$BEGAN))
 $BINDIR/deploy2graphite l10n $LENGTH
-$BINDIR/dologmsg "!log $USER@$HOSTNAME ResourceLoader cache refresh completed 
at $(date -ud @$ENDED) (duration $(date -ud @"$LENGTH" +'%-Mm %-Ss'))"
+$BINDIR/dologmsg "!log $LOGUSER@$HOSTNAME ResourceLoader cache refresh 
completed at $(date -ud @$ENDED) (duration $(date -ud @"$LENGTH" +'%-Mm %-Ss'))"

-- 
To view, visit https://gerrit.wikimedia.org/r/228299
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I03e21ace687c80db60e2c314c7816bb0c28054dd
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to