Skip to content

Commit 8e41d5c

Browse files
authored
Merge pull request opendatahub-io#570 from jstourac/sync-main
Sync odh/main into rhds/main
2 parents c0fa3b2 + cd5532d commit 8e41d5c

File tree

54 files changed

+12579
-11340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+12579
-11340
lines changed

.github/workflows/build-notebooks-TEMPLATE.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ jobs:
209209
- name: Calculate image name and tag
210210
id: calculated_vars
211211
run: |
212-
SANITIZED_REF_NAME=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9._-]/_/g')
212+
# Need for sanitization explained in https://github.com/opendatahub-io/notebooks/issues/631
213+
# For length, Docker image tags have 128-character limit, and we form them as <inputs.target>-<ref_name>_<sha>
214+
# therefore since sha is 40 characters, and our target names are <40 chars, we should cut ref_name at 40
215+
SANITIZED_REF_NAME=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9._-]/_/g') | cut -c 1-40
213216
IMAGE_TAG="${SANITIZED_REF_NAME}_${{ github.sha }}"
214217
215218
echo "IMAGE_TAG=${IMAGE_TAG}" >> "$GITHUB_OUTPUT"

ci/check-software-versions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import json
1515
import logging
1616
import os
17-
import re
1817
import subprocess
1918
import sys
2019
import uuid
@@ -65,10 +64,9 @@ def load_yaml(filepath):
6564

6665

6766
def extract_variable(reference):
68-
"""Extracts a variable name from a string (e.g.: '$(odh-rstudio-notebook-image-commit-n-1)') using regex."""
67+
"""Extracts a variable name from a string (e.g.: 'odh-rstudio-notebook-image-commit-n-1_PLACEHOLDER') using regex."""
6968

70-
match = re.search(r"\((.*?)\)", reference)
71-
return match.group(1) if match else None
69+
return reference.replace("_PLACEHOLDER", "")
7270

7371

7472
def get_variable_value(variable_name, params_file_path=PARAMS_ENV_PATH):

ci/kustomize.sh

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# https://github.com/red-hat-data-services/rhods-operator/blob/7ccc405135f99c014982d7e297b8949e970dd750/go.mod#L28-L29
1515
# and then to match appropriate kustomize release https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize%2Fv5.0.3
1616
DEFAULT_KUSTOMIZE_VERSION=5.0.3
17+
# The latest kustomize version we want to check with to be sure we're prepared for the future
18+
THE_LATEST_KUSTOMIZE=5.6.0
1719

1820
KUSTOMIZE_VERSION="${KUSTOMIZE_VERSION:-$DEFAULT_KUSTOMIZE_VERSION}"
1921

@@ -27,7 +29,30 @@ function download_kustomize() {
2729
echo "---------------------------------------------------------------------------------"
2830
echo "Download kustomize '${kustomize_version}'"
2931
echo "---------------------------------------------------------------------------------"
30-
wget --output-document="${kustomize_tar}" "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${kustomize_version}/kustomize_v${kustomize_version}_linux_amd64.tar.gz"
32+
33+
# Detect OS
34+
local uname_out
35+
uname_out="$(uname -s)"
36+
case "${uname_out}" in
37+
Linux*) os=linux;;
38+
Darwin*) os=darwin;;
39+
*) echo "Unsupported OS: ${uname_out}" && return 1;;
40+
esac
41+
42+
# Detect architecture
43+
local arch
44+
arch="$(uname -m)"
45+
case "${arch}" in
46+
x86_64) arch=amd64;;
47+
arm64) arch=arm64;;
48+
aarch64) arch=arm64;;
49+
*) echo "Unsupported architecture: ${arch}" && return 1;;
50+
esac
51+
52+
local download_url="https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v${kustomize_version}/kustomize_v${kustomize_version}_${os}_${arch}.tar.gz"
53+
echo "Downloading from: ${download_url}"
54+
55+
wget --output-document="${kustomize_tar}" "${download_url}"
3156
tar -C "${tmp_dir}" -xvf "${kustomize_tar}"
3257
mv "${tmp_dir}/kustomize" "${kustomize_bin}"
3358

@@ -46,22 +71,72 @@ function execute_kustomize() {
4671
echo "Starting to run kustomize '${kustomize_version}' for each kustomization.yaml file except components"
4772
echo "---------------------------------------------------------------------------------------------------"
4873
# We don't want to execute kustomization on the components part as it's not intended to be used that way.
49-
find . -name "kustomization.yaml" | xargs dirname | grep -v "components" | xargs -t -I {} "${kustomize_bin}" build {} >"${kustomize_stdout}" 2>"${kustomize_stderr}"
74+
# This first run is for the actual execution to get the generated output and eventual errors/warnings.
75+
find . -name "kustomization.yaml" | xargs dirname | grep -v "components" | xargs -I {} "${kustomize_bin}" build {} >"${kustomize_stdout}" 2>"${kustomize_stderr}"
76+
# This second run is with verbose output to see eventual errors/warnings together with which command they are present for easier debugging.
77+
find . -name "kustomization.yaml" | xargs dirname | grep -v "components" | xargs --verbose -I {} "${kustomize_bin}" build {} >/dev/null
5078

5179
echo "Let's print the STDERR:"
5280
cat "${kustomize_stderr}"
5381
}
5482

