-
Notifications
You must be signed in to change notification settings - Fork 33
[rhoai-2.25] docs(lockfile): align custom flavor on Dockerfile.konflux.<flavor> #2705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rhoai-2.25
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ SCRIPTS_PATH="scripts/lockfile-generators" | |
| COMPONENT_DIR="" | ||
| VARIANT="odh" # "odh" = upstream (CentOS Stream), "rhds" = downstream (RHEL) | ||
| FLAVOR="cpu" # selects which pylock/requirements files to use (cpu, cuda, rocm) | ||
| FLAVOR_EXPLICIT=false | ||
| ACTIVATION_KEY="" | ||
| ORG="" | ||
|
|
||
|
|
@@ -60,7 +61,8 @@ Options: | |
| --component-dir DIR Component directory (required) | ||
| e.g. codeserver/ubi9-python-3.12 | ||
| --rhds Use downstream (RHDS) lockfiles instead of upstream (ODH) | ||
| --flavor NAME Lock file flavor (default: cpu) | ||
| --flavor NAME Lock file flavor (default: cpu, or first available | ||
| Dockerfile.konflux.{cpu,cuda,rocm} when cpu is absent) | ||
| --activation-key KEY Red Hat activation key for RHEL RPMs (optional) | ||
| --org ORG Red Hat organization ID for RHEL RPMs (optional) | ||
| -h, --help Show this help | ||
|
|
@@ -76,6 +78,33 @@ error_exit() { | |
| exit 1 | ||
| } | ||
|
|
||
| # resolve_konflux_flavor PROJECT_DIR FLAVOR FLAVOR_EXPLICIT | ||
| resolve_konflux_flavor() { | ||
| local project_dir="$1" | ||
| local flavor="$2" | ||
| local explicit="$3" | ||
| local candidate | ||
|
|
||
| if [[ -f "${project_dir}/Dockerfile.konflux.${flavor}" ]]; then | ||
| echo "$flavor" | ||
| return 0 | ||
| fi | ||
|
|
||
| if [[ "$explicit" == true ]]; then | ||
| error_exit "Konflux Dockerfile not found: ${project_dir}/Dockerfile.konflux.${flavor}" | ||
| fi | ||
|
|
||
| for candidate in cpu cuda rocm; do | ||
| if [[ -f "${project_dir}/Dockerfile.konflux.${candidate}" ]]; then | ||
| echo "Note: auto-selected flavor '${candidate}' (no Dockerfile.konflux.${flavor})" >&2 | ||
| echo "$candidate" | ||
| return 0 | ||
| fi | ||
| done | ||
|
|
||
| error_exit "No Dockerfile.konflux.{cpu,cuda,rocm} found in ${project_dir}; use --flavor" | ||
| } | ||
|
|
||
| # find_tekton_yaml COMPONENT_DIR VARIANT | ||
| # Finds .tekton/*pull-request*.yaml files that build this component for the | ||
| # given variant by matching the pipeline's dockerfile param. Requires yq; | ||
|
|
@@ -119,7 +148,7 @@ while [[ $# -gt 0 ]]; do | |
| COMPONENT_DIR="$2"; shift 2 ;; | ||
| --rhds) VARIANT="rhds"; shift ;; | ||
| --flavor) [[ $# -ge 2 ]] || error_exit "--flavor requires a value" | ||
| FLAVOR="$2"; shift 2 ;; | ||
| FLAVOR="$2"; FLAVOR_EXPLICIT=true; shift 2 ;; | ||
| --activation-key) [[ $# -ge 2 ]] || error_exit "--activation-key requires a value" | ||
| ACTIVATION_KEY="$2"; shift 2 ;; | ||
| --org) [[ $# -ge 2 ]] || error_exit "--org requires a value" | ||
|
|
@@ -131,6 +160,7 @@ done | |
|
|
||
| [[ -z "$COMPONENT_DIR" ]] && error_exit "--component-dir is required." | ||
| [[ -d "$COMPONENT_DIR" ]] || error_exit "Component directory not found: $COMPONENT_DIR" | ||
| FLAVOR="$(resolve_konflux_flavor "$COMPONENT_DIR" "$FLAVOR" "$FLAVOR_EXPLICIT")" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -u
rg -n -C 10 \
'find_tekton_yaml|TEKTON_YAML|FLAVOR=|dockerfile_path' \
scripts/lockfile-generators/prefetch-all.sh
printf '\nFlavor-specific Tekton references:\n'
rg -n -C 4 \
'Dockerfile\.konflux\.(cpu|cuda|rocm)|Dockerfile\.konflux\.' \
.tekton scripts --glob '*.yaml' --glob '*.sh'Repository: red-hat-data-services/notebooks Length of output: 50387 🏁 Script executed: #!/usr/bin/env bash
set -u
printf '%s\n' 'Relevant implementation:'
sed -n '74,140p;292,325p' scripts/lockfile-generators/prefetch-all.sh
printf '\n%s\n' 'NPM downloader input handling:'
fd -i 'download-npm' scripts/lockfile-generators
sed -n '1,220p' scripts/lockfile-generators/download-npm.sh
printf '\n%s\n' 'Pull-request Tekton files grouped by component directory and flavor:'
python3 - <<'PY'
from pathlib import Path
import re
from collections import defaultdict
groups = defaultdict(list)
for path in sorted(Path(".tekton").glob("*pull-request*.yaml")):
text = path.read_text()
m = re.search(
r'(?m)^\s*value:\s*["\']?([^"\']*?/Dockerfile\.konflux\.([A-Za-z0-9_-]+))["\']?\s*$',
text,
)
if not m:
continue
dockerfile, flavor = m.groups()
component = dockerfile.rsplit("/Dockerfile.konflux.", 1)[0]
groups[component].append((flavor, str(path), dockerfile))
for component, entries in groups.items():
flavors = sorted({flavor for flavor, _, _ in entries})
if len(flavors) > 1:
print(component)
for flavor, path, dockerfile in entries:
print(f" {flavor}: {path} -> {dockerfile}")
PYRepository: red-hat-data-services/notebooks Length of output: 12884 🏁 Script executed: #!/usr/bin/env bash
set -u
python3 - <<'PY'
from pathlib import Path
from collections import defaultdict
import re
# Extract the scalar immediately following a dockerfile parameter.
records = []
for path in sorted(Path(".tekton").glob("*pull-request*.yaml")):
lines = path.read_text().splitlines()
for i, line in enumerate(lines):
if re.match(r"^\s*-\s*name:\s*dockerfile\s*$", line):
for value_line in lines[i + 1:i + 5]:
m = re.match(r"^\s*value:\s*[\"']?([^\"']+?)[\"']?\s*$", value_line)
if m:
dockerfile = m.group(1).strip()
if "/Dockerfile.konflux." in dockerfile:
component, flavor = dockerfile.rsplit("/Dockerfile.konflux.", 1)
records.append((component, flavor, str(path), dockerfile))
break
break
by_component = defaultdict(list)
for record in records:
by_component[record[0]].append(record)
print(f"pull-request YAMLs with Konflux dockerfiles: {len(records)}")
print(f"components represented: {len(by_component)}")
print("\nComponents with multiple matching pull-request YAMLs:")
collision_count = 0
for component in sorted(by_component):
entries = by_component[component]
if len(entries) > 1:
collision_count += 1
print(component)
for _, flavor, path, dockerfile in entries:
print(f" {flavor}\t{path}\t{dockerfile}")
if collision_count == 0:
print(" none")
print("\nFlavor distribution:")
flavors = defaultdict(int)
for _, flavor, _, _ in records:
flavors[flavor] += 1
for flavor, count in sorted(flavors.items()):
print(f" {flavor}: {count}")
print("\nFirst matching YAML for each component under lexical glob order:")
for component in sorted(by_component):
first = by_component[component][0]
print(f"{component}\t{first[1]}\t{first[2]}")
PY
printf '\nDockerfiles with multiple Konflux flavors:\n'
find . -type f -name 'Dockerfile.konflux.*' -print \
| sed 's#^\./##' \
| awk '
{
path=$0
sub(/\/Dockerfile\.konflux\.[^/]+$/, "", path)
count[path]++
files[path]=files[path] "\n " $0
}
END {
for (path in count)
if (count[path] > 1)
print path ":" files[path]
}
' | sortRepository: red-hat-data-services/notebooks Length of output: 2887 🏁 Script executed: #!/usr/bin/env bash
set -u
for f in \
.tekton/odh-workbench-jupyter-minimal-cpu-py312-pull-request.yaml \
.tekton/odh-workbench-jupyter-minimal-cuda-py312-pull-request.yaml \
.tekton/odh-workbench-jupyter-minimal-rocm-py312-pull-request.yaml
do
printf '\n--- %s ---\n' "$f"
rg -n -C 3 'name: dockerfile|name: prefetch-input|type: npm|path:|build-args-file' "$f"
done
printf '\nFlavor-specific Dockerfiles and package-lock locations:\n'
for f in \
jupyter/minimal/ubi9-python-3.12/Dockerfile.konflux.cpu \
jupyter/minimal/ubi9-python-3.12/Dockerfile.konflux.cuda \
jupyter/minimal/ubi9-python-3.12/Dockerfile.konflux.rocm
do
printf '\n--- %s ---\n' "$f"
rg -n '^(FROM|COPY|ADD)|package-lock|package\.json|prefetch-input|npm' "$f" || true
done
printf '\nNPM prefetch paths by YAML (textual YAML extraction):\n'
python3 - <<'PY'
from pathlib import Path
import re
files = [
Path(".tekton/odh-workbench-jupyter-minimal-cpu-py312-pull-request.yaml"),
Path(".tekton/odh-workbench-jupyter-minimal-cuda-py312-pull-request.yaml"),
Path(".tekton/odh-workbench-jupyter-minimal-rocm-py312-pull-request.yaml"),
]
for path in files:
lines = path.read_text().splitlines()
dockerfile = next(
(re.match(r"\s*value:\s*[\"']?([^\"']+?)[\"']?\s*$", lines[i + 1]).group(1)
for i, line in enumerate(lines[:-1])
if re.match(r"\s*-\s*name:\s*dockerfile\s*$", line)
and re.match(r"\s*value:", lines[i + 1])),
"<not found>",
)
npm_paths = []
in_npm = False
for i, line in enumerate(lines):
if re.match(r"\s*-\s*type:\s*npm\s*$", line):
in_npm = True
elif in_npm:
m = re.match(r"\s*path:\s*(\S+)\s*$", line)
if m:
npm_paths.append(m.group(1))
in_npm = False
elif re.match(r"\s*-\s*type:", line):
in_npm = False
print(path)
print(f" dockerfile: {dockerfile}")
print(f" npm paths: {npm_paths}")
PYRepository: red-hat-data-services/notebooks Length of output: 3249 Make
🤖 Prompt for AI Agents |
||
|
|
||
| # CLI args take priority; fall back to env vars so GHA can pass secrets | ||
| # without exposing them on the command line. GitHub Actions masks env var | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Document explicit flavor validation in
prefetch-all.sh --help.The resolver rejects an explicitly supplied flavor when
Dockerfile.konflux.<flavor>is missing. The help text only documents the default fallback. Add the exact-match requirement so users can predict validation behavior.Proposed help-text update
--flavor NAME Lock file flavor (default: cpu, or first available Dockerfile.konflux.{cpu,cuda,rocm} when cpu is absent) + Must match Dockerfile.konflux.<flavor> in the + component directory.📝 Committable suggestion
🤖 Prompt for AI Agents