Skip to content

Commit

Permalink
fix: update role label failed when switchover (#8661)
Browse files Browse the repository at this point in the history
  • Loading branch information
kizuna-lek authored Dec 17, 2024
1 parent 18721cf commit ed1d303
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit ed1d303

Please sign in to comment.