Skip to content

Commit

Permalink
[docker-ptf] create symlinks for py3-only image (sonic-net#19813)
Browse files Browse the repository at this point in the history
Why I did it
The mix of docker-ptf with Python 2 + Python 3 (in virtual-env) and Python 3 images only across branches (with possibly some test scripts in sonic-mgmt not migrated to Python 3 in older branches) causes different path references to Python and PTF binaries. This can cause backporting a hassle. To prevent this the PR creates virtual environment (/root/env-python3) path to the real python 3 and PTF binaries. This keeps the paths same across docker-ptf images.

How I did it
Created symlinks for python and PTF from /root/env-python3/bin to /usr/bin.

How to verify it
Image built successfully and manually verified the existence of the links.
  • Loading branch information
opcoder0 authored Aug 23, 2024
1 parent f9ec341 commit a341620
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dockers/docker-ptf/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LABEL maintainer="Pavel Shirshov"

COPY ["sources.list.{{ CONFIGURED_ARCH }}", "/etc/apt/sources.list"]
COPY ["no-check-valid-until", "/etc/apt/apt.conf.d"]
COPY ["apt-retries-count", "/etc/apt/apt.conf.d"]

## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -266,6 +267,18 @@ RUN dpkg -i \
debs/{{ deb }}{{' '}}
{%- endfor %}

{% if PTF_ENV_PY_VER == "py3" %}
# Create symlink so that test scripts and ptf_runner invocation path
# is same across python 2 and python 3 envs. Note that for virtual-env
# ptf is under /root/env-python3/bin.
# TODO - cleanup when the supported PTF image is py3only across all branches
RUN mkdir -p /root/env-python3/bin \
&& ln -s /usr/local/bin/ptf /usr/bin/ptf \
&& ln -s /usr/bin/python /root/env-python3/bin/python3 \
&& ln -s /usr/bin/python /root/env-python3/bin/python \
&& ln -s /usr/local/bin/ptf /root/env-python3/bin/ptf
{% endif %}

COPY ["*.ini", "/etc/ptf/"]
EXPOSE 22 8009

Expand Down

0 comments on commit a341620

Please sign in to comment.