Skip to content
This repository was archived by the owner on Sep 18, 2020. It is now read-only.

update-agent: Added reboot-wait parameter #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion cmd/update-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
node = flag.String("node", "", "Kubernetes node name")
printVersion = flag.Bool("version", false, "Print version and exit")
reapTimeout = flag.Int("grace-period", 600, "Period of time in seconds given to a pod to terminate when rebooting for an update")
rebootWait = flag.Int("reboot-wait", 0, "Period of time in seconds waiting after last pod deletion for reboot")
)

func main() {
Expand All @@ -37,7 +38,10 @@ func main() {
}

rt := time.Duration(*reapTimeout) * time.Second
a, err := agent.New(*node, rt)
rw := time.Duration(*rebootWait) * time.Second

glog.Infof("Waiting %v for reboot", rw)
a, err := agent.New(*node, rt, rw)
if err != nil {
glog.Fatalf("Failed to initialize %s: %v", os.Args[0], err)
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Klocksmith struct {
ue *updateengine.Client
lc *login1.Conn
reapTimeout time.Duration
rebootWait time.Duration
}

const defaultPollInterval = 10 * time.Second
Expand All @@ -40,7 +41,7 @@ var (
}).AsSelector()
)

func New(node string, reapTimeout time.Duration) (*Klocksmith, error) {
func New(node string, reapTimeout time.Duration, rebootWait time.Duration) (*Klocksmith, error) {
// set up kubernetes in-cluster client
kc, err := k8sutil.GetClient("")
if err != nil {
Expand All @@ -62,7 +63,7 @@ func New(node string, reapTimeout time.Duration) (*Klocksmith, error) {
return nil, fmt.Errorf("error establishing connection to logind dbus: %v", err)
}

return &Klocksmith{node, kc, nc, ue, lc, reapTimeout}, nil
return &Klocksmith{node, kc, nc, ue, lc, reapTimeout, rebootWait}, nil
}

// Run starts the agent to listen for an update_engine reboot signal and react
Expand Down Expand Up @@ -220,6 +221,11 @@ func (k *Klocksmith) process(stop <-chan struct{}) error {
}
wg.Wait()

// We wait a little bit more time to perform finalizing operations
// This solves problems with some storage provisioners like rook.
glog.Infof("Waiting for finalizing operations, waiting %v", k.rebootWait)
time.Sleep(k.rebootWait)

glog.Info("Node drained, rebooting")

// reboot
Expand Down