-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sync podstatus from leaf to root when root node from ready to notready #770
base: main
Are you sure you want to change the base?
Conversation
7e73738
to
ca3f31b
Compare
f2db91b
to
6428c2e
Compare
a7c3205
to
0467e7f
Compare
5c86aee
to
1a2ede0
Compare
pkg/clustertree/cluster-manager/controllers/pod/rootpodstatus_sync_controller.go
Outdated
Show resolved
Hide resolved
a032fb4
to
21c2c70
Compare
add unit test |
Signed-off-by: gaoyuan <[email protected]>
}, | ||
UpdateFunc: func(updateEvent event.UpdateEvent) bool { | ||
pod1 := updateEvent.ObjectOld.(*corev1.Pod) | ||
pod2 := updateEvent.ObjectNew.(*corev1.Pod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pod1 and pod2 is strange
if !skipFunc(updateEvent.ObjectNew) { | ||
return false | ||
} | ||
return !reflect.DeepEqual(pod1.Status, pod2.Status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skipFunc and reflect.DeepEqual can be written together
return reconcile.Result{}, nil | ||
} | ||
|
||
if !c.GlobalLeafManager.HasNode(rootpod.Spec.NodeName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In one2cluster mode, the nodename of the rootpod is not in the subset cluster
if !skipFunc(updateEvent.ObjectNew) { | ||
return false | ||
} | ||
return !reflect.DeepEqual(pod1.Status, pod2.Status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should only judge the conditions in status, not all the contents of status
return reconcile.Result{RequeueAfter: utils.DefaultRequeueTime}, nil | ||
} | ||
|
||
if !podutils.IsKosmosPod(&rootpod) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same as skipFunc
return reconcile.Result{}, nil | ||
} | ||
|
||
if podutils.IsKosmosPod(leafPod) && !reflect.DeepEqual(rootpod.Status, leafPod.Status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status.condition?
podutils.FitObjectMeta(&rPodCopy.ObjectMeta) | ||
if err := c.RootClient.Status().Update(ctx, rPodCopy); err != nil && !apierrors.IsNotFound(err) { | ||
klog.Errorf("error while updating rootpod status in kubernetes, %s", err) | ||
return reconcile.Result{}, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requeue?
rPodCopy := rootpod.DeepCopy() | ||
rPodCopy.Status = leafPod.Status | ||
podutils.FitObjectMeta(&rPodCopy.ObjectMeta) | ||
if err := c.RootClient.Status().Update(ctx, rPodCopy); err != nil && !apierrors.IsNotFound(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apierrors.IsNotFound is redundant
What type of PR is this?
/kind feature
What does this PR do?
sync podstatus from leaf to root when root node from ready to notready
Which issue(s) does this PR fix?
Fixes #705
Special notes for your reviewer:
Does this PR introduce a user-facing change?