83+
function check_the_results() {
84+
local tmp_dir="${1}"
85+
local kustomize_version_1="${2}"
86+
local kustomize_version_2="${3}"
87+
88+
local kustomize_stdout_1="${tmp_dir}/kustomize-${kustomize_version_1}-stdout.yaml"
89+
local kustomize_stderr_1="${tmp_dir}/kustomize-${kustomize_version_1}-stderr.txt"
90+
local kustomize_stdout_2="${tmp_dir}/kustomize-${kustomize_version_2}-stdout.yaml"
91+
local kustomize_stderr_2="${tmp_dir}/kustomize-${kustomize_version_2}-stderr.txt"
92+
93+
echo "---------------------------------------------------------------------------------"
94+
echo "Checking the generated outputs - should be identical:"
95+
echo " - ${kustomize_stdout_1}"
96+
echo " - ${kustomize_stdout_2}"
97+
echo "---------------------------------------------------------------------------------"
98+
diff -u "${kustomize_stdout_1}" "${kustomize_stdout_2}" || {
99+
echo "Generated files from kustomize differs between kustomize version ${kustomize_version_1} and ${kustomize_version_2}. Please check above!"
100+
return 1
101+
}
102+
103+
echo "---------------------------------------------------------------------------------"
104+
echo "No log in STDERR outputs should be printed:"
105+
echo " - ${kustomize_stderr_1}"
106+
echo " - ${kustomize_stderr_2}"
107+
echo "---------------------------------------------------------------------------------"
108+
if [ -s "${kustomize_stderr_1}" ] || [ -s "${kustomize_stderr_2}" ]; then
109+
echo "There were some logs generated to STDERR during the kustomize build. Please check the log above!"
110+
return 1
111+
fi
112+
}
113+
114+
function run_check() {
115+
local tmp_dir="${1}"
116+
local kustomize_version="${2}"
117+
118+
download_kustomize "${tmp_dir}" "${kustomize_version}" || return 1
119+
execute_kustomize "${tmp_dir}" "${kustomize_version}" || return 1
120+
}
121+
55122
function main() {
123+
local ret_code=0
124+
56125
local tmp_dir
57126
tmp_dir=$(mktemp --directory -t kustomize-XXXXXXXXXX)
58127
echo "Running in the following temporary directory: '${tmp_dir}'"
59128

60-
download_kustomize "${tmp_dir}" "${KUSTOMIZE_VERSION}" || return 1
61-
execute_kustomize "${tmp_dir}" "${KUSTOMIZE_VERSION}" || return 1
129+
run_check "${tmp_dir}" "${KUSTOMIZE_VERSION}" || return 1
130+
run_check "${tmp_dir}" "${THE_LATEST_KUSTOMIZE}" || return 1
131+
132+
# --------------------------------------------------------------------------------------
133+
134+
check_the_results "${tmp_dir}" "${KUSTOMIZE_VERSION}" "${THE_LATEST_KUSTOMIZE}" || return 1
135+
136+
exit "${ret_code}"
62137
}
63138

64139
# allows sourcing the script into interactive session without executing it
65140
if [[ "${0}" == "${BASH_SOURCE[0]}" ]]; then
66-
main $@
141+
main "$@"
67142
fi

ci/package_versions_selftestdata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
openshift.io/imported-from: quay.io/opendatahub/workbench-images
3131
opendatahub.io/workbench-image-recommended: 'true'
3232
opendatahub.io/default-image: "true"
33-
opendatahub.io/notebook-build-commit: $(odh-minimal-notebook-image-commit-n)
33+
opendatahub.io/notebook-build-commit: odh-minimal-notebook-image-commit-n_PLACEHOLDER
3434
from:
3535
kind: DockerImage
3636
name: $(odh-minimal-notebook-image-n)
@@ -53,7 +53,7 @@
5353
openshift.io/imported-from: quay.io/opendatahub/workbench-images
5454
opendatahub.io/workbench-image-recommended: 'false'
5555
opendatahub.io/default-image: "true"
56-
opendatahub.io/notebook-build-commit: $(odh-minimal-notebook-image-commit-n-1)
56+
opendatahub.io/notebook-build-commit: odh-minimal-notebook-image-commit-n-1_PLACEHOLDER
5757
from:
5858
kind: DockerImage
5959
name: $(odh-minimal-notebook-image-n-1)

0 commit comments

Comments
 (0)