Skip to content

Commit f548dae

Browse files
Add DeprecationAvaliable to ComplianceConfigAction
Add DeprecationAvaliable to ComplianceConfigAction Signed-off-by: yiraeChristineKim <[email protected]>
1 parent ed4307f commit f548dae

File tree

5 files changed

+61
-6
lines changed

5 files changed

+61
-6
lines changed

api/v1beta1/operatorpolicy_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ type ComplianceConfig struct {
134134
//
135135
//+kubebuilder:default=Compliant
136136
UpgradesAvailable ComplianceConfigAction `json:"upgradesAvailable,omitempty"`
137+
// DeprecationAvailable specifies how the NoDeprecations condition impacts overall
138+
// policy compliance. The default value is `Compliant`. If any deprecations are detected
139+
// in the package, channel, or bundle with DeprecationAvailable = NonCompliant,
140+
// then the policy compliance will be set to `Compliant`.
141+
//
142+
// +kubebuilder:default=Compliant
143+
DeprecationAvailable ComplianceConfigAction `json:"deprecationAvailable,omitempty"`
137144
}
138145

139146
// OperatorPolicySpec defines the desired state of a particular operator on the cluster.

controllers/operatorpolicy_status.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ func calculateComplianceCondition(policy *policyv1beta1.OperatorPolicy) metav1.C
283283
}
284284

285285
idx, cond = policy.Status.GetCondition(deprecationType)
286-
if !policy.Spec.ComplianceType.IsMustNotHave() {
286+
if !policy.Spec.ComplianceType.IsMustNotHave() &&
287+
policy.Spec.ComplianceConfig.DeprecationAvailable == "Compliant" {
287288
if idx == -1 {
288289
messages = append(messages, "The deprecation status is unknown")
289290
foundNonCompliant = true

deploy/crds/kustomize_operatorpolicy/policy.open-cluster-management.io_operatorpolicies.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ spec:
6868
- Compliant
6969
- NonCompliant
7070
type: string
71+
deprecationAvailable:
72+
default: Compliant
73+
description: |-
74+
DeprecationAvailable specifies how the NoDeprecations condition impacts overall
75+
policy compliance. The default value is `Compliant`. If any deprecations are detected
76+
in the package, channel, or bundle with DeprecationAvailable = NonCompliant,
77+
then the policy compliance will be set to `Compliant`.
78+
enum:
79+
- Compliant
80+
- NonCompliant
81+
type: string
7182
upgradesAvailable:
7283
default: Compliant
7384
description: |-

deploy/crds/policy.open-cluster-management.io_operatorpolicies.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ spec:
7070
- Compliant
7171
- NonCompliant
7272
type: string
73+
deprecationAvailable:
74+
default: Compliant
75+
description: |-
76+
DeprecationAvailable specifies how the NoDeprecations condition impacts overall
77+
policy compliance. The default value is `Compliant`. If any deprecations are detected
78+
in the package, channel, or bundle with DeprecationAvailable = NonCompliant,
79+
then the policy compliance will be set to `Compliant`.
80+
enum:
81+
- Compliant
82+
- NonCompliant
83+
type: string
7384
upgradesAvailable:
7485
default: Compliant
7586
description: |-

test/e2e/case38_install_operator_test.go

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3762,11 +3762,11 @@ var _ = Describe("Testing OperatorPolicy", Ordered, Label("supports-hosted"), fu
37623762

37633763
check(
37643764
allPolName,
3765-
false,
3765+
true,
37663766
[]policyv1.RelatedObject{},
37673767
metav1.Condition{
37683768
Type: "NoDeprecations",
3769-
Status: metav1.ConditionTrue,
3769+
Status: metav1.ConditionFalse,
37703770
Reason: "PackageDeprecated",
37713771
Message: "the requested deprecation-operator Package was deprecated. " +
37723772
"deprecation-operator is end of life. Please don't use this package.",
@@ -3783,11 +3783,11 @@ var _ = Describe("Testing OperatorPolicy", Ordered, Label("supports-hosted"), fu
37833783

37843784
check(
37853785
channelPolName,
3786-
false,
3786+
true,
37873787
[]policyv1.RelatedObject{},
37883788
metav1.Condition{
37893789
Type: "NoDeprecations",
3790-
Status: metav1.ConditionTrue,
3790+
Status: metav1.ConditionFalse,
37913791
Reason: "ChannelDeprecated",
37923792
Message: "the requested alpha Channel was deprecated. " +
37933793
"channel alpha is no longer supported. Please switch to channel 'stable'",
@@ -3802,13 +3802,38 @@ var _ = Describe("Testing OperatorPolicy", Ordered, Label("supports-hosted"), fu
38023802
createObjWithParent(parentPolicyYAML, parentPolicyName,
38033803
bundlePolYAML, testNamespace, gvrPolicy, gvrOperatorPolicy)
38043804

3805+
check(
3806+
bundlePolName,
3807+
true,
3808+
[]policyv1.RelatedObject{},
3809+
metav1.Condition{
3810+
Type: "NoDeprecations",
3811+
Status: metav1.ConditionFalse,
3812+
Reason: "BundleDeprecated",
3813+
Message: "the requested dep-bundle-operator.v0.0.1 Bundle was deprecated. " +
3814+
"dep-bundle-operator.v0.0.1 bundle is no longer supported.",
3815+
},
3816+
"",
3817+
)
3818+
})
3819+
It("Should have deprecation message is displayed and policy compliance is Compliant "+
3820+
"when bundle is deprecated and deprecationAvaliable is set to NonCompliant",
3821+
func(_ SpecContext) {
3822+
createObjWithParent(parentPolicyYAML, parentPolicyName,
3823+
bundlePolYAML, testNamespace, gvrPolicy, gvrOperatorPolicy)
3824+
3825+
utils.Kubectl("patch", "operatorpolicy", bundlePolName, "-n", testNamespace, "--type=json", "-p",
3826+
`[{"op": "replace",
3827+
"path": "/spec/complianceConfig/deprecationAvaliable",
3828+
"value": "NonCompliant"}]`)
3829+
38053830
check(
38063831
bundlePolName,
38073832
false,
38083833
[]policyv1.RelatedObject{},
38093834
metav1.Condition{
38103835
Type: "NoDeprecations",
3811-
Status: metav1.ConditionTrue,
3836+
Status: metav1.ConditionFalse,
38123837
Reason: "BundleDeprecated",
38133838
Message: "the requested dep-bundle-operator.v0.0.1 Bundle was deprecated. " +
38143839
"dep-bundle-operator.v0.0.1 bundle is no longer supported.",

0 commit comments

Comments
 (0)