fix:group was updated continuously in member cluster
Signed-off-by: Roland.Ma <rolandma@yunify.com>
This commit is contained in:
@@ -146,29 +146,30 @@ func (c *Controller) reconcile(key string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if group.Labels != nil {
|
if group.Labels != nil {
|
||||||
// Set OwnerReferences when the group has a parent.
|
// Set OwnerReferences when the group has a parent. And it's owned by kubefed
|
||||||
if parent, ok := group.Labels[iam1alpha2.GroupParent]; ok && !k8sutil.IsControlledBy(group.OwnerReferences, "Group", parent) {
|
if group.Labels[constants.KubefedManagedLabel] != "true" {
|
||||||
if g == nil {
|
if parent, ok := group.Labels[iam1alpha2.GroupParent]; ok && !k8sutil.IsControlledBy(group.OwnerReferences, "Group", parent) {
|
||||||
g = group.DeepCopy()
|
if g == nil {
|
||||||
}
|
g = group.DeepCopy()
|
||||||
groupParent, err := c.groupLister.Get(parent)
|
|
||||||
if err != nil {
|
|
||||||
if errors.IsNotFound(err) {
|
|
||||||
utilruntime.HandleError(fmt.Errorf("Parent group '%s' no longer exists", key))
|
|
||||||
delete(group.Labels, iam1alpha2.GroupParent)
|
|
||||||
} else {
|
|
||||||
klog.Error(err)
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
} else {
|
groupParent, err := c.groupLister.Get(parent)
|
||||||
if err := controllerutil.SetControllerReference(groupParent, g, scheme.Scheme); err != nil {
|
if err != nil {
|
||||||
klog.Error(err)
|
if errors.IsNotFound(err) {
|
||||||
return err
|
utilruntime.HandleError(fmt.Errorf("Parent group '%s' no longer exists", key))
|
||||||
|
delete(group.Labels, iam1alpha2.GroupParent)
|
||||||
|
} else {
|
||||||
|
klog.Error(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := controllerutil.SetControllerReference(groupParent, g, scheme.Scheme); err != nil {
|
||||||
|
klog.Error(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if g != nil {
|
if g != nil {
|
||||||
if _, err = c.ksClient.IamV1alpha2().Groups().Update(context.Background(), g, metav1.UpdateOptions{}); err != nil {
|
if _, err = c.ksClient.IamV1alpha2().Groups().Update(context.Background(), g, metav1.UpdateOptions{}); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user