Skip to content
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

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 and obj.status.status == nil then
hs.status = "Healthy"
hs.message = "No clusters match this policy"
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ tests:
status: Healthy
message: All templates are compliant
inputPath: testdata/healthy_replicated.yaml
- healthStatus:
status: Progressing
message: Waiting for the status to be reported
inputPath: testdata/progressing_no_status.yaml
- healthStatus:
status: Healthy
message: No clusters match this policy
inputPath: testdata/healthy_with_placement_empty_compliant.yaml
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
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
Loading