mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 20:42:26 +00:00
Merge pull request #122146 from pohly/dra-helper-context-support
DRA helper: enhance context support
This commit is contained in:
commit
8690bbc9c1
@ -189,7 +189,7 @@ func New(
|
|||||||
schedulingCtxInformer := informerFactory.Resource().V1alpha2().PodSchedulingContexts()
|
schedulingCtxInformer := informerFactory.Resource().V1alpha2().PodSchedulingContexts()
|
||||||
claimNameLookup := resourceclaim.NewNameLookup(kubeClient)
|
claimNameLookup := resourceclaim.NewNameLookup(kubeClient)
|
||||||
|
|
||||||
eventBroadcaster := record.NewBroadcaster()
|
eventBroadcaster := record.NewBroadcaster(record.WithContext(ctx))
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
eventBroadcaster.Shutdown()
|
eventBroadcaster.Shutdown()
|
||||||
|
@ -161,6 +161,10 @@ func (l *leaderElection) PrepareHealthCheck(s Server) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *leaderElection) Run() error {
|
func (l *leaderElection) Run() error {
|
||||||
|
ctx := l.ctx
|
||||||
|
if ctx == nil {
|
||||||
|
ctx = context.Background()
|
||||||
|
}
|
||||||
if l.identity == "" {
|
if l.identity == "" {
|
||||||
id, err := defaultLeaderElectionIdentity()
|
id, err := defaultLeaderElectionIdentity()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -174,7 +178,7 @@ func (l *leaderElection) Run() error {
|
|||||||
l.namespace = inClusterNamespace()
|
l.namespace = inClusterNamespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster(record.WithContext(ctx))
|
||||||
broadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: l.clientset.CoreV1().Events(l.namespace)})
|
broadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: l.clientset.CoreV1().Events(l.namespace)})
|
||||||
eventRecorder := broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: fmt.Sprintf("%s/%s", l.lockName, l.identity)})
|
eventRecorder := broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: fmt.Sprintf("%s/%s", l.lockName, l.identity)})
|
||||||
|
|
||||||
@ -188,10 +192,6 @@ func (l *leaderElection) Run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := l.ctx
|
|
||||||
if ctx == nil {
|
|
||||||
ctx = context.Background()
|
|
||||||
}
|
|
||||||
leaderConfig := leaderelection.LeaderElectionConfig{
|
leaderConfig := leaderelection.LeaderElectionConfig{
|
||||||
Lock: lock,
|
Lock: lock,
|
||||||
LeaseDuration: l.leaseDuration,
|
LeaseDuration: l.leaseDuration,
|
||||||
|
Loading…
Reference in New Issue
Block a user