Merge lp:~jpds/launchpad/archivepublisher-log-to-file into lp:launchpad

Proposed by Jonathan Davies on 2010-03-09
Status: Rejected
Rejected by: Tom Haddon on 2010-03-09
Proposed branch: lp:~jpds/launchpad/archivepublisher-log-to-file
Merge into: lp:launchpad
Diff against target: 208 lines (+48/-13)
1 file modified
cronscripts/publishing/cron.publish-ftpmaster (+48/-13)
To merge this branch: bzr merge lp:~jpds/launchpad/archivepublisher-log-to-file
Reviewer Review Type Date Requested Status
Graham Binns (community) code 2010-03-09 Approve on 2010-03-09
Julian Edwards 2010-03-09 Pending
Review via email: mp+20974@code.launchpad.net

Commit Message

Made cron.publish-ftpmaster log messages to a file rather than a cron mail spool.

Description of the Change

= Summary =

This branch makes the cron.publish-ftpmaster cronjob log all of its output to a log file in:

/srv/launchpad.net/production-logs/lp_publish/publish-ftpmaster.log

...rather than having cron send all the output to the lp_publish user's mail spool file where it's building up and hard to find what ran at what time.

It also rotates the log when it's completed a run and keep up to a month's worth of logs.

All actions are additionally timestamped.

To post a comment you must log in.
Graham Binns (gmb) :
review: Approve (code)
Tom Haddon (mthaddon) wrote :

For reasons discussed on IRC I'd rather this wasn't merged. We should just do this in the crontab rather than in the script itself.

Julian Edwards (julian-edwards) wrote :

Can you paste the conversation in here for posterity please?

Unmerged revisions

10464. By Jonathan Davies on 2010-03-09

Timestamp these two last things.

10463. By Jonathan Davies on 2010-03-09

