diff --git a/controllers/k8score/event_controller_test.go b/controllers/k8score/event_controller_test.go index 70ceb23bf17..5a4e90c93bd 100644 --- a/controllers/k8score/event_controller_test.go +++ b/controllers/k8score/event_controller_test.go @@ -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{} @@ -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()) }) }) diff --git a/pkg/controller/instanceset/pod_role_event_handler.go b/pkg/controller/instanceset/pod_role_event_handler.go index 3c3808a2f66..30161ca6179 100644 --- a/pkg/controller/instanceset/pod_role_event_handler.go +++ b/pkg/controller/instanceset/pod_role_event_handler.go @@ -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,