From 7c0f032deff536ae64db7dd3a730a59bc0affb81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonasz=20=C5=81asut-Balcerzak?= Date: Thu, 4 Dec 2025 18:07:14 +0100 Subject: [PATCH] fix(health): update crossplane healthchecks (#25386) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonasz Lasut-Balcerzak Signed-off-by: Jonasz Łasut-Balcerzak --- .../_.crossplane.io/_/health.lua | 3 +- .../_.crossplane.io/_/health_test.yaml | 6 ++- .../_/testdata/provider_degraded.yaml | 33 +++++++++++++ .../_.upbound.io/_/health.lua | 3 +- .../_.upbound.io/_/health_test.yaml | 4 ++ ...managedresource_failedupdate_degraded.yaml | 46 +++++++++++++++++++ 6 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 resource_customizations/_.crossplane.io/_/testdata/provider_degraded.yaml create mode 100644 resource_customizations/_.upbound.io/_/testdata/managedresource_failedupdate_degraded.yaml diff --git a/resource_customizations/_.crossplane.io/_/health.lua b/resource_customizations/_.crossplane.io/_/health.lua index 38f6636302..be323f0a36 100644 --- a/resource_customizations/_.crossplane.io/_/health.lua +++ b/resource_customizations/_.crossplane.io/_/health.lua @@ -1,4 +1,4 @@ --- Health check copied from here: https://github.com/crossplane/docs/blob/709889c5dbe6e5a2ea3dffd66fe276cf465b47b5/content/master/guides/crossplane-with-argo-cd.md +-- Health check copied from here: https://github.com/crossplane/docs/blob/9fe744889fc150ca71e5298d90b4133f79ea20f2/content/master/guides/crossplane-with-argo-cd.md health_status = { status = "Progressing", @@ -59,7 +59,6 @@ for i, condition in ipairs(obj.status.conditions) do if condition.status == "True" then health_status.status = "Healthy" health_status.message = "Resource is up-to-date." - return health_status end end end diff --git a/resource_customizations/_.crossplane.io/_/health_test.yaml b/resource_customizations/_.crossplane.io/_/health_test.yaml index 32282d0432..86ac4ac012 100644 --- a/resource_customizations/_.crossplane.io/_/health_test.yaml +++ b/resource_customizations/_.crossplane.io/_/health_test.yaml @@ -6,4 +6,8 @@ tests: - healthStatus: status: Healthy message: "Resource is up-to-date." - inputPath: testdata/configurationrevision_healthy.yaml \ No newline at end of file + inputPath: testdata/configurationrevision_healthy.yaml + - healthStatus: + status: Degraded + message: "ActivePackageRevision UnhealthyPackageRevision" + inputPath: testdata/provider_degraded.yaml \ No newline at end of file diff --git a/resource_customizations/_.crossplane.io/_/testdata/provider_degraded.yaml b/resource_customizations/_.crossplane.io/_/testdata/provider_degraded.yaml new file mode 100644 index 0000000000..4a35f9b192 --- /dev/null +++ b/resource_customizations/_.crossplane.io/_/testdata/provider_degraded.yaml @@ -0,0 +1,33 @@ +apiVersion: pkg.crossplane.io/v1 +kind: Provider +metadata: + name: upbound-provider-family-azure +spec: + ignoreCrossplaneConstraints: false + package: xpkg.upbound.io/upbound/provider-family-azure:v2.2.0 + packagePullPolicy: IfNotPresent + revisionActivationPolicy: Automatic + revisionHistoryLimit: 1 + runtimeConfigRef: + apiVersion: pkg.crossplane.io/v1beta1 + kind: DeploymentRuntimeConfig + name: default + skipDependencyResolution: false +status: + conditions: + - lastTransitionTime: "2025-11-22T08:47:52Z" + message: 'Package runtime health is "False" with message: post establish xppkgruntime + hook failed for package: provider package deployment is unavailable with message: + Deployment does not have minimum availability.' + observedGeneration: 3 + reason: UnhealthyPackageRevision + status: "False" + type: Healthy + - lastTransitionTime: "2025-11-22T08:45:44Z" + observedGeneration: 3 + reason: ActivePackageRevision + status: "True" + type: Installed + currentIdentifier: xpkg.upbound.io/upbound/provider-family-azure:v2.2.0 + currentRevision: upbound-provider-family-azure-04ba5ac3fc37 + resolvedPackage: xpkg.upbound.io/upbound/provider-family-azure:v2.2.0 \ No newline at end of file diff --git a/resource_customizations/_.upbound.io/_/health.lua b/resource_customizations/_.upbound.io/_/health.lua index e875b7476a..643b313746 100644 --- a/resource_customizations/_.upbound.io/_/health.lua +++ b/resource_customizations/_.upbound.io/_/health.lua @@ -1,4 +1,4 @@ --- Health check copied from here: https://github.com/crossplane/docs/blob/709889c5dbe6e5a2ea3dffd66fe276cf465b47b5/content/master/guides/crossplane-with-argo-cd.md +-- Health check copied from here: https://github.com/crossplane/docs/blob/9fe744889fc150ca71e5298d90b4133f79ea20f2/content/master/guides/crossplane-with-argo-cd.md health_status = { status = "Progressing", @@ -56,7 +56,6 @@ for i, condition in ipairs(obj.status.conditions) do if condition.status == "True" then health_status.status = "Healthy" health_status.message = "Resource is up-to-date." - return health_status end end end diff --git a/resource_customizations/_.upbound.io/_/health_test.yaml b/resource_customizations/_.upbound.io/_/health_test.yaml index a11541d263..18838a3383 100644 --- a/resource_customizations/_.upbound.io/_/health_test.yaml +++ b/resource_customizations/_.upbound.io/_/health_test.yaml @@ -3,3 +3,7 @@ tests: status: Healthy message: "Resource is up-to-date." inputPath: testdata/providerconfig_healthy.yaml + - healthStatus: + status: Degraded + message: "update failed: async update failed: refuse to update the external resource because the following update requires replacing it: cannot change the value of the argument \"location\" from \"westeurope\" to \"switzerlandnorth\"" + inputPath: testdata/managedresource_failedupdate_degraded.yaml \ No newline at end of file diff --git a/resource_customizations/_.upbound.io/_/testdata/managedresource_failedupdate_degraded.yaml b/resource_customizations/_.upbound.io/_/testdata/managedresource_failedupdate_degraded.yaml new file mode 100644 index 0000000000..37856ccd2a --- /dev/null +++ b/resource_customizations/_.upbound.io/_/testdata/managedresource_failedupdate_degraded.yaml @@ -0,0 +1,46 @@ +apiVersion: azure.m.upbound.io/v1beta1 +kind: ResourceGroup +metadata: + annotations: + crossplane.io/external-create-pending: '2025-11-22T08:33:27Z' + crossplane.io/external-create-succeeded: '2025-11-22T08:33:27Z' + crossplane.io/external-name: example-resources + name: example-resources +spec: + forProvider: + location: Switzerland North + initProvider: {} + managementPolicies: + - '*' + providerConfigRef: + kind: ClusterProviderConfig + name: default +status: + atProvider: + id: >- + /subscriptions/uuid/resourceGroups/example-resources + location: westeurope + managedBy: '' + conditions: + - lastTransitionTime: '2025-11-22T08:33:40Z' + reason: Available + status: 'True' + type: Ready + - lastTransitionTime: '2025-11-22T08:36:12Z' + message: >- + update failed: async update failed: refuse to update the external + resource because the following update requires replacing it: cannot + change the value of the argument "location" from "westeurope" to + "switzerlandnorth" + observedGeneration: 3 + reason: ReconcileError + status: 'False' + type: Synced + - lastTransitionTime: '2025-11-22T08:36:11Z' + message: >- + async update failed: refuse to update the external resource because the + following update requires replacing it: cannot change the value of the + argument "location" from "westeurope" to "switzerlandnorth" + reason: AsyncUpdateFailure + status: 'False' + type: LastAsyncOperation \ No newline at end of file