Bug #25129

Race condition in install task

Added by Nathan Cutler over 4 years ago. Updated over 4 years ago.

Target version:
% Done:


3 - minor
Affected Versions:
Crash signature (v1):
Crash signature (v2):


When the "branch" option is given to the install task, a race condition can occur, as reproduced here: (minimal reproducer) and here: (real-life example)

Somehow (not sure exactly by which mechanism) Teuthology adds the following override to every job:

        sha1: dd471db8bce26d29051e8c41d2dbd8a2baf5186e

This is the sha1 of the branch given via the --ceph parameter on the teuthology-suite command line. In this case, it's the tip of branch "mimic".

The test yaml further contains:

  - install:
      branch: luminous

When it starts, then, the install task has both "branch: luminous" and "sha1: dd471db8bce26d29051e8c41d2dbd8a2baf5186e" (tip of mimic) in its config dict, causing it to emit a message:

2018-07-26T19:20:51.219 WARNING:teuthology.packaging:More than one of ref, tag, branch, or sha1 supplied; using branch

Next, teuthology queries shaman to get the repo:

2018-07-26T19:20:51.220 DEBUG:teuthology.packaging:Querying

Shaman returns a list of repos containing builds from any SHA1 it finds in branch "luminous", and teuthology takes the first result -

    def _get_base_url(self):
return self._result.json()[0]['url']

At this point, nothing has been installed yet. This marks the beginning of the race condition.

2018-07-26T19:20:51.811 INFO:teuthology.task.install.deb:Pulling from
2018-07-26T19:20:51.814 INFO:teuthology.task.install.deb:Package version is 12.2.7-18-g0ce17fa-1xenial

Now the install task gets to work - calls apt-get install, lots of dependent packages get pulled in, etc. Time passes.

When the packages finish installing, the install task checks to make sure the expected package version was really installed. If, in the meantime, Shaman finishes building another SHA1 from branch "luminous", this check will fail:

2018-07-26T19:22:11.308 WARNING:teuthology.packaging:More than one of ref, tag, branch, or sha1 supplied; using branch
2018-07-26T19:22:11.308 INFO:teuthology.packaging:ref: None
2018-07-26T19:22:11.308 INFO:teuthology.packaging:tag: None
2018-07-26T19:22:11.308 INFO:teuthology.packaging:branch: luminous
2018-07-26T19:22:11.308 INFO:teuthology.packaging:sha1: dd471db8bce26d29051e8c41d2dbd8a2baf5186e
2018-07-26T19:22:11.309 DEBUG:teuthology.packaging:Querying

This again returns a list of repos, but the first one (which is the only one teuthology looks at) is now different! (12.2.7-19-g3a01e5d-1xenial instead of 12.2.7-18-g0ce17fa-1xenial before apt-get was called)

But the log is silent about this anomaly. Next, the install task uses dpkg-query to see which version of the ceph packages was actually installed:

2018-07-26T19:22:11.882 "dpkg-query -W -f '${Version}' ceph" 
2018-07-26T19:22:11.915 INFO:teuthology.packaging:The installed version of ceph is 12.2.7-18-g0ce17fa-1xenial

Now the install task reports the anomaly and aborts:

2018-07-26T19:22:11.915 ERROR:teuthology.contextutil:Saw exception from nested tasks
Traceback (most recent call last):
  File "/home/teuthworker/src/git.ceph.com_git_teuthology_master/teuthology/", line 30, in nested
  File "/usr/lib/python2.7/", line 17, in __enter__
  File "/home/teuthworker/src/git.ceph.com_git_teuthology_master/teuthology/task/install/", line 250, in install
    install_packages(ctx, package_list, config)
  File "/home/teuthworker/src/git.ceph.com_git_teuthology_master/teuthology/task/install/", line 127, in install_packages
    verify_package_version(ctx, config, remote)
  File "/home/teuthworker/src/git.ceph.com_git_teuthology_master/teuthology/task/install/", line 59, in verify_package_version
RuntimeError: ceph version 12.2.7-19-g3a01e5d-1xenial was not installed, found 12.2.7-18-g0ce17fa-1xenial.

IMO in this case the install task should see that "branch: luminous" was given and "override the override", i.e. overwrite the sha1 from --ceph with the real tip of branch "luminous".

Related issues

Related to teuthology - Feature #24760: Add ability to check/install (/from) and/or for released ceph versions Resolved 07/03/2018


#1 Updated by Yuri Weinstein over 4 years ago

  • Related to Feature #24760: Add ability to check/install (/from) and/or for released ceph versions added

#2 Updated by Nathan Cutler over 4 years ago

  • Description updated (diff)

#3 Updated by Sage Weil over 4 years ago

Why is the install task querying shaman a second time? Seems like that's the source of the race...

#4 Updated by Nathan Cutler over 4 years ago

I agree with Sage that it makes sense to take the first repo/version number returned by shaman and stick to it (i.e. not query Shaman post-install, but rather compare the installed version with the result of the first Shaman query). That fixes the race, and will be less disruptive than insisting on tip-of-branch.

#5 Updated by Nathan Cutler over 4 years ago

  • Description updated (diff)

Also available in: Atom PDF