From a0a6eb09fa8d0fd7b14416f0f40f3e867358a166 Mon Sep 17 00:00:00 2001 From: --global Date: Sun, 2 Apr 2023 19:10:00 +0200 Subject: [PATCH 1/3] checking if References would fix race condition --- component/vshn_postgres.jsonnet | 12 ++++++++++++ .../appcat/21_composition_vshn_postgres.yaml | 14 ++++++++++++++ .../21_composition_vshn_postgresrestore.yaml | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/component/vshn_postgres.jsonnet b/component/vshn_postgres.jsonnet index c2b6fc6ec..98f3f56dc 100644 --- a/component/vshn_postgres.jsonnet +++ b/component/vshn_postgres.jsonnet @@ -310,6 +310,17 @@ local sgCluster = { base: comp.KubeObject('stackgres.io/v1', 'SGCluster') + { spec+: { + references+: [ + { + dependsOn+: { + apiVersion: 'v1', + kind: 'namespace', + metadata: { + name: "" #patched + } + }, + }, + ], forProvider+: { manifest+: { metadata: {}, @@ -357,6 +368,7 @@ local sgCluster = { }, patches: [ comp.ToCompositeFieldPath('status.conditions', 'status.pgclusterConditions'), + comp.FromCompositeFieldPathWithTransformPrefix('metadata.labels[crossplane.io/composite]', 'spec.references[0].dependsOn.name', 'vshn-postgresql'), comp.FromCompositeFieldPathWithTransformSuffix('metadata.labels[crossplane.io/composite]', 'metadata.name', 'cluster'), comp.FromCompositeFieldPathWithTransformPrefix('metadata.labels[crossplane.io/composite]', 'spec.forProvider.manifest.metadata.namespace', 'vshn-postgresql'), comp.FromCompositeFieldPath('metadata.labels[crossplane.io/composite]', 'spec.forProvider.manifest.metadata.name'), diff --git a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml index f3c9b1713..af3985cca 100644 --- a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml +++ b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml @@ -421,10 +421,24 @@ spec: sgInstanceProfile: '' providerConfigRef: name: kubernetes + references: + - dependsOn: + apiVersion: v1 + kind: namespace + metadata: + name: '' patches: - fromFieldPath: status.conditions toFieldPath: status.pgclusterConditions type: ToCompositeFieldPath + - fromFieldPath: metadata.labels[crossplane.io/composite] + toFieldPath: spec.references[0].dependsOn.name + transforms: + - string: + fmt: vshn-postgresql-%s + type: Format + type: string + type: FromCompositeFieldPath - fromFieldPath: metadata.labels[crossplane.io/composite] toFieldPath: metadata.name transforms: diff --git a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml index e24cd21ec..552279c1b 100644 --- a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml +++ b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml @@ -502,6 +502,11 @@ spec: providerConfigRef: name: kubernetes references: + - dependsOn: + apiVersion: v1 + kind: namespace + metadata: + name: '' - dependsOn: apiVersion: stackgres.io/v1 kind: SGBackup @@ -509,6 +514,14 @@ spec: - fromFieldPath: status.conditions toFieldPath: status.pgclusterConditions type: ToCompositeFieldPath + - fromFieldPath: metadata.labels[crossplane.io/composite] + toFieldPath: spec.references[0].dependsOn.name + transforms: + - string: + fmt: vshn-postgresql-%s + type: Format + type: string + type: FromCompositeFieldPath - fromFieldPath: metadata.labels[crossplane.io/composite] toFieldPath: metadata.name transforms: From 8be401796289f7d495dda051783caf7337b13846 Mon Sep 17 00:00:00 2001 From: --global Date: Tue, 4 Apr 2023 10:23:47 +0200 Subject: [PATCH 2/3] defaulting organization to avoid race condition --- component/vshn_postgres.jsonnet | 1 + .../golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml | 2 ++ .../vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml | 2 ++ 3 files changed, 5 insertions(+) diff --git a/component/vshn_postgres.jsonnet b/component/vshn_postgres.jsonnet index 98f3f56dc..11afa5688 100644 --- a/component/vshn_postgres.jsonnet +++ b/component/vshn_postgres.jsonnet @@ -89,6 +89,7 @@ local namespace = comp.KubeObject('v1', 'Namespace') + [serviceNameLabelKey]: 'postgresql-standalone', [serviceNamespaceLabelKey]: '', 'appuio.io/no-rbac-creation': 'true', + 'appuio.io/organization': 'vshn', }, }, }, diff --git a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml index af3985cca..309259bb4 100644 --- a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml +++ b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml @@ -34,6 +34,7 @@ spec: appcat.vshn.io/claim-namespace: '' appcat.vshn.io/servicename: postgresql-standalone appuio.io/no-rbac-creation: 'true' + appuio.io/organization: vshn name: '' managementPolicy: Observe providerConfigRef: @@ -67,6 +68,7 @@ spec: appcat.vshn.io/claim-namespace: '' appcat.vshn.io/servicename: postgresql-standalone appuio.io/no-rbac-creation: 'true' + appuio.io/organization: vshn name: '' providerConfigRef: name: kubernetes diff --git a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml index 552279c1b..00ebc0dd9 100644 --- a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml +++ b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml @@ -34,6 +34,7 @@ spec: appcat.vshn.io/claim-namespace: '' appcat.vshn.io/servicename: postgresql-standalone appuio.io/no-rbac-creation: 'true' + appuio.io/organization: vshn name: '' managementPolicy: Observe providerConfigRef: @@ -67,6 +68,7 @@ spec: appcat.vshn.io/claim-namespace: '' appcat.vshn.io/servicename: postgresql-standalone appuio.io/no-rbac-creation: 'true' + appuio.io/organization: vshn name: '' providerConfigRef: name: kubernetes From b12db430dff06d8c22872cc6a3e5cc7ca4aafc49 Mon Sep 17 00:00:00 2001 From: --global Date: Tue, 4 Apr 2023 11:36:46 +0200 Subject: [PATCH 3/3] removing dependsOn --- component/vshn_postgres.jsonnet | 12 ------------ .../appcat/21_composition_vshn_postgres.yaml | 14 -------------- .../21_composition_vshn_postgresrestore.yaml | 13 ------------- 3 files changed, 39 deletions(-) diff --git a/component/vshn_postgres.jsonnet b/component/vshn_postgres.jsonnet index 11afa5688..27ccad589 100644 --- a/component/vshn_postgres.jsonnet +++ b/component/vshn_postgres.jsonnet @@ -311,17 +311,6 @@ local sgCluster = { base: comp.KubeObject('stackgres.io/v1', 'SGCluster') + { spec+: { - references+: [ - { - dependsOn+: { - apiVersion: 'v1', - kind: 'namespace', - metadata: { - name: "" #patched - } - }, - }, - ], forProvider+: { manifest+: { metadata: {}, @@ -369,7 +358,6 @@ local sgCluster = { }, patches: [ comp.ToCompositeFieldPath('status.conditions', 'status.pgclusterConditions'), - comp.FromCompositeFieldPathWithTransformPrefix('metadata.labels[crossplane.io/composite]', 'spec.references[0].dependsOn.name', 'vshn-postgresql'), comp.FromCompositeFieldPathWithTransformSuffix('metadata.labels[crossplane.io/composite]', 'metadata.name', 'cluster'), comp.FromCompositeFieldPathWithTransformPrefix('metadata.labels[crossplane.io/composite]', 'spec.forProvider.manifest.metadata.namespace', 'vshn-postgresql'), comp.FromCompositeFieldPath('metadata.labels[crossplane.io/composite]', 'spec.forProvider.manifest.metadata.name'), diff --git a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml index 309259bb4..85b34de9d 100644 --- a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml +++ b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml @@ -423,24 +423,10 @@ spec: sgInstanceProfile: '' providerConfigRef: name: kubernetes - references: - - dependsOn: - apiVersion: v1 - kind: namespace - metadata: - name: '' patches: - fromFieldPath: status.conditions toFieldPath: status.pgclusterConditions type: ToCompositeFieldPath - - fromFieldPath: metadata.labels[crossplane.io/composite] - toFieldPath: spec.references[0].dependsOn.name - transforms: - - string: - fmt: vshn-postgresql-%s - type: Format - type: string - type: FromCompositeFieldPath - fromFieldPath: metadata.labels[crossplane.io/composite] toFieldPath: metadata.name transforms: diff --git a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml index 00ebc0dd9..ee34687db 100644 --- a/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml +++ b/tests/golden/vshn/appcat/appcat/21_composition_vshn_postgresrestore.yaml @@ -504,11 +504,6 @@ spec: providerConfigRef: name: kubernetes references: - - dependsOn: - apiVersion: v1 - kind: namespace - metadata: - name: '' - dependsOn: apiVersion: stackgres.io/v1 kind: SGBackup @@ -516,14 +511,6 @@ spec: - fromFieldPath: status.conditions toFieldPath: status.pgclusterConditions type: ToCompositeFieldPath - - fromFieldPath: metadata.labels[crossplane.io/composite] - toFieldPath: spec.references[0].dependsOn.name - transforms: - - string: - fmt: vshn-postgresql-%s - type: Format - type: string - type: FromCompositeFieldPath - fromFieldPath: metadata.labels[crossplane.io/composite] toFieldPath: metadata.name transforms: