Ori.livneh has submitted this change and it was merged.

Change subject: Added MW version argument to scap
......................................................................


Added MW version argument to scap

* It can either be "active" for all active MW versions,
  a specific MW version, or left out for all MW versions.
  The can avoid lots of rsync traffic on old versions.

Change-Id: I1e2bcf4268b389544de35ed4c4a929935a4b5808
---
M files/scap/mw-update-l10n
M files/scap/scap
M files/scap/scap-2
3 files changed, 50 insertions(+), 4 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/files/scap/mw-update-l10n b/files/scap/mw-update-l10n
index 2497548..3823a54 100755
--- a/files/scap/mw-update-l10n
+++ b/files/scap/mw-update-l10n
@@ -48,6 +48,20 @@
 for i in ${mwExtVerDbSets[@]}; do
        mwVerNum=${i%=*}
        mwDbName=${i#*=}
+
+       # Only looks at certain MW version if specified
+       if [ -n "$MW_VERSIONS_SYNC" ]; then
+               skip=1
+               for v in ${MW_VERSIONS_SYNC[@]}; do
+                       if [ "$mwVerNum" == "$v" ]; then
+                               skip=0
+                       fi
+               done
+               if [ "$skip" -eq "1" ]; then
+                       continue
+               fi
+       fi
+
        echo -n "Updating ExtensionMessages-$mwVerNum.php..."
        mwTempDest=$(sudo -u apache mktemp) || die
        sudo -u apache $BINDIR/mwscript mergeMessageFileList.php 
--wiki="$mwDbName" \
diff --git a/files/scap/scap b/files/scap/scap
index 6a89b3c..30961cd 100755
--- a/files/scap/scap
+++ b/files/scap/scap
@@ -33,6 +33,23 @@
        die "SSH_AUTH_SOCK not set or not pointing to a socket. Did you start 
your ssh-agent?"
 fi
 
+DSH_EXPORTS=
+# Only sync the active version(s) if requested
+if [ -n "$1" ]; then
+       # This will export MW_VERSIONS_SYNC to sync-common/mw-update-l10n
+       if [ "$1" == "active" ]; then
+               # All active MW versions
+               export MW_VERSIONS_SYNC=$($BINDIR/mwversionsinuse --home)
+       elif [ -d "$MW_COMMON_SOURCE/$1" ]; then
+               # A specific MW version
+               export MW_VERSIONS_SYNC=$1
+       else
+               die "Invalid MediaWiki version \"$1\""
+       fi
+       # This will export MW_VERSIONS_SYNC to scap-1 on the proxies/servers
+       DSH_EXPORTS="export MW_VERSIONS_SYNC=\"$MW_VERSIONS_SYNC\";"
+fi
+
 # Perform syntax check
 echo -n "Checking syntax of wmf-config and multiversion..."
 if ( ! ( $BINDIR/lint $MW_COMMON_SOURCE/wmf-config && $BINDIR/lint 
$MW_COMMON_SOURCE/multiversion ) ); then
@@ -56,7 +73,7 @@
 export DOLOGMSGNOLOG=1
 
 echo 'Updating rsync proxies...'
-dsh -cM -g scap-proxies -o -oSetupTimeout=10 -- /usr/local/bin/scap-1
+dsh -cM -g scap-proxies -o -oSetupTimeout=10 -- "$DSH_EXPORTS 
/usr/local/bin/scap-1"
 
 # Do the main code update in random order to avoid overloading any given rsync 
server
 NODEFILE=$(mktemp)
@@ -67,7 +84,7 @@
 RSYNC_SERVERS=`echo $RSYNC_SERVERS`
 
 echo 'Copying code to apaches...'
-dsh -F30 -cM -f "$NODEFILE" -o -oSetupTimeout=10 /usr/local/bin/scap-1 
\""$RSYNC_SERVERS"\"
+dsh -F30 -cM -f "$NODEFILE" -o -oSetupTimeout=10 -- "$DSH_EXPORTS 
/usr/local/bin/scap-1 \""$RSYNC_SERVERS"\""
 echo 'Finished'
 
 # Builds wikiversions.cdb and syncs it to the apaches with the dat file
diff --git a/files/scap/scap-2 b/files/scap/scap-2
index 43cfe2b..b8fbbe2 100755
--- a/files/scap/scap-2
+++ b/files/scap/scap-2
@@ -11,8 +11,17 @@
        SERVER="${MW_RSYNC_HOST}"
 fi
 
+RSYNC_ARGS=MW_RSYNC_ARGS
+# Only looks at certain MW version if specified
+if [ -n "$MW_VERSIONS_SYNC" ]; then
+       RSYNC_ARGS+=("--exclude='php-*'")
+       for v in ${MW_VERSIONS_SYNC[@]}; do
+               RSYNC_ARGS+=("--include='php-$v'")
+       done
+fi
+
 echo -n Copying to `hostname -s` from "$SERVER"...
-if rsync "${MW_RSYNC_ARGS[@]}" "$SERVER"::common/ "${MW_COMMON}"
+if rsync "${RSYNC_ARGS[@]}" "$SERVER"::common/ "${MW_COMMON}"
 then
        echo "ok"
 else
@@ -24,7 +33,13 @@
 CPUS=`grep -c 'model name' /proc/cpuinfo`
 THREADS=`expr $CPUS / 2`
 
-mwVersions=$($BINDIR/mwversionsinuse)
+# Only looks at certain MW version if specified
+if [ -n "$MW_VERSIONS_SYNC" ]; then
+       mwVersions=$MW_VERSIONS_SYNC
+else
+       mwVersions=$($BINDIR/mwversionsinuse)
+fi
+
 # Rebuild the CDB files from the JSON versions
 # Regenerate the extension message file list for all active MediaWiki versions
 for mwVerNum in ${mwVersions[@]}; do

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1e2bcf4268b389544de35ed4c4a929935a4b5808
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to