Skip to content

Commit dc79732

Browse files
Remove capi labels for tinkerbell wf, jobs (#5133)
1 parent 8ad6dbc commit dc79732

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

projects/tinkerbell/tinkerbell-crds/scripts/generate-crds-chart.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ cp "${PROJECT_DIR}/chart/Chart.yaml" "${OUTPUT_DIR}/"
3939
cp "${PROJECT_DIR}/chart/values.yaml" "${OUTPUT_DIR}/"
4040
cp "${PROJECT_DIR}/chart/.helmignore" "${OUTPUT_DIR}/"
4141

42+
# Transient CRDs that should NOT have clusterctl labels (to prevent move during cluster migration).
43+
# The move label causes clusterctl to discover and move these resources during cluster move.
44+
# When moved, they arrive with empty status (clusterctl only moves spec) causing controllers
45+
# to re-process them
46+
SKIP_CLUSTERCTL_LABELS="tinkerbell.org_workflows.yaml bmc.tinkerbell.org_jobs.yaml bmc.tinkerbell.org_tasks.yaml"
47+
4248
# Copy all CRDs from mono-repo
4349
for crd_file in "${REPO_ROOT}"/crd/bases/*.yaml; do
4450
filename=$(basename "$crd_file")
@@ -51,9 +57,11 @@ for crd_file in "${REPO_ROOT}"/crd/bases/*.yaml; do
5157
# This prevents Helm from deleting CRDs on uninstall
5258
yq -i '.metadata.annotations["helm.sh/resource-policy"] = "keep"' "${OUTPUT_DIR}/templates/${filename}"
5359

54-
# Add clusterctl labels for CAPI move operations
55-
yq -i '.metadata.labels["clusterctl.cluster.x-k8s.io"] = ""' "${OUTPUT_DIR}/templates/${filename}"
56-
yq -i '.metadata.labels["clusterctl.cluster.x-k8s.io/move"] = ""' "${OUTPUT_DIR}/templates/${filename}"
60+
# Add clusterctl labels (skip for transient CRDs)
61+
if [[ ! " ${SKIP_CLUSTERCTL_LABELS} " =~ " ${filename} " ]]; then
62+
yq -i '.metadata.labels["clusterctl.cluster.x-k8s.io"] = ""' "${OUTPUT_DIR}/templates/${filename}"
63+
yq -i '.metadata.labels["clusterctl.cluster.x-k8s.io/move"] = ""' "${OUTPUT_DIR}/templates/${filename}"
64+
fi
5765
done
5866

5967
echo "Generated tinkerbell-crds chart with $(ls -1 "${OUTPUT_DIR}/templates/" | wc -l | tr -d ' ') CRDs"

projects/tinkerbell/tinkerbell-crds/scripts/verify.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ fi
3737

3838
# Verify all CRDs have required annotations
3939
echo "Verifying CRDs have required annotations..."
40+
41+
# CRDs that should NOT have clusterctl labels (to prevent move during cluster migration)
42+
SKIP_CLUSTERCTL_LABELS="tinkerbell.org_workflows.yaml bmc.tinkerbell.org_jobs.yaml bmc.tinkerbell.org_tasks.yaml"
43+
4044
for crd_file in "${HELM_DIRECTORY}"/templates/*.yaml; do
4145
filename=$(basename "$crd_file")
4246

@@ -46,10 +50,12 @@ for crd_file in "${HELM_DIRECTORY}"/templates/*.yaml; do
4650
exit 1
4751
fi
4852

49-
# Check clusterctl labels
50-
if ! yq -e '.metadata.labels["clusterctl.cluster.x-k8s.io"] == ""' "$crd_file" > /dev/null 2>&1; then
51-
echo "${filename} missing clusterctl.cluster.x-k8s.io label"
52-
exit 1
53+
# Check clusterctl labels (skip for transient CRDs)
54+
if [[ ! " ${SKIP_CLUSTERCTL_LABELS} " =~ " ${filename} " ]]; then
55+
if ! yq -e '.metadata.labels["clusterctl.cluster.x-k8s.io"] == ""' "$crd_file" > /dev/null 2>&1; then
56+
echo "${filename} missing clusterctl.cluster.x-k8s.io label"
57+
exit 1
58+
fi
5359
fi
5460

5561
echo "${filename} has required annotations/labels"

0 commit comments

Comments
 (0)