Log all output of cron.publish-ftpmaster to file instead of via cron emails and
timestamp everything we do.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cronscripts/publishing/cron.publish-ftpmaster'
2--- cronscripts/publishing/cron.publish-ftpmaster 2010-03-02 17:48:37 +0000
3+++ cronscripts/publishing/cron.publish-ftpmaster 2010-03-09 15:48:26 +0000
4@@ -43,27 +43,37 @@
5 # Configuration options.
6 LAUNCHPADROOT=/srv/launchpad.net/codelines/current
7 LOCKFILE=/srv/launchpad.net/ubuntu-archive/cron.daily.lock
8+LOGDIR=/srv/launchpad.net/production-logs
9+LOGFILE=$LOGDIR/lp_publish/publish-ftpmaster.log
10 DISTRONAME=ubuntu
11 TRACEFILE=$ARCHIVEROOT/project/trace/$(hostname --fqdn)
12 DSYNCLIST=$CACHEROOT/dsync.list
13 MD5LIST=$INDICES/md5sums.gz
14
15+# Mirrors to push at the end of the publishing run.
16+MASTERMIRRORS="syowa frei scandium"
17+
18 # Manipulate the environment.
19 export GNUPGHOME
20 PATH=$PATH:$LAUNCHPADROOT/scripts:$LAUNCHPADROOT/cronscripts:$LAUNCHPADROOT/cronscripts/publishing:$LAUNCHPADROOT/scripts/ftpmaster-tools
21
22+# Log all output to file.
23+exec >> $LOGFILE 2>&1
24+
25 # Claim the lock.
26 if ! lockfile -r1 $LOCKFILE; then
27 echo "Could not claim lock file."
28 exit 1
29 fi
30
31+echo "$(date -R): Initiating archive publishing operations..."
32+
33 DONEPUB=no
34
35 cleanup () {
36- echo "Cleaning up lockfile."
37+ echo "$(date -R): Cleaning up lockfile."
38 rm -f $LOCKFILE
39- echo "Moving dists backup to safe keeping for next time."
40+ echo "$(date -R): Moving dists backup to safe keeping for next time."
41 if [ "x$DONEPUB" = "xyes" ]; then
42 if [ -d ${DISTSROOT}.old ]; then
43 mv ${DISTSROOT}.old ${DISTSCOPYROOT}/dists
44@@ -82,6 +92,10 @@
45 if [ "$SECURITY_PUBLISHER" = "yes" ]; then
46 exec $0
47 fi
48+
49+ # Keep up to a month of log files.
50+ echo "$(date -R): Rotating log file."
51+ savelog -c 750 $LOGFILE > /dev/null 2>&1
52 }
53
54 trap cleanup EXIT
55@@ -89,11 +103,13 @@
56 # Lock claimed.
57
58 # Process the accepted queue into the publishing records.
59+echo "$(date -R): Processing the accepted queue into the publishing records..."
60 process-accepted.py -v -v -v $DISTRONAME
61
62 # If doing a security run, find out which suites are pending publication.
63 SUITEOPTS=""
64 if [ "$SECURITY_PUBLISHER" = "yes" ]; then
65+ echo "$(date -R): Querying which suites are pending publication..."
66 SUITES=$(lp-query-distro.py pending_suites)
67 SECURITY_SUITES="no"
68 if [ -n "$SUITES" ]; then
69@@ -109,7 +125,7 @@
70 done
71 fi
72 if [ "$SECURITY_SUITES" != "yes" ]; then
73- echo "Nothing to do for security publisher; exiting."
74+ echo "$(date -R): Nothing to do for security publisher; exiting."
75 exit 0
76 fi
77 fi
78@@ -122,21 +138,27 @@
79 # This should achieve the same as copying, only faster.
80
81 # Create backup dists folder, if this is the first time.
82+echo "$(date -R): Creating backup dists directories..."
83 mkdir -p ${DISTSCOPYROOT}/dists
84 mkdir -p ${DISTSCOPYROOT_PARTNER}/dists
85
86 # Move the backup dists folder into place.
87+echo "$(date -R): Moving backup dists into place..."
88 mv ${DISTSCOPYROOT}/dists ${ARCHIVEROOT}/dists.new
89 mv ${DISTSCOPYROOT_PARTNER}/dists ${ARCHIVEROOT_PARTNER}/dists.new
90
91 # Bring it up-to-date efficiently with rsync. --delete is required to
92 # ensure we don't ressurect things previously deleted, bug 58835.
93+echo "$(date -R): Updating dists directories..."
94 rsync -aH --delete ${DISTSROOT}/ ${ARCHIVEROOT}/dists.new
95 rsync -aH --delete ${DISTSROOT_PARTNER}/ ${ARCHIVEROOT_PARTNER}/dists.new
96
97 # Publish the results for all archives (except PPA).
98 # The -R only affects the primary and the partner archive.
99+echo "$(date -R): Publishing the $DISTRONAME partner archive..."
100 publish-distro.py -v -v --partner -d $DISTRONAME -R ${DISTSROOT_PARTNER}.new
101+
102+echo "$(date -R): Publishing the $DISTRONAME archive..."
103 publish-distro.py -v -v -d $DISTRONAME $SUITEOPTS -R ${DISTSROOT}.new
104
105 set +x
106@@ -148,39 +170,40 @@
107 $(find ${DISTSROOT}.new/*/*/dist-upgrader* -name "*.tar.gz"); do
108 # [ Release.gpg missing ] or [ Release is newer than Release.gpg ]
109 if [ ! -f $CANDIDATE.gpg ] || [ $CANDIDATE -nt $CANDIDATE.gpg ]; then
110- echo "(re-)signing $CANDIDATE"
111+ echo "$(date -R): (re-)signing $CANDIDATE"
112 gpg --yes --detach-sign --armor -o $CANDIDATE.gpg --sign $CANDIDATE
113 else
114- echo "Not re-signing $CANDIDATE"
115+ echo "$(date -R): Not re-signing $CANDIDATE"
116 fi
117 done
118 SIGNLIST_PARTNER=$(find ${DISTSROOT_PARTNER}.new -maxdepth 2 -name Release)
119 for CANDIDATE in $SIGNLIST_PARTNER; do
120 # [ Release.gpg missing ] or [ Release is newer than Release.gpg ].
121 if [ ! -f $CANDIDATE.gpg ] || [ $CANDIDATE -nt $CANDIDATE.gpg ]; then
122- echo "(re-)signing $CANDIDATE"
123+ echo "$(date -R): (re-)signing $CANDIDATE"
124 gpg --yes --detach-sign --armor -o $CANDIDATE.gpg --sign $CANDIDATE
125 else
126- echo "Not re-signing $CANDIDATE"
127+ echo "$(date -R): Not re-signing $CANDIDATE"
128 fi
129 done
130
131 # The Packages and Sources files are very large and would cripple our
132 # mirrors, so we remove them now that the uncompressed MD5SUMS are in the
133 # Release files.
134-echo Removing uncompressed Packages and Sources files
135+echo "$(date -R): Removing uncompressed Packages and Sources files"
136 find ${DISTSROOT}.new \( -name "Packages" -o -name "Sources" \) -exec rm "{}" \;
137 find ${DISTSROOT_PARTNER} \( -name "Packages" -o -name "Sources" \) -exec rm "{}" \;
138
139 # Copy in the indices.
140 if [ "$LPCONFIG" = "$PRODUCTION_CONFIG" ]; then
141- echo Copying the indices into place.
142+ echo "$(date -R): Copying the indices into place."
143 rm -f $INDICES/override.*
144 cp $OVERRIDEROOT/override.* $INDICES
145 fi
146
147 # As close to atomically as possible, put the new dists into place for the
148 # primary and partner archives.
149+echo "$(date -R): Placing the new dists into place..."
150 mv $DISTSROOT ${DISTSROOT}.old
151 mv ${DISTSROOT}.new $DISTSROOT
152 mv $DISTSROOT_PARTNER ${DISTSROOT_PARTNER}.old
153@@ -197,6 +220,7 @@
154 # Timestamp our trace file to track when the last archive publisher run took
155 # place.
156 if [ "$LPCONFIG" = "$PRODUCTION_CONFIG" ]; then
157+ echo "$(date -R): Timestamping trace file..."
158 date -u > "$TRACEFILE"
159 fi
160
161@@ -204,6 +228,7 @@
162 if [ "$SECURITY_PUBLISHER" != "yes" ]; then
163
164 # Make the lslr because we all love those.
165+ echo "$(date -R): Creating ls-lR.gz..."
166 LSLR=ls-lR.gz
167 ( cd $ARCHIVEROOT ; \
168 rm -f .$LSLR.new ; \
169@@ -215,25 +240,35 @@
170 mv -f .$LSLR.new $LSLR )
171
172 # Run dsync over primary archive only.
173+ echo "$(date -R): Running dsync over primary archive..."
174 ( cd $ARCHIVEROOT ; \
175 dsync-flist -q generate $DSYNCLIST -e 'Packages*' -e 'Sources*' -e 'Release*' --md5 ; \
176 (dsync-flist -q md5sums $DSYNCLIST; find dists '(' -name 'Packages*' -o -name 'Sources*' -o -name 'Release*' ')' -print | xargs -r md5sum) | gzip -9n > ${MD5LIST} ; \
177 dsync-flist -q link-dups $DSYNCLIST || true )
178
179 # Clear out empty and thus redundant dirs.
180+ echo "$(date -R): Clearing out empty directories..."
181 find $ARCHIVEROOT -type d -empty | xargs -r rmdir
182 find $ARCHIVEROOT_PARTNER -type d -empty | xargs -r rmdir
183
184 # Invoke cron.germinate to fill ubuntu tasks and ignore failures,
185 # the mirrors should be always triggered.
186- cron.germinate || echo "cron.germinate failed with exit code $?" >&2
187+ echo "$(date -R): Running cron.germinate..."
188+ cron.germinate || echo "$(date -R): cron.germinate failed with exit code $?"
189
190 # End of block skipped by security publishing.
191 fi
192
193 # Trigger master mirrors.
194 if [ "$LPCONFIG" = "$PRODUCTION_CONFIG" ]; then
195- ssh archvsync@syowa
196- ssh archvsync@frei
197- ssh archvsync@scandium
198+ echo "$(date -R): Triggering master mirrors..."
199+
200+ for HOST in $MASTERMIRRORS; do
201+ echo "$(date -R): Triggering $HOST:"
202+ ssh archvsync@$HOST
203+ done
204+
205+ echo "$(date -R): Master mirror triggers completed."
206 fi
207+
208+echo "$(date -R): Archive publishing operations completed."