-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the webhook to validate the remediationAction field of policies
Currently, when the remediationAction field is unset in both the root policy and configuration policy in its policy template, the violation is generated as an event by the config-policy controller in the managed cluster. This PR addresses the issue by updating the validating webhook so that the violation can be caught on policy creation and updates on the hub. ref: https://issues.redhat.com/browse/ACM-7551 Signed-off-by: Jason Zhang <[email protected]> (cherry picked from commit 5adbb99)
- Loading branch information
1 parent
0ecd13b
commit 135c7fe
Showing
6 changed files
with
242 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ webhooks: | |
- v1 | ||
operations: | ||
- CREATE | ||
- UPDATE | ||
resources: | ||
- policies | ||
sideEffects: None |
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
19 changes: 19 additions & 0 deletions
19
test/resources/case17_policy_webhook/case17_invalid_remediation_policy.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,19 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: Policy | ||
metadata: | ||
name: case17-test-policy-no-remediation | ||
spec: | ||
disabled: false | ||
policy-templates: | ||
- objectDefinition: | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: case17-cfplc1 | ||
spec: | ||
severity: low | ||
namespaceSelector: | ||
exclude: | ||
- kube-* | ||
include: | ||
- default |
20 changes: 20 additions & 0 deletions
20
test/resources/case17_policy_webhook/case17_valid_remediation_policy_cfplc.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,20 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: Policy | ||
metadata: | ||
name: case17-test-policy-cfplc-remediation | ||
spec: | ||
disabled: false | ||
policy-templates: | ||
- objectDefinition: | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: case17-cfplc2 | ||
spec: | ||
remediationAction: inform | ||
severity: low | ||
namespaceSelector: | ||
exclude: | ||
- kube-* | ||
include: | ||
- default |
20 changes: 20 additions & 0 deletions
20
test/resources/case17_policy_webhook/case17_valid_remediation_policy_root.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,20 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: Policy | ||
metadata: | ||
name: case17-test-policy-root-remediation | ||
spec: | ||
remediationAction: inform | ||
disabled: false | ||
policy-templates: | ||
- objectDefinition: | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: case17-cfplc3 | ||
spec: | ||
severity: low | ||
namespaceSelector: | ||
exclude: | ||
- kube-* | ||
include: | ||
- default |