@@ -76,7 +76,7 @@ var _ = Describe("Test selective policy enforcement", Ordered, func() {
76
76
)
77
77
Expect (err ).ToNot (HaveOccurred ())
78
78
79
- By ("Verifying no replicated policy created on cluster ns managed3" )
79
+ By ("Verifying no replicated policy created on cluster ns managed3 because of the subfilter " )
80
80
Eventually (func () interface {} {
81
81
replicatedPlc := utils .GetWithTimeout (
82
82
clientHubDynamic , gvrPolicy , testNamespace + "." + case16PolicyName ,
@@ -192,5 +192,60 @@ var _ = Describe("Test selective policy enforcement", Ordered, func() {
192
192
return rootPlc .Object ["status" ].(map [string ]interface {})["placement" ]
193
193
}, defaultTimeoutSeconds , 1 ).Should (utils .SemanticEqual (expectedPlacementStatus ))
194
194
})
195
+
196
+ It ("should propagate to all clusters when the subfilter is removed" , func () {
197
+ By ("Putting all clusters in the case16-test-policy-plr-enforce decisions" )
198
+ plr := utils .GetWithTimeout (
199
+ clientHubDynamic , gvrPlacementRule , case16PolicyName + "-plr-enforce" ,
200
+ testNamespace , true , defaultTimeoutSeconds ,
201
+ )
202
+ plr .Object ["status" ] = utils .GeneratePlrStatus ("managed1" , "managed2" , "managed3" )
203
+ _ , err := clientHubDynamic .Resource (gvrPlacementRule ).Namespace (testNamespace ).UpdateStatus (
204
+ context .TODO (), plr , metav1.UpdateOptions {},
205
+ )
206
+ Expect (err ).ToNot (HaveOccurred ())
207
+
208
+ By ("Verifying that the policy on managed3 is still not created" )
209
+ Consistently (func () interface {} {
210
+ return utils .GetWithTimeout (
211
+ clientHubDynamic , gvrPolicy , testNamespace + "." + case16PolicyName ,
212
+ "managed3" , false , defaultTimeoutSeconds ,
213
+ )
214
+ }, "5s" , 1 ).Should (BeNil ())
215
+
216
+ By ("Removing the subfilter from the binding" )
217
+ utils .Kubectl ("patch" , "placementbinding" , "case16-test-policy-pb-enforce" , "-n" , testNamespace ,
218
+ "--type=json" , `-p=[{"op":"remove","path":"/subFilter"}]` )
219
+
220
+ By ("Verifying the policies exist and are enforcing on all 3 clusters" )
221
+ for _ , clustername := range []string {"managed1" , "managed2" , "managed3" } {
222
+ Eventually (func () interface {} {
223
+ replicatedPlc := utils .GetWithTimeout (
224
+ clientHubDynamic , gvrPolicy , testNamespace + "." + case16PolicyName ,
225
+ clustername , true , defaultTimeoutSeconds ,
226
+ )
227
+
228
+ return replicatedPlc .Object ["spec" ].(map [string ]interface {})["remediationAction" ]
229
+ }, defaultTimeoutSeconds , 1 ).Should (Equal ("enforce" ))
230
+ }
231
+ })
232
+
233
+ It ("should change remediationAction when the bindingOverrides are removed" , func () {
234
+ By ("Removing the overrides from the binding" )
235
+ utils .Kubectl ("patch" , "placementbinding" , "case16-test-policy-pb-enforce" , "-n" , testNamespace ,
236
+ "--type=json" , `-p=[{"op":"remove","path":"/bindingOverrides"}]` )
237
+
238
+ By ("Verifying the policies are informing on all 3 clusters" )
239
+ for _ , clustername := range []string {"managed1" , "managed2" , "managed3" } {
240
+ Eventually (func () interface {} {
241
+ replicatedPlc := utils .GetWithTimeout (
242
+ clientHubDynamic , gvrPolicy , testNamespace + "." + case16PolicyName ,
243
+ clustername , true , defaultTimeoutSeconds ,
244
+ )
245
+
246
+ return replicatedPlc .Object ["spec" ].(map [string ]interface {})["remediationAction" ]
247
+ }, defaultTimeoutSeconds , 1 ).Should (Equal ("inform" ))
248
+ }
249
+ })
195
250
})
196
251
})
0 commit comments