diff --git a/Dockerfile b/Dockerfile index e1a30d5b30..378a76eb98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,8 +30,10 @@ RUN cd /tmp/src/web && yarn install -d && yarn build RUN assemble # The wheel install method doesn't run the setup hooks as the source based -# installations do so we have to call zuul-manage-ansible here. -RUN /output/install-from-bindep && zuul-manage-ansible +# installations do so we have to call zuul-manage-ansible here. Remove +# /root/.local/share/virtualenv after because it adds wheels into /root +# that we don't need after the install step so are a waste of space. +RUN /output/install-from-bindep && zuul-manage-ansible && rm -rf /root/.local/share/virtualenv RUN mkdir /tmp/openshift-install \ && curl -L $OPENSHIFT_URL -o /tmp/openshift-install/openshift-client.tgz \ diff --git a/playbooks/zuul-stream/pre.yaml b/playbooks/zuul-stream/pre.yaml index 3715423079..543d7ab197 100644 --- a/playbooks/zuul-stream/pre.yaml +++ b/playbooks/zuul-stream/pre.yaml @@ -1,6 +1,8 @@ - hosts: controller roles: + - role: ensure-pip + - role: bindep bindep_profile: test bindep_dir: src/opendev.org/zuul/zuul diff --git a/zuul/lib/ansible.py b/zuul/lib/ansible.py index df0ed02137..f4b8fdd940 100644 --- a/zuul/lib/ansible.py +++ b/zuul/lib/ansible.py @@ -49,8 +49,6 @@ class ManagedAnsible: self.install_root = self._ansible_roots[-1] def ensure_ansible(self, upgrade=False): - self._ensure_venv() - self.log.info('Installing ansible %s, requirements: %s, ' 'extra packages: %s', self.version, self._requirements, self.extra_packages) @@ -76,7 +74,7 @@ class ManagedAnsible: p.stderr.decode())) self.log.debug('Successfully installed packages %s', requirements) - def _ensure_venv(self): + def ensure_venv(self): if self.python_path: self.log.debug( 'Virtual environment %s already existing', self.venv_path) @@ -192,6 +190,13 @@ class AnsibleManager: self.default_version = default_version def install(self, upgrade=False): + # virtualenv sets up a shared directory of pip seed packages per + # python version. If we run virtualenv in parallel we can have one + # create the dirs but not be finished filling them with content, a + # second notice the dir is there so it just goes on with what it's + # done, and thus races leaving us with virtualenvs minus pip. + for a in self._supported_versions.values(): + a.ensure_venv() # Note: With higher number of threads pip seems to have some race # leading to occasional failures during setup of all ansible # environments. Thus we limit the number of workers to reduce the risk