Skip to content

Commit

Permalink
Update AddSchedulingEventHandlers to propagate the error back
Browse files Browse the repository at this point in the history
  • Loading branch information
SophieTech88 committed Jun 1, 2024
1 parent 0113fff commit 30f7429
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions pkg/cache/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,33 +111,50 @@ func NewContextWithBootstrapConfigMaps(apis client.APIProvider, bootstrapConfigM
return ctx
}

func (ctx *Context) AddSchedulingEventHandlers() {
ctx.apiProvider.AddEventHandler(&client.ResourceEventHandlers{
func (ctx *Context) AddSchedulingEventHandlers() error {
err := ctx.apiProvider.AddEventHandler(&client.ResourceEventHandlers{
Type: client.ConfigMapInformerHandlers,
FilterFn: ctx.filterConfigMaps,
AddFn: ctx.addConfigMaps,
UpdateFn: ctx.updateConfigMaps,
DeleteFn: ctx.deleteConfigMaps,
})
ctx.apiProvider.AddEventHandler(&client.ResourceEventHandlers{
if err != nil {
return err

Check warning on line 123 in pkg/cache/context.go

View check run for this annotation

Codecov / codecov/patch

pkg/cache/context.go#L123

Added line #L123 was not covered by tests
}

err = ctx.apiProvider.AddEventHandler(&client.ResourceEventHandlers{
Type: client.PriorityClassInformerHandlers,
FilterFn: ctx.filterPriorityClasses,
AddFn: ctx.addPriorityClass,
UpdateFn: ctx.updatePriorityClass,
DeleteFn: ctx.deletePriorityClass,
})
ctx.apiProvider.AddEventHandler(&client.ResourceEventHandlers{
if err != nil {
return err

Check warning on line 134 in pkg/cache/context.go

View check run for this annotation

Codecov / codecov/patch

pkg/cache/context.go#L134

Added line #L134 was not covered by tests
}

err = ctx.apiProvider.AddEventHandler(&client.ResourceEventHandlers{
Type: client.NodeInformerHandlers,
AddFn: ctx.addNode,
UpdateFn: ctx.updateNode,
DeleteFn: ctx.deleteNode,
})
ctx.apiProvider.AddEventHandler(&client.ResourceEventHandlers{
if err != nil {
return err

Check warning on line 144 in pkg/cache/context.go

View check run for this annotation

Codecov / codecov/patch

pkg/cache/context.go#L144

Added line #L144 was not covered by tests
}

err = ctx.apiProvider.AddEventHandler(&client.ResourceEventHandlers{
Type: client.PodInformerHandlers,
AddFn: ctx.AddPod,
UpdateFn: ctx.UpdatePod,
DeleteFn: ctx.DeletePod,
})
if err != nil {
return err

Check warning on line 154 in pkg/cache/context.go

View check run for this annotation

Codecov / codecov/patch

pkg/cache/context.go#L154

Added line #L154 was not covered by tests
}

return nil
}

func (ctx *Context) IsPluginMode() bool {
Expand Down Expand Up @@ -1449,7 +1466,11 @@ func (ctx *Context) InitializeState() error {

// Step 5: Start scheduling event handlers. At this point, initialization is mostly complete, and any existing
// objects will show up as newly added objects. Since the add/update event handlers are idempotent, this is fine.
ctx.AddSchedulingEventHandlers()
err = ctx.AddSchedulingEventHandlers()
if err != nil {
log.Log(log.Admission).Error("failed to add scheduling event handlers", zap.Error(err))
return err

Check warning on line 1472 in pkg/cache/context.go

View check run for this annotation

Codecov / codecov/patch

pkg/cache/context.go#L1471-L1472

Added lines #L1471 - L1472 were not covered by tests
}

// Step 6: Finalize priority classes. Between the start of initialization and when the informer event handlers are
// registered, it is possible that a priority class object was deleted. Process them again and remove
Expand Down

0 comments on commit 30f7429

Please sign in to comment.