Skip to content

Commit bcad15e

Browse files
fix(monitoring-agents): let the cleanup hook use its in-cluster credentials
A non-zero --request-timeout lands in the client config kubectl compares against the default to decide whether to load in-cluster credentials, so every call of the hook went to localhost:8080 and was refused. The Job's activeDeadlineSeconds already bounds the run. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <[email protected]>
1 parent 5d0bb38 commit bcad15e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎packages/system/monitoring-agents/templates/vm-cleanup-hook.yaml‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ metadata:
7171
helm.sh/hook-weight: "0"
7272
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
7373
spec:
74-
# Well inside the HelmRelease's 10m uninstall budget, and above the 60s wait
75-
# plus one call per object on either side of it.
74+
# Bounds every kubectl call as well: --request-timeout would make kubectl
75+
# skip the in-cluster credentials (hack/check-hook-request-timeout.bats).
76+
# Well inside the HelmRelease's 10m uninstall budget, and above the 60s
77+
# wait plus one call per object on either side of it.
7678
activeDeadlineSeconds: 180
7779
backoffLimit: 0
7880
ttlSecondsAfterFinished: 600
@@ -126,7 +128,7 @@ spec:
126128
# to keep in step. A kind whose CRD is gone just prints an error.
127129
owned() {
128130
for k in $kinds; do
129-
kubectl get "$k.operator.victoriametrics.com" -A --request-timeout=15s \
131+
kubectl get "$k.operator.victoriametrics.com" -A \
130132
-o jsonpath='{range .items[*]}{.metadata.annotations.meta\.helm\.sh/release-name}{"|"}{.metadata.annotations.meta\.helm\.sh/release-namespace}{"|"}{.metadata.namespace}{"|"}{.metadata.name}{"\n"}{end}' |
131133
while IFS='|' read -r r rns ns n; do
132134
if [ "$r" = "$rel" ] && [ "$rns" = "$relns" ]; then
@@ -143,7 +145,7 @@ spec:
143145
fi
144146
145147
echo "$objs" | while read -r k ns n; do
146-
kubectl -n "$ns" delete "$k" "$n" --wait=false --request-timeout=15s
148+
kubectl -n "$ns" delete "$k" "$n" --wait=false
147149
done
148150
149151
deadline=$(( $(date +%s) + 60 ))
@@ -159,6 +161,6 @@ spec:
159161
echo "finalizers still held after 60s; clearing them by hand"
160162
echo "$objs" | while read -r k ns n; do
161163
kubectl -n "$ns" patch "$k" "$n" --type=merge \
162-
-p '{"metadata":{"finalizers":null}}' --request-timeout=15s
164+
-p '{"metadata":{"finalizers":null}}'
163165
done
164166
exit 0

0 commit comments

Comments
 (0)