@@ -115,19 +115,26 @@ not_valid_pdb_max_unavailable(pdb) {
115115
116116# Check one podDisruptionBudget and pod(controller), returns true if it does not match
117117mismatched_selector (pdb, obj) = res {
118- r1 := match_labels (pdb, obj)
119- r2 := match_expressions_exists (pdb, obj)
120- r3 := match_expressions_does_not_exist (pdb, obj)
121- r4 := any (match_expressions_in (pdb, obj))
122- r5 := any (match_expressions_not_in (pdb, obj))
118+ r1 := matchLabelsMissingKeys (pdb, obj)
119+ r2 := any (matchLabelsValues (pdb, obj))
120+ r3 := match_expressions_exists (pdb, obj)
121+ r4 := match_expressions_does_not_exist (pdb, obj)
122+ r5 := any (match_expressions_in (pdb, obj))
123+ r6 := any (match_expressions_not_in (pdb, obj))
123124 # Return true if any part of the podDisruptionBudget and pod(controller) does not match
124- res := any ({r1, r2, r3, r4, r5})
125+ res := any ({r1, r2, r3, r4, r5, r6 })
125126}
126127
127- match_labels (pdb, obj) = res {
128- pdb_match_labels := { [label, value] | some label; value := pdb.spec.selector.matchLabels[label] }
129- obj_match_labels := { [label, value] | some label; value := obj.spec.selector.matchLabels[label] }
130- res := count (pdb_match_labels - obj_match_labels) != 0
128+ matchLabelsMissingKeys (pdb, obj) = res {
129+ res3 := {key | pdb.spec.selector.matchLabels[key]}
130+ res4 := {key | get_labels (obj)[key]}
131+ res := count (res3 - res4) != 0
132+ }
133+
134+ matchLabelsValues (pdb, obj) = res {
135+ res := [x |
136+ get_labels (obj)[key1] != pdb.spec.selector.matchLabels[key3];
137+ x := key1 == key3]
131138}
132139
133140match_expressions_exists (pdb, obj) = res {
0 commit comments