Merge lp://staging/~michael.nelson/launchpad/627608-p3a-token-race into lp://staging/launchpad

Proposed by Michael Nelson
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: 11812
Proposed branch: lp://staging/~michael.nelson/launchpad/627608-p3a-token-race
Merge into: lp://staging/launchpad
Diff against target: 90 lines (+50/-6)
2 files modified
lib/lp/archivepublisher/scripts/generate_ppa_htaccess.py (+7/-2)
lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py (+43/-4)
To merge this branch: bzr merge lp://staging/~michael.nelson/launchpad/627608-p3a-token-race
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+39469@code.staging.launchpad.net

Commit message

p3a access tokens created in the window when the generate_ppa_htaccess script runs will be included in the next run.

Description of the change

Overview
========

This branch ensures that if a token is created *while* the generate_ppa_htaccess script is running (ie. before the script finishes), that it will be included the next time the script runs.

Details
=======
We did some work recently to improve the generate_ppa_htaccess script so that it could run minutely. That work selected only tokens that had been created since the last successful script run completed.

We recently saw bug 627608 happening again, even though the script was running minutely, and discovered that if the token is created in the tiny window *after* a run of the script has started, but before it is finished, then it won't be included in the next run either (more detailed description on the bug).

The branch does the adds a test and trivial fix, and fixes an existing test which was incorrectly setting the date_started for the script activity.

To test
=======

bin/test -vvm test_generate_ppa_htaccess

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

It's very picky, but I think I'd find the tests easier to understand if you gave the times names, like so:

earliest = now - timedelta(seconds=20)
latest = now - timedelta(seconds=10)
in_between = now - timedelta(seconds=15)

and use keyword arguments in the calls to recordSuccess then it's a bit easier to see the relationship between them. Not 100% sure about the names.

Even if you don't do this, the change looks good to land. Congratulations on finding the problem :-)

review: Approve
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Thanks Michael.

Regarding the possible NTP-skew between servers, I've added the fudge-factor of 1 second as you suggested.

I've pushed 11812, but the incremental is here:
http://pastebin.ubuntu.com/520992/

I also created the variables for clarity as you suggested.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.