Merge lp:~pfalcon/linaro-license-protection/reshuffle-files-merge-contents into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Paul Sokolovsky
Status: Merged
Merged at revision: 31
Proposed branch: lp:~pfalcon/linaro-license-protection/reshuffle-files-merge-contents
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 38 lines (+20/-10)
1 file modified
scripts/jenkins-post-www.sh (+20/-10)
To merge this branch: bzr merge lp:~pfalcon/linaro-license-protection/reshuffle-files-merge-contents
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Approve
Данило Шеган (community) Needs Fixing
Review via email: mp+88227@code.launchpad.net

Description of the change

Fix for current build breakage (in artifact transfer), more in commit message.

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

This is definitely an improvement over the existing approach so it could land as-is.

However, it still has a race-condition that might become even more harmful since the script will succeed and perhaps "rm -rf" stuff that was pushed to snapshots only in between the "cp" evaluation and "rm" execution. I think the best thing we could do is add a simple lock file to the begining of the script, and loop for a certain time hoping that the lock is cleared, and bail out otherwise.

review: Needs Fixing
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

Rewrote to process one dir at time, as explicitly passed from Jenkins build.

32. By Paul Sokolovsky

Rewrite to receive a directory to process explicitly from Jenkins.

This fixes race condition of removing files being transferred by concurrently
running builds in Jenkins.

33. By Paul Sokolovsky

Remove debug values.

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks good.

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

Note that this approach might mean changes to the setup of the android-build-linaro and android-build-linaro-trigger users. IMO, it reduces the security of the setup, in the sense that we can influence what gets executed from a remote machine, whereas it was so far all implemented on the snapshots.l.o and we could only trigger it from the outside, without passing anything in.

That's why I suggested using a lock, but this could work as well.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/jenkins-post-www.sh'
2--- scripts/jenkins-post-www.sh 2012-01-11 13:15:42 +0000
3+++ scripts/jenkins-post-www.sh 2012-01-11 17:44:24 +0000
4@@ -1,14 +1,24 @@
5 #!/bin/sh
6+set -x
7 BASE_PATH=/home/android-build-linaro/android/.tmp
8 TARGET_PATH=/srv3/snapshots.linaro.org/www/android/
9-for dir in `ls $BASE_PATH`; do
10- if [ -d $BASE_PATH/$dir ]; then
11- username=`echo "$dir" | cut -d_ -f1`
12- buildname=`echo "$dir" | cut -d_ -f2-`
13- echo -n "Moving $BASE_PATH/$dir to $TARGET_PATH/~$username/$buildname... " &&
14- (mkdir -p "$TARGET_PATH/~$username/$buildname" && \
15- mv $BASE_PATH/"$dir"/* "$TARGET_PATH/~$username/$buildname/" && \
16- rmdir $BASE_PATH/"$dir" && \
17+
18+# Expected argument: ~username_jobname/buildno
19+build_path="$1"
20+
21+# Paranoid security
22+if echo "$build_path" | grep -q "\."; then
23+ echo "No dots in build names please"
24+ exit 1
25+fi
26+
27+if [ -d $BASE_PATH/$build_path ]; then
28+ job_dir=$(dirname $build_path)
29+ username=`echo "$job_dir" | cut -d_ -f1`
30+ jobname=`echo "$job_dir" | cut -d_ -f2-`
31+ echo -n "Moving $BASE_PATH/$build_path to $TARGET_PATH/~$username/$jobname/... " &&
32+ (mkdir -p "$TARGET_PATH/~$username/$jobname" && \
33+ cp -a $BASE_PATH/"$build_path" "$TARGET_PATH/~$username/$jobname/" && \
34+ rm -rf $BASE_PATH/"$build_path" && \
35 echo "done")
36- fi
37-done
38+fi

Subscribers

People subscribed via source and target branches