Merge lp:~vila/uci-engine/unique-queues into lp:uci-engine

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: 863
Merged at revision: 862
Proposed branch: lp:~vila/uci-engine/unique-queues
Merge into: lp:uci-engine
Diff against target: 83 lines (+9/-9)
4 files modified
lander/lander/tests/test_service_wrapper.py (+3/-3)
lander/lander/workflow.py (+2/-2)
test_runner/bin/check_worker.py (+2/-2)
test_runner/run-integration.py (+2/-2)
To merge this branch: bzr merge lp:~vila/uci-engine/unique-queues
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Paul Larson Approve
Review via email: mp+239462@code.launchpad.net

Commit message

Always use unique queue names for progress report

Description of the change

When running at scale, time.time() to "uniquify" a queue name is not enough, multiple workers can call time.time() at the same... time.

I ran into this while debugging uci-britney and ending up with orphaned queues that still had unprocessed messages.

'prefetch' was adding to the confusion but this collision on queue names is also a nasty trap that is hard to encounter with deployments with a single unit of each type (or even two for the lander).

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

You may want to consider uuid4 instead of uuid1. IIRC uuid1 generates the uuid based on mac address and time... so if these happen on the same node at the same time, I think you could still risk collision right?

Something to consider, but if you know a good reason why that's not a risk, feel free. uuid4 is just a straight pseudorandom uuid, which isn't wonderful, but possibly a better fit here.
Otherwise +1 from me

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:862
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/1626/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/1626/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Vincent Ladeuil (vila) wrote :

Thanks for the review !

> You may want to consider uuid4 instead of uuid1. IIRC uuid1 generates the
> uuid based on mac address and time... so if these happen on the same node at
> the same time, I think you could still risk collision right?

As Joe verified, this doesn't seem to be case.

As I mentioned at the sprint, I just reused uuid1 because that's what was used elsewhere and we may want to revisit later. In the meantime, I think it's safe and I prefer to stay consistent.

>
> Something to consider, but if you know a good reason why that's not a risk,
> feel free. uuid4 is just a straight pseudorandom uuid, which isn't wonderful,
> but possibly a better fit here.

Yeah, that may apply everywhere we used uuid1.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Thanks for the review !

> You may want to consider uuid4 instead of uuid1. IIRC uuid1 generates the
> uuid based on mac address and time... so if these happen on the same node at
> the same time, I think you could still risk collision right?

As Joe verified, this doesn't seem to be case.

As I mentioned at the sprint, I just reused uuid1 because that's what was used elsewhere and we may want to revisit later. In the meantime, I think it's safe and I prefer to stay consistent.

>
> Something to consider, but if you know a good reason why that's not a risk,
> feel free. uuid4 is just a straight pseudorandom uuid, which isn't wonderful,
> but possibly a better fit here.

Yeah, that may apply everywhere we used uuid1.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Yeah, launchpad, I won't say it twice, I won't say it twice...

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:863
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/1633/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/1633/rebuild

review: Approve (continuous-integration)
Revision history for this message
Ubuntu CI Bot (uci-bot) wrote :

The attempt to merge lp:~vila/uci-engine/unique-queues into lp:uci-engine failed. Below is the output from the failed tests.

INFO:root:Creating a virtualenv to run under...
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 2339, in <module>
    main()
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 985, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1193, in install_python
    writefile(site_filename_dst, SITE_PY)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 487, in writefile
    f.write(content.encode('utf-8'))
IOError: [Errno 28] No space left on device
INFO:root:virtualenv created in 0.12s.
Traceback (most recent call last):
  File "bin/called-by-tarmac.py", line 140, in <module>
    sys.exit(main())
  File "bin/called-by-tarmac.py", line 110, in main
    venv.install()
  File "/tmp/tarmac/branch.eq_OUn/bin/../testing/venv.py", line 139, in install
    path = create()
  File "/tmp/tarmac/branch.eq_OUn/bin/../testing/venv.py", line 53, in create
    subprocess.check_call(cmd, stdout=devnull)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['virtualenv', '/dev/shm/venv-h7vcEN', '-p', 'python2.7']' returned non-zero exit status 1

Revision history for this message
Ubuntu CI Bot (uci-bot) wrote :

