Merge lp:~launchpad-baby-gnu/ubumirror/feature-abort-on-remote-update-in-progress into lp:ubumirror

Proposed by Daniel Dehennin
Status: Needs review
Proposed branch: lp:~launchpad-baby-gnu/ubumirror/feature-abort-on-remote-update-in-progress
Merge into: lp:ubumirror
Diff against target: 63 lines (+36/-1)
1 file modified
ubuarchive (+36/-1)
To merge this branch: bzr merge lp:~launchpad-baby-gnu/ubumirror/feature-abort-on-remote-update-in-progress
Reviewer Review Type Date Requested Status
Ubumirror Developers Pending
Review via email: mp+279599@code.launchpad.net

Description of the change

My patch add some checks on remote mirror state.

It minimize the risk of synchronising a dists/ directory not related to pool/ if our synchronisation speed is slower than the remote one :

- we start synchronising pool/
- remote start its own synchronisation and finish
- synchronisation of pool/ finish for us
- we start synchronising dists/

In which case our current dists/ does not have the proper pool/.

To post a comment you must log in.

Unmerged revisions

85. By Daniel Dehennin <email address hidden>

Check remote state before synchronising dist

Sometimes, the synchronisation of pool/ is long enough for remote mirror
to begin a new synchronisation before we start synchronising dists/.

We need to check if remote “project/trace/” has changed since we started
as the remote mirror could be faster than us.

* ubuarchive: Call “check_remote_state” before syncing pool and dist.
 (check_remote_state): Check remote “Archive-Update-in-Progress” lock
 and if remote “project/trace/” has changed.
 (_clean_on_exit): function to clean everything at EXIT.

84. By Daniel Dehennin <email address hidden>

Abort if the remote update is in progress

* ubuarchive: Test if remote 'Archive-Update-in-Progress-*' is present.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuarchive'
2--- ubuarchive 2014-06-08 05:58:41 +0000
3+++ ubuarchive 2015-12-04 13:49:51 +0000
4@@ -39,9 +39,40 @@
5 exit 2
6 fi
7
8+check_remote_state() {
9+ if rsync ${UBUARC_MIRROR}/Archive-Update-in-Progress-* > /dev/null 2>&1; then
10+ echo "$(date -R): Remote mirror update is in progress: abort."
11+ exit 1
12+ fi
13+
14+ if [ ! -d "${STATE_DIR}/init" ]; then
15+ rsync -a --delete --delete-after ${UBUARC_MIRROR}/project/trace ${STATE_DIR}/init
16+ elif rsync -a --delete --delete-after ${UBUARC_MIRROR}/project/trace ${STATE_DIR}/check; then
17+ if ! diff -qr ${STATE_DIR}/init/ ${STATE_DIR}/check/; then
18+ echo "$(date -R): Remote mirror was updated during our synchronisation: abort."
19+ exit 1
20+ fi
21+ else
22+ echo "$(date -R): Unable to check remote state: abort."
23+ exit 1
24+ fi
25+}
26+
27+_clean_on_exit() {
28+ EXIT_CODE=$?
29+
30+ # Do not abort on failure as we are in SIGHANDLER
31+ set +e
32+ rm -f "${LOCK}" > /dev/null 2>&1
33+ [ ! -d "${STATE_DIR}" ] || rm -rf "${STATE_DIR}"
34+
35+ savelog -c 28 -n $LOGFILE > /dev/null
36+}
37+
38 LOCK="${UBUARC_DIR}/Archive-Update-in-Progress-${HOSTNAME}"
39+STATE_DIR=$(mktemp -d -t ubuarchive-XXXXXXXX)
40
41-trap 'rm -f $LOCK > /dev/null 2>&1; savelog -c 28 -n $LOGFILE > /dev/null' EXIT
42+trap _clean_on_exit EXIT
43
44 # Get in the right directory and set the umask
45 cd $HOME
46@@ -62,6 +93,8 @@
47
48 echo "$(date -R): Lock established for process $(cat $LOCK)."
49
50+check_remote_state
51+
52 set +e
53 echo "$(date -R): Initiating Ubuntu archive pool sync..."
54
55@@ -82,6 +115,8 @@
56
57 echo "$(date -R): Ubuntu archive pool sync completed."
58
59+check_remote_state
60+
61 echo "$(date -R): Initiating Ubuntu archive dists and indices sync..."
62
63 rsync -av --partial --delete --delete-after \

Subscribers

People subscribed via source and target branches

to status/vote changes: