Skip to content

Commit

Permalink
fix: inhibit timer to follow kubelet timer
Browse files Browse the repository at this point in the history
Ensure to wait as long as possibly given to kubelet shutdown timers.
Related to fix of #7138

Signed-off-by: Niklas Wik <niklas.wik@nokia.com>
Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
(cherry picked from commit 339986d)
  • Loading branch information
salkin authored and smira committed May 8, 2023
1 parent 476dccf commit e2979fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
"github.com/siderolabs/talos/internal/pkg/environment"
"github.com/siderolabs/talos/internal/pkg/etcd"
"github.com/siderolabs/talos/internal/pkg/install"
"github.com/siderolabs/talos/internal/pkg/logind"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/internal/pkg/mount"
"github.com/siderolabs/talos/internal/pkg/partition"
Expand Down Expand Up @@ -1604,7 +1605,7 @@ func stopAndRemoveAllPods(stopAction cri.StopAction) runtime.TaskExecutionFunc {

logger.Printf("shutting down kubelet gracefully")

shutdownCtx, shutdownCtxCancel := context.WithTimeout(ctx, constants.KubeletShutdownGracePeriod*2)
shutdownCtx, shutdownCtxCancel := context.WithTimeout(ctx, logind.InhibitMaxDelay)
defer shutdownCtxCancel()

if err = r.State().Machine().DBus().WaitShutdown(shutdownCtx); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions internal/pkg/logind/logind.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ const (
logindService = "org.freedesktop.login1"
logindObject = dbus.ObjectPath("/org/freedesktop/login1")
logindInterface = "org.freedesktop.login1.Manager"

inhibitMaxDelay = 40 * constants.KubeletShutdownGracePeriod
)

// InhibitMaxDelay is the maximum delay for graceful shutdown.
const InhibitMaxDelay = 40 * constants.KubeletShutdownGracePeriod

type logindMock struct {
mu sync.Mutex
inhibitPipe []int
Expand All @@ -32,7 +33,7 @@ type logindMock struct {
var logindProps = map[string]map[string]*prop.Prop{
logindInterface: {
"InhibitDelayMaxUSec": {
Value: uint64(inhibitMaxDelay / time.Microsecond),
Value: uint64(InhibitMaxDelay / time.Microsecond),
Writable: false,
},
},
Expand Down

0 comments on commit e2979fb

Please sign in to comment.