-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report Pending status despite hub template error
A previous change allowing hub-templates for all policy types, and handling any hub-template errors in this controller, caused a change in behavior. Before that change, when a policy both had a hub-template error *and* an unsatisfied dependency, the policy would be marked as Pending. The change made the hub-template error have priority. This commit gives the Pending status priority, and adds a test for that specific behavior. It also handles ConfigurationPolicies particularly carefully: setting `PruneObjectBehavior` to `None` when the template will be deleted specifically because of a hub-template error. Refs: - https://issues.redhat.com/browse/ACM-11530 Signed-off-by: Justin Kulikauskas <[email protected]>
- Loading branch information
1 parent
6125983
commit d780b0e
Showing
6 changed files
with
256 additions
and
80 deletions.
There are no files selected for viewing
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
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
34 changes: 34 additions & 0 deletions
34
test/resources/case10_template_sync_error_test/error-hubtemplate-notyet.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,34 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: Policy | ||
metadata: | ||
name: case10-bad-hubtemplate-notyet | ||
labels: | ||
policy.open-cluster-management.io/cluster-name: managed | ||
policy.open-cluster-management.io/cluster-namespace: managed | ||
policy.open-cluster-management.io/root-policy: case10-bad-hubtemplate | ||
spec: | ||
remediationAction: inform | ||
disabled: false | ||
policy-templates: | ||
- objectDefinition: | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: case10-bad-hubtemplate-notyet | ||
# annotations: | ||
# policy.open-cluster-management.io/hub-templates-error: "must be aboveground" | ||
spec: | ||
pruneObjectBehavior: DeleteAll | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-pod-e2e | ||
namespace: default | ||
annotations: | ||
policy.test/location: 'I come from {{hub the land down under hub}}' | ||
spec: | ||
containers: | ||
- name: nginx |
39 changes: 39 additions & 0 deletions
39
test/resources/case10_template_sync_error_test/error-hubtemplate-pending.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,39 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: Policy | ||
metadata: | ||
name: case10-bad-hubtemplate-pending | ||
labels: | ||
policy.open-cluster-management.io/cluster-name: managed | ||
policy.open-cluster-management.io/cluster-namespace: managed | ||
policy.open-cluster-management.io/root-policy: case10-bad-hubtemplate | ||
spec: | ||
remediationAction: inform | ||
disabled: false | ||
dependencies: | ||
- apiVersion: policy.open-cluster-management.io/v1 | ||
kind: Policy | ||
name: australia | ||
namespace: default | ||
compliance: Compliant | ||
policy-templates: | ||
- objectDefinition: | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: case10-bad-hubtemplate-pending | ||
annotations: | ||
policy.open-cluster-management.io/hub-templates-error: "must be aboveground" | ||
spec: | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-pod-e2e | ||
namespace: default | ||
annotations: | ||
policy.test/location: 'I come from {{hub the land down under hub}}' | ||
spec: | ||
containers: | ||
- name: nginx |
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
30 changes: 0 additions & 30 deletions
30
test/resources/case10_template_sync_error_test/mock-crd.yaml
This file was deleted.
Oops, something went wrong.