From bc65ed3c0c964ba8bbaa53fa18a41af3e2c024ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulko?= Date: Wed, 8 Jun 2022 16:25:32 +0200 Subject: [PATCH] Run Kuryr inside containers in venv We've just hit an issue where Ceph repo added by RDO upgraded setuptools to a version that pip cannot uninstall. This is mainly because we're still installing all the Kuryr dependencies in system's site-packages. This commit switches us to create and use a virtualenv to have a clean environment in which we install all the dependencies through pip. Change-Id: Ieb9fd5ed0251425e9fe172e4a93ad048768ce785 --- cni.Dockerfile | 7 ++++++- controller.Dockerfile | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cni.Dockerfile b/cni.Dockerfile index cff239a31..7f073bb0e 100644 --- a/cni.Dockerfile +++ b/cni.Dockerfile @@ -13,11 +13,16 @@ ARG OSLO_LOCK_PATH=/var/kuryr-lock ARG RDO_REPO=https://repos.fedorapeople.org/repos/openstack/openstack-yoga/rdo-release-yoga-1.el9s.noarch.rpm RUN dnf upgrade -y && dnf install -y epel-release $RDO_REPO \ - && dnf install -y --setopt=tsflags=nodocs python3-pip python3-setuptools-53.0.0-10.el9 openvswitch sudo iproute pciutils kmod-libs \ + && dnf install -y --setopt=tsflags=nodocs python3-pip openvswitch sudo iproute pciutils kmod-libs \ && dnf install -y --setopt=tsflags=nodocs gcc gcc-c++ python3-devel git COPY . /opt/kuryr-kubernetes +ARG VIRTUAL_ENV=/opt/venv +RUN python3 -m venv $VIRTUAL_ENV +# This is enough to activate a venv +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + RUN pip3 --no-cache-dir install -U pip \ && python3 -m pip --no-cache-dir install -c $UPPER_CONSTRAINTS_FILE /opt/kuryr-kubernetes \ && cp /opt/kuryr-kubernetes/cni_ds_init /usr/bin/cni_ds_init \ diff --git a/controller.Dockerfile b/controller.Dockerfile index 4d2f08f57..125f7a629 100644 --- a/controller.Dockerfile +++ b/controller.Dockerfile @@ -10,6 +10,11 @@ RUN dnf upgrade -y \ COPY . /opt/kuryr-kubernetes +ARG VIRTUAL_ENV=/opt/venv +RUN python3 -m venv $VIRTUAL_ENV +# This is enough to activate a venv +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + RUN pip3 --no-cache-dir install -U pip \ && python3 -m pip install -c $UPPER_CONSTRAINTS_FILE --no-cache-dir /opt/kuryr-kubernetes \ && dnf -y history undo last \