Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 6 additions & 7 deletions shim/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ func (c *Container) Config() *v1.Config {
return c.cfg
}

func (c *Container) ScheduleScaleDown() error {
return c.scheduleScaleDownIn(c.cfg.ScaleDownDuration)
func (c *Container) ScheduleScaleDown() {
c.scheduleScaleDownIn(c.cfg.ScaleDownDuration)
}

func (c *Container) scheduleScaleDownIn(in time.Duration) error {
func (c *Container) scheduleScaleDownIn(in time.Duration) {
// cancel any potential pending scaledonws
c.CancelScaleDown()

if in == 0 {
log.G(c.context).Info("scale down is disabled")
return nil
return
}

log.G(c.context).Infof("scheduling scale down in %s", in)
Expand Down Expand Up @@ -182,7 +182,6 @@ func (c *Container) scheduleScaleDownIn(in time.Duration) error {
}
})
c.scaleDownTimer = timer
return nil
}

func (c *Container) CancelScaleDown() {
Expand Down Expand Up @@ -473,8 +472,8 @@ func (c *Container) restoreHandler(ctx context.Context) activator.RestoreHook {
log.G(ctx).Errorf("error restoring container, exiting process: %s", err)
}
c.Container = restoredContainer

return c.ScheduleScaleDown()
c.ScheduleScaleDown()
return nil
}
}

Expand Down
9 changes: 2 additions & 7 deletions shim/task/service_zeropod.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,7 @@ func (w *wrapper) Start(ctx context.Context, r *taskAPI.StartRequest) (*taskAPI.
return resp, nil
}

if err := zeropodContainer.ScheduleScaleDown(); err != nil {
return nil, err
}

zeropodContainer.ScheduleScaleDown()
return resp, err
}

Expand Down Expand Up @@ -311,9 +308,7 @@ func (w *wrapper) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (*taskAP
// on delete of an exec container we want to schedule scaling down again
// but only if there are no other running execs.
if w.runningExecs[zeropodContainer.Container] == 0 {
if err := zeropodContainer.ScheduleScaleDown(); err != nil {
return nil, err
}
zeropodContainer.ScheduleScaleDown()
}
w.lifecycleMu.Unlock()
}
Expand Down
Loading