Add a check which ensures that selector and labels match
Make sure that the VirtualMachineTemplate lables are matched by the
VirtualMachineReplicaSet. If they don't match, log it and ignore the
ReplicaSet.
@@ -163,6 +163,11 @@ func (c *VMReplicaSet) execute(key string) error {
return nil
}
+ if !selector.Matches(labels.Set(rs.Spec.Template.ObjectMeta.Labels)) {
+ log.Error().Reason(err).Msg("Selector does not match template labels, will not re-enqueue.")
+ return nil
+ }
+
needsSync := c.expectations.SatisfiedExpectations(key)
// get all potentially interesting VMs from the cache
