Skip to content

Commit a21c18f

Browse files
fix(harbor): drive bucket-secret.yaml from values, gate HR on BucketInfo
Two bugs caused the harbor E2E to fail (CI #25049445125): 1. cozy-harbor's bucket-secret.yaml called `index $existingSecret.data "BucketInfo"` unconditionally. During first-time install the COSI BucketAccess controller may create the credentials Secret as a placeholder before populating it, so `.data` is nil and the chart render crashes with `index of untyped nil`. 2. The downstream `<release>-system` HelmRelease starts reconciling immediately, in parallel with bucket provisioning, hitting bug #1 on every retry within the test's 5-minute window. The previous shape relied on `lookup` to read the Secret at render time. helm-controller's upgrade trigger is digest-based over composed values + chart artifact, so a `lookup` returning new data on a later reconcile is not enough on its own to force an upgrade — the rendered output may diverge but the digest does not. Switch to a values-driven shape: - `bucket-secret.yaml` now reads `.Values.bucket.bucketInfo` (a JSON string) and uses `dig` for safe access; if the value is empty or the expected nested fields are missing, no `*-registry-s3` Secret is rendered. - The `<release>-system` HR sources `BucketInfo` via `valuesFrom` with `targetPath: bucket.bucketInfo`. With the default `optional: false`, helm-controller will refuse to compose values until the key exists, which both gates initial reconciliation on the BucketAccess Secret being populated and forces a config-digest change (and thus a helm upgrade) when its contents change. - `bucket.secretName` is removed from the system chart's values and from the apps chart's `values:` block; the only consumer (the `lookup` call) is gone. Verified four scenarios via `helm template` against the system chart: unset bucketInfo, empty string, empty JSON object `{}`, and a fully-populated BucketInfo — only the last renders the registry-s3 Secret; the others render nothing without erroring. Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent adc430e commit a21c18f

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

‎packages/apps/harbor/templates/harbor.yaml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ spec:
6565
name: {{ .Release.Name }}-credentials
6666
valuesKey: redis-password
6767
targetPath: harbor.redis.external.password
68+
# BucketInfo is populated by the COSI BucketAccess controller. Sourcing it via
69+
# valuesFrom both gates reconciliation on the Secret being ready and forces a
70+
# config-digest change (and thus a helm upgrade) when its contents change —
71+
# Flux HR dependsOn cannot reference COSI resources directly.
72+
- kind: Secret
73+
name: {{ .Release.Name }}-registry-bucket
74+
valuesKey: BucketInfo
75+
targetPath: bucket.bucketInfo
6876
values:
69-
bucket:
70-
secretName: {{ .Release.Name }}-registry-bucket
7177
db:
7278
replicas: {{ .Values.database.replicas }}
7379
size: {{ .Values.database.size }}
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
{{- if .Values.bucket.secretName }}
2-
{{- $existingSecret := lookup "v1" "Secret" .Release.Namespace .Values.bucket.secretName }}
3-
{{- $bucketInfo := fromJson (b64dec (index $existingSecret.data "BucketInfo")) }}
4-
{{- $accessKeyID := index $bucketInfo.spec.secretS3 "accessKeyID" }}
5-
{{- $accessSecretKey := index $bucketInfo.spec.secretS3 "accessSecretKey" }}
6-
{{- $endpoint := index $bucketInfo.spec.secretS3 "endpoint" }}
7-
{{- $bucketName := $bucketInfo.spec.bucketName }}
1+
{{- if .Values.bucket.bucketInfo }}
2+
{{- $bucketInfo := fromJson .Values.bucket.bucketInfo }}
3+
{{- $secretS3 := dig "spec" "secretS3" dict $bucketInfo }}
4+
{{- if $secretS3 }}
5+
{{- $accessKeyID := index $secretS3 "accessKeyID" }}
6+
{{- $accessSecretKey := index $secretS3 "accessSecretKey" }}
7+
{{- $endpoint := index $secretS3 "endpoint" }}
8+
{{- $bucketName := dig "spec" "bucketName" "" $bucketInfo }}
89
---
910
apiVersion: v1
1011
kind: Secret
@@ -18,3 +19,4 @@ stringData:
1819
REGISTRY_STORAGE_S3_BUCKET: {{ $bucketName | quote }}
1920
REGISTRY_STORAGE_S3_REGION: "us-east-1"
2021
{{- end }}
22+
{{- end }}

‎packages/system/harbor/values.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
harbor: {}
22
bucket:
3-
secretName: ""
3+
bucketInfo: ""
44
db:
55
replicas: 2
66
size: 5Gi

0 commit comments

Comments
 (0)