-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Policy/policy.open-cluster-management.io stuck in progressing status when no clusters match the policy (#21296) #21297
Open
mbaldessari
wants to merge
1
commit into
argoproj:master
Choose a base branch
from
mbaldessari:fix-policy-check
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+130
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 16 additions & 1 deletion
17
resource_customizations/policy.open-cluster-management.io/Policy/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,9 +1,24 @@ | ||||||
hs = {} | ||||||
if obj.status == nil or obj.status.compliant == nil then | ||||||
if obj.status == nil then | ||||||
hs.status = "Progressing" | ||||||
hs.message = "Waiting for the status to be reported" | ||||||
return hs | ||||||
end | ||||||
|
||||||
-- A policy will not have a compliant field but will have a placement key set if | ||||||
-- it is not being applied to any clusters | ||||||
if obj.status.compliant == nil and #obj.status.placement > 0 then | ||||||
hs.status = "Healthy" | ||||||
hs.message = "No clusters are matching this policy" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: wording
Suggested change
|
||||||
return hs | ||||||
end | ||||||
|
||||||
if obj.status.compliant == nil then | ||||||
hs.status = "Progressing" | ||||||
hs.message = "Waiting for the status to be reported" | ||||||
return hs | ||||||
end | ||||||
|
||||||
if obj.status.compliant == "Compliant" then | ||||||
hs.status = "Healthy" | ||||||
else | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...cy.open-cluster-management.io/Policy/testdata/healthy_with_placement_empty_compliant.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: Policy | ||
metadata: | ||
annotations: | ||
argocd.argoproj.io/compare-options: IgnoreExtraneous | ||
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true | ||
labels: | ||
argocd.argoproj.io/instance: acm | ||
name: acm-hub-ca-policy | ||
namespace: open-cluster-management | ||
spec: | ||
disabled: false | ||
policy-templates: | ||
- objectDefinition: | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: acm-hub-ca-config-policy | ||
spec: | ||
namespaceSelector: | ||
include: | ||
- default | ||
object-templates: | ||
- complianceType: mustonlyhave | ||
objectDefinition: | ||
apiVersion: v1 | ||
data: | ||
hub-kube-root-ca.crt: '{{hub fromConfigMap "" "kube-root-ca.crt" "ca.crt" | ||
| base64enc hub}}' | ||
hub-openshift-service-ca.crt: '{{hub fromConfigMap "" "openshift-service-ca.crt" | ||
"service-ca.crt" | base64enc hub}}' | ||
kind: Secret | ||
metadata: | ||
name: hub-ca | ||
namespace: golang-external-secrets | ||
type: Opaque | ||
- complianceType: mustonlyhave | ||
objectDefinition: | ||
apiVersion: v1 | ||
data: | ||
hub-kube-root-ca.crt: | | ||
{{hub fromConfigMap "" "kube-root-ca.crt" "ca.crt" | autoindent hub}} | ||
hub-openshift-service-ca.crt: | | ||
{{hub fromConfigMap "" "openshift-service-ca.crt" "service-ca.crt" | autoindent hub}} | ||
kind: ConfigMap | ||
metadata: | ||
name: trusted-hub-bundle | ||
namespace: imperative | ||
remediationAction: enforce | ||
severity: medium | ||
remediationAction: enforce | ||
status: | ||
placement: | ||
- placementBinding: acm-hub-ca-policy-placement-binding | ||
placementRule: acm-hub-ca-policy-placement |
51 changes: 51 additions & 0 deletions
51
...stomizations/policy.open-cluster-management.io/Policy/testdata/progressing_no_status.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: Policy | ||
metadata: | ||
annotations: | ||
argocd.argoproj.io/compare-options: IgnoreExtraneous | ||
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true | ||
labels: | ||
argocd.argoproj.io/instance: acm | ||
name: acm-hub-ca-policy | ||
namespace: open-cluster-management | ||
spec: | ||
disabled: false | ||
policy-templates: | ||
- objectDefinition: | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: acm-hub-ca-config-policy | ||
spec: | ||
namespaceSelector: | ||
include: | ||
- default | ||
object-templates: | ||
- complianceType: mustonlyhave | ||
objectDefinition: | ||
apiVersion: v1 | ||
data: | ||
hub-kube-root-ca.crt: '{{hub fromConfigMap "" "kube-root-ca.crt" "ca.crt" | ||
| base64enc hub}}' | ||
hub-openshift-service-ca.crt: '{{hub fromConfigMap "" "openshift-service-ca.crt" | ||
"service-ca.crt" | base64enc hub}}' | ||
kind: Secret | ||
metadata: | ||
name: hub-ca | ||
namespace: golang-external-secrets | ||
type: Opaque | ||
- complianceType: mustonlyhave | ||
objectDefinition: | ||
apiVersion: v1 | ||
data: | ||
hub-kube-root-ca.crt: | | ||
{{hub fromConfigMap "" "kube-root-ca.crt" "ca.crt" | autoindent hub}} | ||
hub-openshift-service-ca.crt: | | ||
{{hub fromConfigMap "" "openshift-service-ca.crt" "service-ca.crt" | autoindent hub}} | ||
kind: ConfigMap | ||
metadata: | ||
name: trusted-hub-bundle | ||
namespace: imperative | ||
remediationAction: enforce | ||
severity: medium | ||
remediationAction: enforce |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An additional conditional is required for the case where clusters were matched but are not yet reporting status.