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

remove some not very useful update events #1486

Merged
merged 4 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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: 0 additions & 4 deletions pkg/controller/backup_schedule_status_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
informers "github.com/pingcap/tidb-operator/pkg/client/informers/externalversions/pingcap/v1alpha1"
listers "github.com/pingcap/tidb-operator/pkg/client/listers/pingcap/v1alpha1"
corev1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
Expand Down Expand Up @@ -82,9 +81,6 @@ func (bss *realBackupScheduleStatusUpdater) UpdateBackupScheduleStatus(

return updateErr
})
if !apiequality.Semantic.DeepEqual(newStatus, oldStatus) {
bss.recordBackupScheduleEvent("update", bs, err)
}
return err
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/controller/backup_status_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ func (bcu *realBackupConditionUpdater) Update(backup *v1alpha1.Backup, condition
}
return nil
})
if isUpdate {
bcu.recordBackupEvent("update", backup, err)
}
return err
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/configmap_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func (cc *realConfigMapControl) UpdateConfigMap(owner runtime.Object, cm *corev1

return updateErr
})
cc.recordConfigMapEvent("update", owner, cm, err)
return updatedCm, err
}

Expand Down
8 changes: 0 additions & 8 deletions pkg/controller/configmap_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ func TestConfigMapControlUpdateConfigMap(t *testing.T) {
updatecm, err := control.UpdateConfigMap(tc, cm)
g.Expect(err).To(Succeed())
g.Expect(updatecm.Data["file"]).To(Equal("test"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestConfigMapControlUpdateConfigMapConflictSuccess(t *testing.T) {
Expand Down Expand Up @@ -113,10 +109,6 @@ func TestConfigMapControlUpdateConfigMapConflictSuccess(t *testing.T) {
updatecm, err := control.UpdateConfigMap(tc, cm)
g.Expect(err).To(Succeed())
g.Expect(updatecm.Data["file"]).To(Equal("test"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestConfigMapControlDeleteConfigMap(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/generic_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ func (c *realGenericControlInterface) CreateOrUpdate(controller, obj runtime.Obj
// 5. check if the copy is actually mutated
if !apiequality.Semantic.DeepEqual(existing, mutated) {
err := c.client.Update(context.TODO(), mutated)
c.RecordControllerEvent("update", controller, mutated, err)
return mutated, err
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/pod_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func (rpc *realPodControl) UpdatePod(tc *v1alpha1.TidbCluster, pod *corev1.Pod)

return updateErr
})
rpc.recordPodEvent("update", tc, podName, err)
return updatePod, err
}

Expand Down Expand Up @@ -185,7 +184,6 @@ func (rpc *realPodControl) UpdateMetaInfo(tc *v1alpha1.TidbCluster, pod *corev1.
return updateErr
})

rpc.recordPodEvent("update", tc, podName, err)
return updatePod, err
}

Expand Down
31 changes: 0 additions & 31 deletions pkg/controller/pod_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ func TestPodControlUpdateMetaInfoSuccess(t *testing.T) {
})
_, err := control.UpdateMetaInfo(tc, pod)
g.Expect(err).To(Succeed())

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestPodControlUpdateMetaInfoGetClusterFailed(t *testing.T) {
Expand Down Expand Up @@ -129,9 +125,6 @@ func TestPodControlUpdateMetaInfoGetClusterFailed(t *testing.T) {
})
_, err := control.UpdateMetaInfo(tc, pod)
g.Expect(err).To(HaveOccurred())

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(0))
}

func TestPodControlUpdateMetaInfoGetMemberFailed(t *testing.T) {
Expand Down Expand Up @@ -172,9 +165,6 @@ func TestPodControlUpdateMetaInfoGetMemberFailed(t *testing.T) {
pod.Labels[label.ComponentLabelKey] = label.PDLabelVal
_, err := control.UpdateMetaInfo(tc, pod)
g.Expect(err).To(HaveOccurred())

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(0))
}

func TestPodControlUpdateMetaInfoGetStoreFailed(t *testing.T) {
Expand Down Expand Up @@ -210,9 +200,6 @@ func TestPodControlUpdateMetaInfoGetStoreFailed(t *testing.T) {
pod.Labels[label.ComponentLabelKey] = label.TiKVLabelVal
_, err := control.UpdateMetaInfo(tc, pod)
g.Expect(err).To(HaveOccurred())

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(0))
}

func TestPodControlUpdateMetaInfoUpdatePodFailed(t *testing.T) {
Expand Down Expand Up @@ -259,10 +246,6 @@ func TestPodControlUpdateMetaInfoUpdatePodFailed(t *testing.T) {
})
_, err := control.UpdateMetaInfo(tc, pod)
g.Expect(err).To(HaveOccurred())

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeWarning))
}

