Skip to content

Commit d9cdc9d

Browse files
authored
fix: leader election use nodepool value for lock name (#414)
1 parent a234591 commit d9cdc9d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cmd/scheduler/app/server.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ func Run(opt *options.ServerOption, config *restclient.Config, mux *http.ServeMu
166166
// Prepare event clients.
167167
broadcaster := record.NewBroadcaster()
168168
broadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: leaderElectionClient.CoreV1().Events(lockObjectNamespace)})
169-
eventRecorder := broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: opt.SchedulerName})
169+
componentName := opt.SchedulerName
170+
if len(opt.NodePoolLabelValue) > 0 {
171+
componentName = fmt.Sprintf("%s-%s", opt.SchedulerName, opt.NodePoolLabelValue)
172+
}
173+
eventRecorder := broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: componentName})
170174

171175
hostname, err := os.Hostname()
172176
if err != nil {
@@ -177,7 +181,7 @@ func Run(opt *options.ServerOption, config *restclient.Config, mux *http.ServeMu
177181

178182
rl, err := resourcelock.New(resourcelock.LeasesResourceLock,
179183
lockObjectNamespace,
180-
opt.SchedulerName,
184+
componentName,
181185
leaderElectionClient.CoreV1(),
182186
leaderElectionClient.CoordinationV1(),
183187
resourcelock.ResourceLockConfig{

pkg/scheduler/cache/status_updater/concurrency.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ func (su *defaultStatusUpdater) updatePodGroup(
102102
} else {
103103
// Move the update to the applied cache
104104
su.appliedPodGroupUpdates.Store(key, updateData)
105-
su.inFlightPodGroups.Delete(key)
105+
_, loaded := su.inFlightPodGroups.LoadAndDelete(key)
106+
if !loaded {
107+
su.appliedPodGroupUpdates.Delete(key)
108+
}
106109
}
107110
}
108111

0 commit comments

Comments
 (0)