-
Notifications
You must be signed in to change notification settings - Fork 501
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
Use patch for sts in periodicity controller #2332
Conversation
if err != nil { | ||
errs = append(errs, err) | ||
continue | ||
} |
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.
why remove this? there is no need to update statefulsets not owned by tidb clusters.
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.
updated.
"metadata": map[string]interface{}{ | ||
"annotations": sts.Annotations, | ||
}, | ||
}) |
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.
I think using the Patch method is a good idea. It can avoid API conflicts in kube-apiserver.
But the root cause is we should copy before modifying the statefulset if the data in the Lister are touched.
if err != nil { | ||
errs = append(errs, err) | ||
continue | ||
} | ||
if sts.Annotations == nil { | ||
sts.Annotations = map[string]string{} | ||
} | ||
sts.Annotations[label.AnnStsLastSyncTimestamp] = time.Now().Format(time.RFC3339) |
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.
create a new annotations map, otherwise, cache in informer will be modified.
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.
updated.
if sts.Annotations == nil { | ||
sts.Annotations = map[string]string{} | ||
} |
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.
if sts.Annotations == nil { | |
sts.Annotations = map[string]string{} | |
} |
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.
updated.
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.
LGTM
cherry pick to release-1.1 in PR #2335 |
What problem does this PR solve?
periodicity controller use update to inject timestamp annotation for the tidbcluster sts. However, the data in the Lister might be out-of-date which causing the tikv/tidb sts scale-in again after they get scale-out by auto-scaler.
In this request, we use patch to merge the target sts annotation instead of updating.
Related changes
Does this PR introduce a user-facing change?: