Skip to content

Commit 28c1193

Browse files
Johann WagnerJasper-Ben
authored andcommitted
update-agent: Added reboot-wait parameter
This adds an reboot-wait parameter, which waits, after the last pod was terminated, an fixed amount of time to finalize operations before reboot. This solves some problems this storage provisioners like rook.
1 parent eb213a8 commit 28c1193

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

cmd/update-agent/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ var (
1919

2020
reapTimeout = flag.Int("grace-period", 600,
2121
"Period of time in seconds given to a pod to terminate when rebooting for an update")
22+
rebootWait = flag.Int("reboot-wait", 0,
23+
"Period of time in seconds waiting after last pod deletion for reboot")
2224
)
2325

2426
func main() {
@@ -44,8 +46,10 @@ func main() {
4446
}
4547

4648
rt := time.Duration(*reapTimeout) * time.Second
49+
rw := time.Duration(*rebootWait) * time.Second
4750

48-
a, err := agent.New(*node, rt)
51+
klog.Infof("Waiting %v for reboot", rw)
52+
a, err := agent.New(*node, rt, rw)
4953
if err != nil {
5054
klog.Fatalf("Failed to initialize %s: %v", os.Args[0], err)
5155
}

pkg/agent/agent.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Klocksmith struct {
3535
ue *updateengine.Client
3636
lc *login1.Conn
3737
reapTimeout time.Duration
38+
rebootWait time.Duration
3839
}
3940

4041
const (
@@ -48,7 +49,7 @@ var shouldRebootSelector = fields.Set(map[string]string{
4849
}).AsSelector()
4950

5051
// New returns initialized Klocksmith.
51-
func New(node string, reapTimeout time.Duration) (*Klocksmith, error) {
52+
func New(node string, reapTimeout time.Duration, rebootWait time.Duration) (*Klocksmith, error) {
5253
// Set up kubernetes in-cluster client.
5354
kc, err := k8sutil.GetClient("")
5455
if err != nil {
@@ -70,7 +71,7 @@ func New(node string, reapTimeout time.Duration) (*Klocksmith, error) {
7071
return nil, fmt.Errorf("error establishing connection to logind dbus: %w", err)
7172
}
7273

73-
return &Klocksmith{node, kc, nc, ue, lc, reapTimeout}, nil
74+
return &Klocksmith{node, kc, nc, ue, lc, reapTimeout, rebootWait}, nil
7475
}
7576

7677
// Run starts the agent to listen for an update_engine reboot signal and react
@@ -249,6 +250,10 @@ func (k *Klocksmith) process(stop <-chan struct{}) error {
249250

250251
wg.Wait()
251252

253+
// We wait a little bit more time to perform finalizing operations
254+
// This solves problems with some storage provisioners like rook.
255+
klog.Infof("Waiting for finalizing operations, waiting %v", k.rebootWait)
256+
252257
klog.Info("Node drained, rebooting")
253258

254259
// Reboot.

0 commit comments

Comments
 (0)