The attempt to merge lp:~vila/uci-engine/unique-queues into lp:uci-engine failed. Below is the output from the failed tests.

INFO:root:Creating a virtualenv to run under...
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 2339, in <module>
    main()
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 985, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1193, in install_python
    writefile(site_filename_dst, SITE_PY)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 487, in writefile
    f.write(content.encode('utf-8'))
IOError: [Errno 28] No space left on device
INFO:root:virtualenv created in 0.13s.
Traceback (most recent call last):
  File "bin/called-by-tarmac.py", line 140, in <module>
    sys.exit(main())
  File "bin/called-by-tarmac.py", line 110, in main
    venv.install()
  File "/tmp/tarmac/branch.3mbnF7/bin/../testing/venv.py", line 139, in install
    path = create()
  File "/tmp/tarmac/branch.3mbnF7/bin/../testing/venv.py", line 53, in create
    subprocess.check_call(cmd, stdout=devnull)
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['virtualenv', '/dev/shm/venv-AdF9XT', '-p', 'python2.7']' returned non-zero exit status 1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lander/lander/tests/test_service_wrapper.py'
2--- lander/lander/tests/test_service_wrapper.py 2014-10-07 10:04:01 +0000
3+++ lander/lander/tests/test_service_wrapper.py 2014-10-23 22:13:26 +0000
4@@ -38,9 +38,9 @@
5 patch = mock.patch('ci_utils.amqp_utils.get_config')
6 patch.start()
7 self.addCleanup(patch.stop)
8- patchtime = mock.patch('time.time', return_value=1234567890)
9- patchtime.start()
10- self.addCleanup(patchtime.stop)
11+ patch_uuid1 = mock.patch('uuid.uuid1', return_value='1234567890')
12+ patch_uuid1.start()
13+ self.addCleanup(patch_uuid1.stop)
14
15 self.results = tempfile.mkstemp(prefix='lander-test-')[1]
16 self.addCleanup(os.unlink, self.results)
17
18=== modified file 'lander/lander/workflow.py'
19--- lander/lander/workflow.py 2014-10-07 10:04:01 +0000
20+++ lander/lander/workflow.py 2014-10-23 22:13:26 +0000
21@@ -14,7 +14,7 @@
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23
24 import json
25-import time
26+import uuid
27
28 import lander.ticket_api
29
30@@ -62,7 +62,7 @@
31
32 def create(ts_url, ticket_data):
33 data = {
34- 'progress_trigger': 'lander-%d' % time.time(),
35+ 'progress_trigger': 'lander-{}'.format(uuid.uuid1()),
36 'ticket_id': ticket_data['id'],
37 'ts_url': ts_url,
38 'steps': ticket_data['steps'],
39
40=== modified file 'test_runner/bin/check_worker.py'
41--- test_runner/bin/check_worker.py 2014-10-10 13:14:33 +0000
42+++ test_runner/bin/check_worker.py 2014-10-23 22:13:26 +0000
43@@ -16,8 +16,8 @@
44
45 import json
46 import logging
47-import time
48 import signal
49+import uuid
50
51
52 from ci_utils import (
53@@ -74,7 +74,7 @@
54
55
56 def check_worker():
57- queue = 'testrun-test-%d' % time.time()
58+ queue = 'testrun-test-{}'.format(uuid.uuid1())
59 series = 'trusty'
60 architecture = 'amd64'
61 image_id = image_store.uci_image_name('cloudimg', series, architecture)
62
63=== modified file 'test_runner/run-integration.py'
64--- test_runner/run-integration.py 2014-10-10 13:14:33 +0000
65+++ test_runner/run-integration.py 2014-10-23 22:13:26 +0000
66@@ -16,7 +16,7 @@
67
68 import json
69 import logging
70-import time
71+import uuid
72
73
74 from ci_utils import (
75@@ -57,7 +57,7 @@
76
77
78 def run_test():
79- queue = 'testrun-test-%d' % time.time()
80+ queue = 'testrun-test-{}'.format(uuid.uuid1())
81 series = 'trusty'
82 architecture = 'amd64'
83 image_id = image_store.uci_image_name('cloudimg', series, architecture)

Subscribers

People subscribed via source and target branches