-
Notifications
You must be signed in to change notification settings - Fork 20
WIP: pkg/agent: wait for all volumes to be detached before rebooting #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,9 @@ rules: | |
- daemonsets | ||
verbs: | ||
- get | ||
- apiGroups: | ||
- storage.k8s.io | ||
resources: | ||
- volumeattachments | ||
verbs: | ||
- list |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,6 +290,30 @@ func (k *klocksmith) process(ctx context.Context) error { | |
|
||
klog.Info("Node drained, rebooting") | ||
|
||
for { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make this optional behind a opt-in flag. |
||
attachments, err := k.clientset.StorageV1().VolumeAttachments().List(ctx, metav1.ListOptions{}) | ||
if err != nil { | ||
klog.Errorf("Listing volume attachments: %v", err) | ||
continue | ||
Comment on lines
+296
to
+297
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably add some mechanism here to give up, for example a timeout. |
||
} | ||
|
||
anyVolumeAttached := false | ||
|
||
for _, attachment := range attachments.Items { | ||
if attachment.Status.Attached && attachment.Spec.NodeName == k.nodeName { | ||
anyVolumeAttached = true | ||
klog.Infof("Volume %q is still attached, waiting for detach", attachment.Name) | ||
} | ||
} | ||
|
||
if !anyVolumeAttached { | ||
klog.Info("All volumes are detached from node, rebooting.") | ||
break | ||
} | ||
|
||
time.Sleep(5 * time.Second) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this should also be adjustable. |
||
} | ||
|
||
// Reboot. | ||
k.lc.Reboot(false) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message needs to be adjusted (or perhaps moved below the volumes detachment).