func TestPodControlUpdateMetaInfoConflictSuccess(t *testing.T) {
Expand Down Expand Up @@ -320,15 +303,10 @@ func TestPodControlUpdateMetaInfoConflictSuccess(t *testing.T) {
g.Expect(err).To(Succeed())
g.Expect(updatePod.Labels[label.StoreIDLabelKey]).To(Equal("333"))
g.Expect(updatePod.Labels[label.ClusterIDLabelKey]).To(Equal("222"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestPodControlUpdatePod(t *testing.T) {
g := NewGomegaWithT(t)
recorder := record.NewFakeRecorder(10)
tc := newTidbCluster()
pod := newPod(tc)
pod.Annotations = map[string]string{"a": "b"}
Expand All @@ -343,15 +321,10 @@ func TestPodControlUpdatePod(t *testing.T) {
g.Expect(err).To(Succeed())
g.Expect(updatePod.Annotations["a"]).To(Equal("b"))
g.Expect(updatePod.Labels["a"]).To(Equal("b"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestPodControlUpdatePodConflictSuccess(t *testing.T) {
g := NewGomegaWithT(t)
recorder := record.NewFakeRecorder(10)
tc := newTidbCluster()
pod := newPod(tc)
pod.Annotations = map[string]string{"a": "b"}
Expand All @@ -374,10 +347,6 @@ func TestPodControlUpdatePodConflictSuccess(t *testing.T) {
g.Expect(err).To(Succeed())
g.Expect(updatePod.Annotations["a"]).To(Equal("b"))
g.Expect(updatePod.Labels["a"]).To(Equal("b"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func newFakeClientRecorderAndPDControl() (*fake.Clientset, *pdapi.FakePDControl, corelisters.PodLister, cache.Indexer, *record.FakeRecorder) {
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/pv_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func (rpc *realPVControl) UpdateMetaInfo(tc *v1alpha1.TidbCluster, pv *corev1.Pe
return updateErr
})

rpc.recordPVEvent("update", tc, pvName, err)
return updatePV, err
}

Expand Down
15 changes: 0 additions & 15 deletions pkg/controller/pv_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ func TestPVControlUpdateMetaInfoSuccess(t *testing.T) {
updatePV, err := control.UpdateMetaInfo(tc, pv)
g.Expect(err).To(Succeed())
g.Expect(updatePV.Annotations["a"]).To(Equal("b"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestPVControlUpdateMetaInfoUpdatePVFailed(t *testing.T) {
Expand All @@ -128,10 +124,6 @@ func TestPVControlUpdateMetaInfoUpdatePVFailed(t *testing.T) {
})
_, err := control.UpdateMetaInfo(tc, pv)
g.Expect(err).To(HaveOccurred())

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeWarning))
}

func TestPVControlUpdateMetaInfoGetPVCFailed(t *testing.T) {
Expand All @@ -148,9 +140,6 @@ func TestPVControlUpdateMetaInfoGetPVCFailed(t *testing.T) {
})
_, err := control.UpdateMetaInfo(tc, pv)
g.Expect(err).To(Succeed())

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(0))
}

func TestPVControlUpdateMetaInfoConflictSuccess(t *testing.T) {
Expand Down Expand Up @@ -179,10 +168,6 @@ func TestPVControlUpdateMetaInfoConflictSuccess(t *testing.T) {
updatePV, err := control.UpdateMetaInfo(tc, pv)
g.Expect(err).To(Succeed())
g.Expect(updatePV.Annotations["a"]).To(Equal("b"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func newFakeRecorderAndPVCInformer() (*fake.Clientset, coreinformers.PersistentVolumeClaimInformer, coreinformers.PersistentVolumeInformer, *record.FakeRecorder) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/pvc_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func (rpc *realPVCControl) UpdatePVC(tc *v1alpha1.TidbCluster, pvc *corev1.Persi

return updateErr
})
rpc.recordPVCEvent("update", tc, pvcName, err)
return updatePVC, err
}

Expand Down Expand Up @@ -161,7 +160,6 @@ func (rpc *realPVCControl) UpdateMetaInfo(tc *v1alpha1.TidbCluster, pvc *corev1.

return updateErr
})
rpc.recordPVCEvent("update", tc, pvcName, err)
return updatePVC, err
}

Expand Down
24 changes: 0 additions & 24 deletions pkg/controller/pvc_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ func TestPVCControlUpdateMetaInfoSuccess(t *testing.T) {
updatePVC, err := control.UpdateMetaInfo(tc, pvc, pod)
g.Expect(err).To(Succeed())
g.Expect(updatePVC.Annotations[label.AnnPodNameKey]).To(Equal(pod.GetName()))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestPVCControlUpdateMetaInfoFailed(t *testing.T) {
Expand All @@ -66,10 +62,6 @@ func TestPVCControlUpdateMetaInfoFailed(t *testing.T) {
})
_, err := control.UpdateMetaInfo(tc, pvc, pod)
g.Expect(err).To(HaveOccurred())

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeWarning))
}

func TestPVCControlUpdateMetaInfoConflictSuccess(t *testing.T) {
Expand All @@ -93,10 +85,6 @@ func TestPVCControlUpdateMetaInfoConflictSuccess(t *testing.T) {
updatePVC, err := control.UpdateMetaInfo(tc, pvc, pod)
g.Expect(err).To(Succeed())
g.Expect(updatePVC.Annotations[label.AnnPodNameKey]).To(Equal(pod.GetName()))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestPVCControlUpdatePVCSuccess(t *testing.T) {
Expand All @@ -114,10 +102,6 @@ func TestPVCControlUpdatePVCSuccess(t *testing.T) {
updatePVC, err := control.UpdatePVC(tc, pvc)
g.Expect(err).To(Succeed())
g.Expect(updatePVC.Annotations["a"]).To(Equal("b"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestPVCControlUpdatePVCFailed(t *testing.T) {
Expand All @@ -131,10 +115,6 @@ func TestPVCControlUpdatePVCFailed(t *testing.T) {
})
_, err := control.UpdatePVC(tc, pvc)
g.Expect(err).To(HaveOccurred())

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeWarning))
}

func TestPVCControlUpdatePVCConflictSuccess(t *testing.T) {
Expand All @@ -158,10 +138,6 @@ func TestPVCControlUpdatePVCConflictSuccess(t *testing.T) {
updatePVC, err := control.UpdatePVC(tc, pvc)
g.Expect(err).To(Succeed())
g.Expect(updatePVC.Annotations["a"]).To(Equal("b"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func newFakeClientAndRecorder() (*fake.Clientset, corelisters.PersistentVolumeClaimLister, cache.Indexer, *record.FakeRecorder) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/controller/restore_status_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ func (rcu *realRestoreConditionUpdater) Update(restore *v1alpha1.Restore, condit
}
return nil
})
if isUpdate {
rcu.recordRestoreEvent("update", restore, err)
}
return err
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/service_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func (sc *realServiceControl) UpdateService(tc *v1alpha1.TidbCluster, svc *corev

return updateErr
})
sc.recordServiceEvent("update", tc, svc, err)
return updateSvc, err
}

Expand Down
8 changes: 0 additions & 8 deletions pkg/controller/service_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ func TestServiceControlUpdateService(t *testing.T) {
updateSvc, err := control.UpdateService(tc, svc)
g.Expect(err).To(Succeed())
g.Expect(updateSvc.Spec.ClusterIP).To(Equal("1.1.1.1"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestServiceControlUpdateServiceConflictSuccess(t *testing.T) {
Expand Down Expand Up @@ -112,10 +108,6 @@ func TestServiceControlUpdateServiceConflictSuccess(t *testing.T) {
updateSvc, err := control.UpdateService(tc, svc)
g.Expect(err).To(Succeed())
g.Expect(updateSvc.Spec.ClusterIP).To(Equal("1.1.1.1"))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestServiceControlDeleteService(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/stateful_set_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func (sc *realStatefulSetControl) UpdateStatefulSet(tc *v1alpha1.TidbCluster, se
return updateErr
})

sc.recordStatefulSetEvent("update", tc, set, err)
return updatedSS, err
}

Expand Down
8 changes: 0 additions & 8 deletions pkg/controller/stateful_set_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ func TestStatefulSetControlUpdateStatefulSet(t *testing.T) {
updateSS, err := control.UpdateStatefulSet(tc, set)
g.Expect(err).To(Succeed())
g.Expect(int(*updateSS.Spec.Replicas)).To(Equal(100))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestStatefulSetControlUpdateStatefulSetConflictSuccess(t *testing.T) {
Expand Down Expand Up @@ -129,10 +125,6 @@ func TestStatefulSetControlUpdateStatefulSetConflictSuccess(t *testing.T) {
updateSS, err := control.UpdateStatefulSet(tc, set)
g.Expect(err).To(Succeed())
g.Expect(int(*updateSS.Spec.Replicas)).To(Equal(100))

events := collectEvents(recorder.Events)
g.Expect(events).To(HaveLen(1))
g.Expect(events[0]).To(ContainSubstring(corev1.EventTypeNormal))
}

func TestStatefulSetControlDeleteStatefulSet(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/controller/tidbcluster_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ func (rtc *realTidbClusterControl) UpdateTidbCluster(tc *v1alpha1.TidbCluster, n

return updateErr
})
if !deepEqualExceptHeartbeatTime(newStatus.DeepCopy(), oldStatus.DeepCopy()) {
rtc.recordTidbClusterEvent("update", tc, err)
}
return updateTC, err
}

Expand Down
Loading