Skip to content

Commit ff3c19a

Browse files
Merge pull request #5299 from openshift-cherrypick-robot/cherry-pick-5296-to-release-4.19
[release-4.19] OCPBUGS-62114: Improve MCN CRD clean-up script
2 parents 9c2ef56 + 2b5b7ce commit ff3c19a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

install/0000_80_machine-config_00_v1alpha1-mcn-cleanup-job.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,18 @@ spec:
4949
echo "Checking for MachineConfigNodes CRD with v1alpha1 version..."
5050
5151
# Check if CRD exists
52-
if ! oc get crd "$CRD_NAME" >/dev/null 2>&1; then
53-
echo "CRD $CRD_NAME does not exist, nothing to clean up"
52+
if ! CRD_CHECK_OUTPUT=$(oc get crd "$CRD_NAME" 2>&1); then
53+
echo "Error checking for CRD $CRD_NAME: $CRD_CHECK_OUTPUT"
54+
echo "Assuming CRD does not exist, nothing to clean up"
5455
exit 0
5556
fi
56-
57+
5758
# Check if CRD has v1alpha1 version
58-
HAS_V1ALPHA1=$(oc get crd "$CRD_NAME" -o jsonpath='{.spec.versions[?(@.name=="v1alpha1")].name}' 2>/dev/null || echo "")
59+
if ! HAS_V1ALPHA1=$(oc get crd "$CRD_NAME" -o jsonpath='{.spec.versions[?(@.name=="v1alpha1")].name}' 2>&1); then
60+
echo "Error checking CRD versions for $CRD_NAME: $HAS_V1ALPHA1"
61+
echo "v1 version likely exists, skipping cleanup"
62+
exit 0
63+
fi
5964
6065
if [ -z "$HAS_V1ALPHA1" ]; then
6166
echo "CRD $CRD_NAME does not have v1alpha1 version, nothing to clean up"
@@ -65,10 +70,11 @@ spec:
6570
echo "Found CRD $CRD_NAME with v1alpha1 version, deleting it..."
6671
6772
# Delete the CRD
68-
if oc delete crd "$CRD_NAME"; then
73+
if DELETE_OUTPUT=$(oc delete crd "$CRD_NAME" 2>&1); then
6974
echo "Successfully deleted CRD $CRD_NAME"
7075
else
7176
echo "Failed to delete CRD $CRD_NAME"
77+
echo "Delete error output: $DELETE_OUTPUT"
7278
exit 1
7379
fi
7480
@@ -88,7 +94,7 @@ spec:
8894
seccompProfile:
8995
type: RuntimeDefault
9096
nodeSelector:
91-
node-role.kubernetes.io/control-plane: ""
97+
node-role.kubernetes.io/master: ""
9298
priorityClassName: "system-cluster-critical"
9399
tolerations:
94100
- effect: NoSchedule

0 commit comments

Comments
 (0)