mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
leaderelection: populate the apiVersion/kind when reporting events
This avoids the assumption that the kinds are populated in the schema, and is arguably a little more efficient also.
This commit is contained in:
parent
e4c795168b
commit
3bf06ff3a1
@ -107,7 +107,11 @@ func (cml *ConfigMapLock) RecordEvent(s string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
events := fmt.Sprintf("%v %v", cml.LockConfig.Identity, s)
|
events := fmt.Sprintf("%v %v", cml.LockConfig.Identity, s)
|
||||||
cml.LockConfig.EventRecorder.Eventf(&v1.ConfigMap{ObjectMeta: cml.cm.ObjectMeta}, v1.EventTypeNormal, "LeaderElection", events)
|
subject := &v1.ConfigMap{ObjectMeta: cml.cm.ObjectMeta}
|
||||||
|
// Populate the type meta, so we don't have to get it from the schema
|
||||||
|
subject.Kind = "ConfigMap"
|
||||||
|
subject.APIVersion = v1.SchemeGroupVersion.String()
|
||||||
|
cml.LockConfig.EventRecorder.Eventf(subject, v1.EventTypeNormal, "LeaderElection", events)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Describe is used to convert details on current resource lock
|
// Describe is used to convert details on current resource lock
|
||||||
|
@ -102,7 +102,11 @@ func (el *EndpointsLock) RecordEvent(s string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
events := fmt.Sprintf("%v %v", el.LockConfig.Identity, s)
|
events := fmt.Sprintf("%v %v", el.LockConfig.Identity, s)
|
||||||
el.LockConfig.EventRecorder.Eventf(&v1.Endpoints{ObjectMeta: el.e.ObjectMeta}, v1.EventTypeNormal, "LeaderElection", events)
|
subject := &v1.Endpoints{ObjectMeta: el.e.ObjectMeta}
|
||||||
|
// Populate the type meta, so we don't have to get it from the schema
|
||||||
|
subject.Kind = "Endpoints"
|
||||||
|
subject.APIVersion = v1.SchemeGroupVersion.String()
|
||||||
|
el.LockConfig.EventRecorder.Eventf(subject, v1.EventTypeNormal, "LeaderElection", events)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Describe is used to convert details on current resource lock
|
// Describe is used to convert details on current resource lock
|
||||||
|
@ -87,7 +87,11 @@ func (ll *LeaseLock) RecordEvent(s string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
events := fmt.Sprintf("%v %v", ll.LockConfig.Identity, s)
|
events := fmt.Sprintf("%v %v", ll.LockConfig.Identity, s)
|
||||||
ll.LockConfig.EventRecorder.Eventf(&coordinationv1.Lease{ObjectMeta: ll.lease.ObjectMeta}, corev1.EventTypeNormal, "LeaderElection", events)
|
subject := &coordinationv1.Lease{ObjectMeta: ll.lease.ObjectMeta}
|
||||||
|
// Populate the type meta, so we don't have to get it from the schema
|
||||||
|
subject.Kind = "Lease"
|
||||||
|
subject.APIVersion = coordinationv1.SchemeGroupVersion.String()
|
||||||
|
ll.LockConfig.EventRecorder.Eventf(subject, corev1.EventTypeNormal, "LeaderElection", events)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Describe is used to convert details on current resource lock
|
// Describe is used to convert details on current resource lock
|
||||||
|
Loading…
Reference in New Issue
Block a user