-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip pruning when the CRD is being deleted
In some upgrade cases, the ConfigurationPolicy CRD might be temporarily removed. This usually triggers all of the ConfigurationPolicies to be deleted, which would trigger the pruning behavior. But deleting those resources could cause problems, even though they might immediately be recreated when the upgrade finishes. Even outside of upgrades, deleting the CRD "by accident" should probably not trigger the prune behavior. Now, before pruning anything, the controller checks if the CRD is being deleted. BUG: `DeleteIfCreated` will not work perfectly through an upgrade: if the object was created by the policy *before* the CRD was removed, it won't be pruned by the policy after everything is re-created. But missing a deletion seems like a better behavior than deleting extra things. Refs: - https://issues.redhat.com/browse/ACM-2355 Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
- Loading branch information
1 parent
8695a8d
commit d426227
Showing
4 changed files
with
149 additions
and
2 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
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
23 changes: 23 additions & 0 deletions
23
test/resources/case20_delete_objects/case20_musthave_pod_deleteall.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,23 @@ | ||
apiVersion: policy.open-cluster-management.io/v1 | ||
kind: ConfigurationPolicy | ||
metadata: | ||
name: policy-pod-mhpda | ||
spec: | ||
remediationAction: enforce | ||
namespaceSelector: | ||
exclude: ["kube-*"] | ||
include: ["default"] | ||
pruneObjectBehavior: DeleteAll | ||
object-templates: | ||
- complianceType: musthave | ||
objectDefinition: | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-pod-e2e20-mhpda | ||
spec: | ||
containers: | ||
- image: nginx:1.7.9 | ||
name: nginx | ||
ports: | ||
- containerPort: 80 |