mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
fix: Wait for Subscription resources to reach AtLatestKnown (#21425)
If using the sync waves annotations currently ArgoCD does not wait for the Subscription to be fully installed. Root cause is that the first update that includes `.status` doesn't include the information that the installation is still pending. To be able to wait for the operator to be installed, the `.status.state` can be checked. Signed-off-by: Thomas Müller <thomas@chaschperli.ch>
This commit is contained in:
@@ -14,13 +14,30 @@ if obj.status ~= nil then
|
||||
numDegraded = numDegraded + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Available states: undef/nil, UpgradeAvailable, UpgradePending, UpgradeFailed, AtLatestKnown
|
||||
-- Source: https://github.com/openshift/operator-framework-olm/blob/5e2c73b7663d0122c9dc3e59ea39e515a31e2719/staging/api/pkg/operators/v1alpha1/subscription_types.go#L17-L23
|
||||
if obj.status.state == nil then
|
||||
numPending = numPending + 1
|
||||
msg = msg .. ".status.state not yet known\n"
|
||||
elseif obj.status.state == "" or obj.status.state == "UpgradeAvailable" or obj.status.state == "UpgradePending" then
|
||||
numPending = numPending + 1
|
||||
msg = msg .. ".status.state is '" .. obj.status.state .. "'\n"
|
||||
elseif obj.status.state == "UpgradeFailed" then
|
||||
numDegraded = numDegraded + 1
|
||||
msg = msg .. ".status.state is '" .. obj.status.state .. "'\n"
|
||||
else
|
||||
-- Last possiblity of .status.state: AtLatestKnown
|
||||
msg = msg .. ".status.state is '" .. obj.status.state .. "'\n"
|
||||
end
|
||||
|
||||
if numDegraded == 0 and numPending == 0 then
|
||||
health_status.status = "Healthy"
|
||||
health_status.message = msg
|
||||
return health_status
|
||||
elseif numPending > 0 and numDegraded == 0 then
|
||||
health_status.status = "Progressing"
|
||||
health_status.message = "An install plan for a subscription is pending installation"
|
||||
health_status.message = msg
|
||||
return health_status
|
||||
else
|
||||
health_status.status = "Degraded"
|
||||
@@ -31,4 +48,4 @@ if obj.status ~= nil then
|
||||
end
|
||||
health_status.status = "Progressing"
|
||||
health_status.message = "An install plan for a subscription is pending installation"
|
||||
return health_status
|
||||
return health_status
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: "An install plan for a subscription is pending installation"
|
||||
message: "1: CatalogSourcesUnhealthy | False\n.status.state not yet known\n"
|
||||
inputPath: testdata/first_update_with_status.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: "1: CatalogSourcesUnhealthy | False\n2: InstallPlanPending | True\n.status.state is 'UpgradePending'\n"
|
||||
inputPath: testdata/install_plan_pending.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "1: CatalogSourcesUnhealthy | True\n"
|
||||
message: "1: CatalogSourcesUnhealthy | True\n.status.state not yet known\n"
|
||||
inputPath: testdata/catalog_sources_unhealthy.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: "1: CatalogSourcesUnhealthy | False\n2: InstallPlanMissing | True\n"
|
||||
message: "1: CatalogSourcesUnhealthy | False\n2: InstallPlanMissing | True\n.status.state is 'AtLatestKnown'\n"
|
||||
inputPath: testdata/install_plan_missing.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "1: CatalogSourcesUnhealthy | False\n2: InstallPlanFailed | True\n"
|
||||
message: "1: CatalogSourcesUnhealthy | False\n2: InstallPlanFailed | True\n.status.state is 'AtLatestKnown'\n"
|
||||
inputPath: testdata/install_plan_failed.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "1: CatalogSourcesUnhealthy | True\n2: ResolutionFailed | True\n"
|
||||
message: "1: CatalogSourcesUnhealthy | True\n2: ResolutionFailed | True\n.status.state not yet known\n"
|
||||
inputPath: testdata/resolution_failed.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: "1: CatalogSourcesUnhealthy | False\n"
|
||||
inputPath: testdata/healthy.yaml
|
||||
message: "1: CatalogSourcesUnhealthy | False\n.status.state is 'AtLatestKnown'\n"
|
||||
inputPath: testdata/healthy.yaml
|
||||
|
||||
54
resource_customizations/operators.coreos.com/Subscription/testdata/first_update_with_status.yaml
vendored
Normal file
54
resource_customizations/operators.coreos.com/Subscription/testdata/first_update_with_status.yaml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
apiVersion: operators.coreos.com/v1alpha1
|
||||
kind: Subscription
|
||||
metadata:
|
||||
creationTimestamp: "2024-10-14T08:37:15Z"
|
||||
generation: 1
|
||||
labels:
|
||||
operators.coreos.com/cincinnati-operator.openshift-update-service: ""
|
||||
name: update-service-subscription
|
||||
namespace: openshift-update-service
|
||||
resourceVersion: "1728269681"
|
||||
uid: ce5194f6-b60e-4206-bcb9-019ed845797e
|
||||
spec:
|
||||
channel: v1
|
||||
installPlanApproval: Manual
|
||||
name: cincinnati-operator
|
||||
source: redhat-operators
|
||||
sourceNamespace: openshift-marketplace
|
||||
status:
|
||||
catalogHealth:
|
||||
- catalogSourceRef:
|
||||
apiVersion: operators.coreos.com/v1alpha1
|
||||
kind: CatalogSource
|
||||
name: certified-operators
|
||||
namespace: openshift-marketplace
|
||||
resourceVersion: "1728260000"
|
||||
uid: 5ccf7092-9df5-4898-b5c5-0368937614f1
|
||||
healthy: true
|
||||
lastUpdated: "2024-10-14T08:37:15Z"
|
||||
- catalogSourceRef:
|
||||
apiVersion: operators.coreos.com/v1alpha1
|
||||
kind: CatalogSource
|
||||
name: redhat-marketplace
|
||||
namespace: openshift-marketplace
|
||||
resourceVersion: "1728258210"
|
||||
uid: 83648c37-b64e-440c-86c1-8c8146fc59f0
|
||||
healthy: true
|
||||
lastUpdated: "2024-10-14T08:37:15Z"
|
||||
- catalogSourceRef:
|
||||
apiVersion: operators.coreos.com/v1alpha1
|
||||
kind: CatalogSource
|
||||
name: redhat-operators
|
||||
namespace: openshift-marketplace
|
||||
resourceVersion: "1728263805"
|
||||
uid: 99cc0db9-35c4-4f2a-87ab-7e37f0b05cc0
|
||||
healthy: true
|
||||
lastUpdated: "2024-10-14T08:37:15Z"
|
||||
conditions:
|
||||
- lastTransitionTime: "2024-10-14T08:37:15Z"
|
||||
message: all available catalogsources are healthy
|
||||
reason: CatalogSourcesAdded
|
||||
status: "False"
|
||||
type: CatalogSourcesUnhealthy
|
||||
lastUpdated: "2024-10-14T08:37:15Z"
|
||||
Reference in New Issue
Block a user