Skip to content

Commit a341620

Browse files
authored
[docker-ptf] create symlinks for py3-only image (#19813)
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.
1 parent f9ec341 commit a341620

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

dockers/docker-ptf/Dockerfile.j2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ LABEL maintainer="Pavel Shirshov"
1818

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

2223
## Make apt-get non-interactive
2324
ENV DEBIAN_FRONTEND=noninteractive
@@ -266,6 +267,18 @@ RUN dpkg -i \
266267
debs/{{ deb }}{{' '}}
267268
{%- endfor %}
268269

270+
{% if PTF_ENV_PY_VER == "py3" %}
271+
# Create symlink so that test scripts and ptf_runner invocation path
272+
# is same across python 2 and python 3 envs. Note that for virtual-env
273+
# ptf is under /root/env-python3/bin.
274+
# TODO - cleanup when the supported PTF image is py3only across all branches
275+
RUN mkdir -p /root/env-python3/bin \
276+
&& ln -s /usr/local/bin/ptf /usr/bin/ptf \
277+
&& ln -s /usr/bin/python /root/env-python3/bin/python3 \
278+
&& ln -s /usr/bin/python /root/env-python3/bin/python \
279+
&& ln -s /usr/local/bin/ptf /root/env-python3/bin/ptf
280+
{% endif %}
281+
269282
COPY ["*.ini", "/etc/ptf/"]
270283
EXPOSE 22 8009
271284

0 commit comments

Comments
 (0)