Skip to content

Commit cb1891c

Browse files
committed
fix(cozy-lib): pull the Secret cleanup image through cozy-lib.image
The helper wrote docker.io/clastix/kubectl into the Job directly, so a cluster that sets images-registry still pulled it from Docker Hub. The Renovate manager that refreshes this digest in the other cleanup hooks only reads templates/hooks, so this pin would have aged while the others were bumped. Assisted-by: LLM Signed-off-by: Yan Bondarenko <[email protected]>
1 parent 57d2e75 commit cb1891c

8 files changed

Lines changed: 36 additions & 7 deletions

File tree

‎.github/renovate.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
{
2929
"customType": "regex",
3030
"description": "Track and keep fresh the clastix/kubectl image digest-pinned in the post-delete cleanup hooks. The ref is assembled at render time by the cozy-lib.image helper (routed through cozy-lib.images-registry so mirrored / air-gapped installs resolve it), so it is neither a Dockerfile nor a go.mod dependency and the built-in managers cannot see it. The helm-values manager is disabled repo-wide (see enabledManagers above), so without this regex manager the digest — a supply-chain pin — would silently age.",
31-
"managerFilePatterns": ["/^packages/.+/templates/hooks/.+\\.yaml$/"],
31+
"managerFilePatterns": ["/^packages/.+/templates/hooks/.+\\.yaml$/", "/^packages/library/cozy-lib/templates/_hooks\\.tpl$/"],
3232
"matchStrings": ["clastix/kubectl:(?<currentValue>v[0-9]+\\.[0-9]+(?:\\.[0-9]+)?)@(?<currentDigest>sha256:[a-f0-9]+)"],
3333
"datasourceTemplate": "docker",
3434
"depNameTemplate": "docker.io/clastix/kubectl"

‎packages/apps/nats/tests/cleanup_secrets_test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ tests:
4646
pattern: 'exit 1'
4747
- matchRegex:
4848
path: spec.template.spec.containers[0].image
49-
pattern: '^docker\.io/clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
49+
pattern: '^clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
5050

5151
- it: still renders when the release no longer issues certificates, since an earlier revision may have
5252
templates:

‎packages/apps/opensearch/tests/cleanup_secrets_test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ tests:
4747
pattern: 'exit 1'
4848
- matchRegex:
4949
path: spec.template.spec.containers[0].image
50-
pattern: '^docker\.io/clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
50+
pattern: '^clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
5151

5252
- it: still renders when the release no longer issues certificates, since an earlier revision may have
5353
templates:

‎packages/apps/qdrant/tests/cleanup_secrets_test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ tests:
4646
pattern: 'exit 1'
4747
- matchRegex:
4848
path: spec.template.spec.containers[0].image
49-
pattern: '^docker\.io/clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
49+
pattern: '^clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
5050

5151
- it: still renders when the release no longer issues certificates, since an earlier revision may have
5252
templates:

‎packages/apps/rabbitmq/tests/cleanup_secrets_test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ tests:
4646
pattern: 'exit 1'
4747
- matchRegex:
4848
path: spec.template.spec.containers[0].image
49-
pattern: '^docker\.io/clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
49+
pattern: '^clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
5050

5151
- it: still renders when the release no longer issues certificates, since an earlier revision may have
5252
templates:

‎packages/apps/redis/tests/cleanup_secrets_test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ tests:
4646
pattern: 'exit 1'
4747
- matchRegex:
4848
path: spec.template.spec.containers[0].image
49-
pattern: '^docker\.io/clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
49+
pattern: '^clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$'
5050

5151
- it: still renders when the release no longer issues certificates, since an earlier revision may have
5252
templates:

‎packages/library/cozy-lib/templates/_hooks.tpl‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ spec:
160160
type: RuntimeDefault
161161
containers:
162162
- name: cleanup
163-
image: docker.io/clastix/kubectl:v1.32@sha256:b9ef7d8dbe65bcc81a46c09b8dc7543103055021c4f43287bf59e92a8f4fe05c
163+
# Routed through cozy-lib.image like the other cleanup hooks, so the
164+
# cluster images-registry applies. The clastix/kubectl Renovate
165+
# manager in .github/renovate.json matches this file by its path.
166+
image: {{ include "cozy-lib.image" (list "clastix/kubectl:v1.32@sha256:b9ef7d8dbe65bcc81a46c09b8dc7543103055021c4f43287bf59e92a8f4fe05c" $root) }}
164167
securityContext:
165168
allowPrivilegeEscalation: false
166169
readOnlyRootFilesystem: true

‎packages/tests/cozy-lib-tests/tests/hooks_deletesecrets_test.yaml‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,32 @@ tests:
134134
path: subjects[0].name
135135
value: redis-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-secrets-c
136136

137+
- it: pulls the pinned kubectl image from its own registry when the cluster sets none
138+
set:
139+
deleteSecrets:
140+
secrets: [myapp-tls]
141+
documentSelector:
142+
path: kind
143+
value: Job
144+
asserts:
145+
- matchRegex:
146+
path: spec.template.spec.containers[0].image
147+
pattern: ^clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$
148+
149+
- it: pulls the pinned kubectl image through the cluster images registry
150+
set:
151+
_cluster:
152+
images-registry: registry.example.com
153+
deleteSecrets:
154+
secrets: [myapp-tls]
155+
documentSelector:
156+
path: kind
157+
value: Job
158+
asserts:
159+
- matchRegex:
160+
path: spec.template.spec.containers[0].image
161+
pattern: ^registry\.example\.com/clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$
162+
137163
- it: refuses an empty Secret list, whose RBAC rule would have no resourceNames
138164
set:
139165
deleteSecrets:

0 commit comments

Comments
 (0)