Skip to content

Commit 0eaa264

Browse files
clcollinsclaude
andcommitted
Improve log clarity for delete-olm-operator dry-run mode
During incident response, SREs ran the delete-olm-operator job without the FORCE=y parameter and incorrectly assumed the job had completed its work when it was only describing what would be deleted. This led to operational confusion and extended incident duration. Changes: - Add prominent dry-run mode banner at script start - Prefix all dry-run messages with [DRY-RUN] - Change "Will delete" to "Would delete" to clarify hypothetical actions - Add final summary banner for both dry-run and execution modes - Include clear instructions to execute with --params FORCE=y These changes make it immediately obvious whether the script is running in dry-run mode or actually executing deletions, preventing operational mistakes during incident response. Related: https://issues.redhat.com/browse/SREP-3321 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Chris Collins <collins.christopher@gmail.com>
1 parent d9265ba commit 0eaa264

1 file changed

Lines changed: 36 additions & 5 deletions

File tree

  • scripts/operators-lifecycle/delete-olm-operator

scripts/operators-lifecycle/delete-olm-operator/script.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@ if [[ "${NAMESPACE}" != openshift-* && "${NAMESPACE}" != redhat-* ]]; then
1717
exit "${ERR_INVALID_NS}"
1818
fi
1919

20-
"$DELETE" || echo "Not going to delete resources"
20+
if ! $DELETE; then
21+
echo "========================================"
22+
echo " DRY-RUN MODE - NO CHANGES "
23+
echo "========================================"
24+
echo "This script is running in DRY-RUN mode."
25+
echo "NO resources will be deleted."
26+
echo ""
27+
echo "To execute deletions, re-run with:"
28+
echo " --params NAMESPACE=${NAMESPACE} \\"
29+
echo " --params FORCE=y"
30+
echo "========================================"
31+
echo ""
32+
fi
2133

2234
SUBSCRIPTION_SAVED=$(oc get subscriptions.operators.coreos.com -n "${NAMESPACE}" -ojson | jq -r 'del(.items[].metadata.annotations."kubectl.kubernetes.io/last-applied-configuration")')
2335
SUBSCRIPTION=$(oc get subscriptions.operators.coreos.com -n "${NAMESPACE}" -o jsonpath='{.items[*].metadata.name}')
@@ -41,12 +53,12 @@ if $DELETE; then
4153
oc delete operatorgroups.operators.coreos.com "${OPERATOR_GROUP}" -n "${NAMESPACE}"
4254
fi
4355
else
44-
echo "Will delete Subscription: ${SUBSCRIPTION}"
45-
echo "Will delete CatalogSource: ${CATALOG_SOURCE}"
46-
echo "Will delete OperatorGroup: ${OPERATOR_GROUP}"
56+
echo "[DRY-RUN] Would delete Subscription: ${SUBSCRIPTION}"
57+
echo "[DRY-RUN] Would delete CatalogSource: ${CATALOG_SOURCE}"
58+
echo "[DRY-RUN] Would delete OperatorGroup: ${OPERATOR_GROUP}"
4759
fi
4860

49-
"${DELETE}" || echo "Will delete CSVs:"
61+
"${DELETE}" || echo "[DRY-RUN] Would delete the following CSVs:"
5062
for csv in $(oc get clusterserviceversions.operators.coreos.com -n "${NAMESPACE}" -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}')
5163
do
5264
if "${DELETE}"; then
@@ -72,3 +84,22 @@ if "${DELETE}"; then
7284
echo "${OPERATOR_GROUP_SAVED}" | oc create -f -
7385
fi
7486
fi
87+
88+
echo ""
89+
if $DELETE; then
90+
echo "========================================"
91+
echo " DELETION COMPLETED SUCCESSFULLY "
92+
echo "========================================"
93+
echo "All OLM resources have been deleted and recreated."
94+
echo "========================================"
95+
else
96+
echo "========================================"
97+
echo " DRY-RUN COMPLETED "
98+
echo "========================================"
99+
echo "No resources were deleted."
100+
echo ""
101+
echo "To execute these deletions, re-run with:"
102+
echo " --params NAMESPACE=${NAMESPACE} \\"
103+
echo " --params FORCE=y"
104+
echo "========================================"
105+
fi

0 commit comments

Comments
 (0)