Skip to content

Commit 6938be7

Browse files
arpsharmArpit Sharma
andauthored
Updated prow Dockerfile for newer versions and defined new variables (#1182)
Updated prow Dockerfile for newer versions and defined new variables Updated prow Dockerfile for newer versions and defined new variables Co-authored-by: Arpit Sharma <arpsharm@arpsharm-thinkpadx1carbongen9.bengluru.csb>
1 parent dbba684 commit 6938be7

File tree

4 files changed

+119
-64
lines changed

4 files changed

+119
-64
lines changed

Dockerfile

Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,46 @@
1-
FROM quay.io/centos/centos:stream9
1+
FROM quay.io/centos/centos:stream10
22

3-
# Update and use not only best candidate packages (avoiding failures)
4-
RUN dnf update -y --nobest
5-
6-
# Install development tools and necessary dependencies
7-
RUN dnf group install -y "Development Tools" \
8-
&& dnf install -y podman jq
9-
10-
# Prerequisite for Python installation
11-
ARG python_full_version=3.14.0
12-
RUN dnf install -y openssl-devel bzip2-devel wget libffi-devel
13-
14-
# Install Python
15-
RUN wget https://www.python.org/ftp/python/${python_full_version}/Python-${python_full_version}.tgz \
3+
ARG python_version=3.14
4+
ARG OCP_CLIENT_VERSION
5+
ARG VIRTCTL_VERSION
6+
ARG BENCHMARK_OPERATOR_VERSION=v1.0.4
7+
ARG OPENSHIFT4_TOOLS_VERSION=v1.2.2-kata-ci
8+
9+
ENV PYTHON_VERSION=${python_version}
10+
11+
COPY hack/get_latest_python_patch.py /tmp/get_latest_python_patch.py
12+
RUN python_patch=$(python3 /tmp/get_latest_python_patch.py ${python_version}) \
13+
&& python_full_version=${python_version}.${python_patch} \
14+
&& dnf update -y --nobest \
15+
&& dnf group install -y "Development Tools" \
16+
&& dnf install -y podman jq openssl-devel bzip2-devel wget libffi-devel hostname bc procps-ng \
17+
&& wget https://www.python.org/ftp/python/${python_full_version}/Python-${python_full_version}.tgz \
1618
&& tar -xzf Python-${python_full_version}.tgz \
1719
&& cd Python-${python_full_version} \
1820
&& ./configure --enable-optimizations \
1921
&& make altinstall \
20-
&& echo alias python=python3.14 >> ~/.bashrc \
21-
&& rm -rf Python-${python_full_version}.tgz
22-
23-
# install & run benchmark-runner (--no-cache-dir for take always the latest)
24-
RUN python3.14 -m pip install --upgrade pip && python3.14 -m pip install --upgrade benchmark-runner
25-
26-
# Passed dynamically
27-
ARG OCP_CLIENT_VERSION
28-
RUN curl -L "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_CLIENT_VERSION}/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" -o "/tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" \
29-
&& tar -xzvf /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz -C /tmp/ \
30-
&& mv /tmp/kubectl /usr/local/bin/kubectl \
31-
&& mv /tmp/oc /usr/local/bin/oc \
32-
&& rm -rf /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz /tmp/kubectl /tmp/oc
33-
34-
# Passed dynamically
35-
ARG VIRTCTL_VERSION
36-
RUN curl -L "https://github.com/kubevirt/kubevirt/releases/download/v${VIRTCTL_VERSION}/virtctl-v${VIRTCTL_VERSION}-linux-amd64" -o /usr/local/bin/virtctl \
37-
&& chmod +x /usr/local/bin/virtctl
38-
39-
# Activate root alias
40-
RUN source ~/.bashrc
41-
42-
# Create necessary directories with the correct permissions
43-
RUN mkdir -p ~/.kube ~/.ssh /tmp/run_artifacts
44-
45-
# download benchmark-operator to /tmp default path
46-
RUN git clone -b v1.0.4 https://github.com/cloud-bulldozer/benchmark-operator /tmp/benchmark-operator
47-
48-
# download clusterbuster to /tmp default path && install cluster-buster dependency
49-
RUN git clone -b v1.2.2-kata-ci https://github.com/RobertKrawitz/OpenShift4-tools /tmp/OpenShift4-tools \
50-
&& dnf install -y hostname bc procps-ng
51-
52-
# Cleanup to reduce image size
53-
RUN dnf clean all && rm -rf /var/cache/dnf
22+
&& echo alias python=python${python_version} >> ~/.bashrc \
23+
&& cd .. \
24+
&& rm -rf Python-${python_full_version} Python-${python_full_version}.tgz \
25+
&& python${python_version} -m pip install --upgrade pip \
26+
&& python${python_version} -m pip install --upgrade benchmark-runner \
27+
&& curl -L "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_CLIENT_VERSION}/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" -o "/tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" \
28+
&& tar -xzf /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz -C /usr/local/bin kubectl oc \
29+
&& rm /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz \
30+
&& curl -L "https://github.com/kubevirt/kubevirt/releases/download/v${VIRTCTL_VERSION}/virtctl-v${VIRTCTL_VERSION}-linux-amd64" -o /usr/local/bin/virtctl \
31+
&& chmod +x /usr/local/bin/virtctl \
32+
&& mkdir -p ~/.kube ~/.ssh /tmp/run_artifacts \
33+
&& git clone -b ${BENCHMARK_OPERATOR_VERSION} https://github.com/cloud-bulldozer/benchmark-operator /tmp/benchmark-operator \
34+
&& git clone -b ${OPENSHIFT4_TOOLS_VERSION} https://github.com/RobertKrawitz/OpenShift4-tools /tmp/OpenShift4-tools \
35+
&& dnf clean all \
36+
&& rm -rf /var/cache/dnf
5437

5538
# Add main
5639
COPY benchmark_runner/main/main.py /benchmark_runner/main/main.py
5740

58-
CMD [ "python3.14", "/benchmark_runner/main/main.py"]
41+
# Shell form so PYTHON_VERSION is expanded; exec form would not expand ENV
42+
CMD ["/bin/sh", "-c", "exec python${PYTHON_VERSION} /benchmark_runner/main/main.py"]
5943

6044
# How to build the Dockerfile ?
61-
# sudo podman build --build-arg OCP_CLIENT_VERSION=$OCP_CLIENT_VERSION--build-arg VIRTCTL_VERSION=$VIRTCTL_VERSION -t quay.io/benchmark-runner/benchmark-runner:latest . --no-cache
45+
# sudo podman build --build-arg OCP_CLIENT_VERSION=$OCP_CLIENT_VERSION --build-arg VIRTCTL_VERSION=$VIRTCTL_VERSION -t quay.io/benchmark-runner/benchmark-runner:latest . --no-cache
6246
# sudo podman run --rm -it -v /root/.kube/:/root/.kube/ -v /etc/hosts:/etc/hosts --privileged quay.io/benchmark-runner/benchmark-runner:latest /bin/bash

ci_pod/jetlag/run_jetlag.sh

100644100755
File mode changed.

hack/get_latest_python_patch.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/python3
2+
"""
3+
Find the latest point release for a given Python minor version (e.g. 3.14)
4+
by parsing https://www.python.org/ftp/python/
5+
Used at Docker build time to install the latest bugfix release.
6+
"""
7+
from html.parser import HTMLParser
8+
import sys
9+
import urllib.request
10+
import urllib.error
11+
12+
URL = 'https://www.python.org/ftp/python/'
13+
14+
15+
def find_best_python_version(release):
16+
class FindPythonVersion(HTMLParser):
17+
def __init__(self, release):
18+
super().__init__()
19+
self.release = release
20+
self.start = f'{release}.'
21+
self.best_found_version = None
22+
23+
def handle_starttag(self, tag, attrs):
24+
if tag == 'a':
25+
try:
26+
for name, value in attrs:
27+
if name == 'href':
28+
if value.startswith(self.start):
29+
point = int(value.removeprefix(self.start).rstrip('/'))
30+
if self.best_found_version is None or point > self.best_found_version:
31+
self.best_found_version = point
32+
return
33+
except Exception:
34+
pass
35+
36+
def get_best_version(self):
37+
return self.best_found_version
38+
39+
try:
40+
with urllib.request.urlopen(URL) as response:
41+
data = response.read().decode('utf-8')
42+
except urllib.error.HTTPError as e:
43+
print(f'HTTP error: {e.code} {e.reason}', file=sys.stderr)
44+
sys.exit(1)
45+
except urllib.error.URLError as e:
46+
print(f'URL error: {e.reason}', file=sys.stderr)
47+
sys.exit(1)
48+
49+
parser = FindPythonVersion(release)
50+
try:
51+
parser.feed(data)
52+
if parser.get_best_version() is not None:
53+
print(parser.get_best_version())
54+
else:
55+
print(f'Cannot find python version for {release}', file=sys.stderr)
56+
sys.exit(1)
57+
except Exception as e:
58+
print(f'Cannot find python version for {release}: {e}', file=sys.stderr)
59+
sys.exit(1)
60+
61+
62+
if __name__ == '__main__':
63+
if len(sys.argv) != 2:
64+
print(f'Usage: {sys.argv[0]} <minor_version> (e.g. 3.14)', file=sys.stderr)
65+
sys.exit(1)
66+
find_best_python_version(sys.argv[1])

prow/Dockerfile

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
1-
FROM quay.io/centos/centos:stream9
1+
FROM quay.io/centos/centos:stream10
22

3-
ARG python_full_version=3.14.0
4-
ARG OCP_CLIENT_VERSION=4.19.1
5-
ARG VIRTCTL_VERSION=1.5.0
3+
ARG python_version=3.14
4+
ARG OCP_CLIENT_VERSION=4.21.2
5+
ARG VIRTCTL_VERSION=1.7.0
6+
ARG BENCHMARK_OPERATOR_VERSION=v1.0.4
7+
ARG OPENSHIFT4_TOOLS_VERSION=v1.2.2-kata-ci
68

7-
RUN dnf update -y --nobest \
9+
ENV PYTHON_VERSION=${python_version}
10+
11+
COPY hack/get_latest_python_patch.py /tmp/get_latest_python_patch.py
12+
RUN python_patch=$(python3 /tmp/get_latest_python_patch.py ${python_version}) \
13+
&& python_full_version=${python_version}.${python_patch} \
14+
&& dnf update -y --nobest \
815
&& dnf group install -y "Development Tools" \
916
&& dnf install -y podman jq openssl-devel bzip2-devel wget libffi-devel hostname bc procps-ng \
1017
&& wget https://www.python.org/ftp/python/${python_full_version}/Python-${python_full_version}.tgz \
1118
&& tar -xzf Python-${python_full_version}.tgz \
1219
&& cd Python-${python_full_version} \
1320
&& ./configure --enable-optimizations \
1421
&& make altinstall \
15-
&& echo alias python=python3.14 >> ~/.bashrc \
22+
&& echo alias python=python${python_version} >> ~/.bashrc \
1623
&& cd .. \
1724
&& rm -rf Python-${python_full_version} Python-${python_full_version}.tgz \
18-
&& python3.14 -m pip install --upgrade pip \
19-
&& python3.14 -m pip install --upgrade benchmark-runner \
25+
&& python${python_version} -m pip install --upgrade pip \
26+
&& python${python_version} -m pip install --upgrade benchmark-runner \
2027
&& curl -L "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_CLIENT_VERSION}/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" -o "/tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz" \
21-
&& tar -xzvf /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz -C /tmp/ \
22-
&& mv /tmp/kubectl /usr/local/bin/kubectl \
23-
&& mv /tmp/oc /usr/local/bin/oc \
24-
&& rm -rf /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz /tmp/kubectl /tmp/oc \
28+
&& tar -xzf /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz -C /usr/local/bin kubectl oc \
29+
&& rm /tmp/openshift-client-linux-${OCP_CLIENT_VERSION}.tar.gz \
2530
&& curl -L "https://github.com/kubevirt/kubevirt/releases/download/v${VIRTCTL_VERSION}/virtctl-v${VIRTCTL_VERSION}-linux-amd64" -o /usr/local/bin/virtctl \
2631
&& chmod +x /usr/local/bin/virtctl \
2732
&& mkdir -p ~/.kube ~/.ssh /tmp/run_artifacts \
28-
&& git clone -b v1.0.4 https://github.com/cloud-bulldozer/benchmark-operator /tmp/benchmark-operator \
29-
&& git clone -b v1.2.2-kata-ci https://github.com/RobertKrawitz/OpenShift4-tools /tmp/OpenShift4-tools \
33+
&& git clone -b ${BENCHMARK_OPERATOR_VERSION} https://github.com/cloud-bulldozer/benchmark-operator /tmp/benchmark-operator \
34+
&& git clone -b ${OPENSHIFT4_TOOLS_VERSION} https://github.com/RobertKrawitz/OpenShift4-tools /tmp/OpenShift4-tools \
3035
&& dnf clean all \
3136
&& rm -rf /var/cache/dnf
3237

0 commit comments

Comments
 (0)