Skip to content
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

fix: update role label failed when switchover #8661

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions controllers/k8score/event_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ var _ = Describe("Event Controller", func() {
By("send role changed event with afterLastTS later than pod last role changes event timestamp annotation should be update successfully")
role = "follower"
sndValidEvent := createRoleChangedEvent(podName, role, uid)
sndValidEvent.EventTime = metav1.NewMicroTime(afterLastTS)
sndValidEvent.LastTimestamp = metav1.NewTime(afterLastTS)
Expect(testCtx.CreateObj(ctx, sndValidEvent)).Should(Succeed())
Eventually(func() string {
event := &corev1.Event{}
Expand All @@ -242,7 +242,7 @@ var _ = Describe("Event Controller", func() {
g.Expect(p).ShouldNot(BeNil())
g.Expect(p.Labels).ShouldNot(BeNil())
g.Expect(p.Labels[constant.RoleLabelKey]).Should(Equal(role))
g.Expect(p.Annotations[constant.LastRoleSnapshotVersionAnnotationKey]).Should(Equal(strconv.FormatInt(sndValidEvent.EventTime.UnixMicro(), 10)))
g.Expect(p.Annotations[constant.LastRoleSnapshotVersionAnnotationKey]).Should(Equal(strconv.FormatInt(sndValidEvent.LastTimestamp.UnixMicro(), 10)))
})).Should(Succeed())
})
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/instanceset/pod_role_event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func parseGlobalRoleSnapshot(role string, event *corev1.Event) *common.GlobalRol
if err := json.Unmarshal([]byte(role), snapshot); err == nil {
return snapshot
}
snapshot.Version = strconv.FormatInt(event.EventTime.UnixMicro(), 10)
snapshot.Version = strconv.FormatInt(event.LastTimestamp.UnixMicro(), 10)
pair := common.PodRoleNamePair{
PodName: event.InvolvedObject.Name,
RoleName: role,
Expand Down
Loading