Skip to content
Draft
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: 6 additions & 0 deletions examples/deploy/rbac/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ rules:
- daemonsets
verbs:
- get
- apiGroups:
- storage.k8s.io
resources:
- volumeattachments
verbs:
- list
24 changes: 24 additions & 0 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,30 @@ func (k *klocksmith) process(ctx context.Context) error {

klog.Info("Node drained, rebooting")
Copy link
Member Author

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).


for {
Copy link
Member Author

Choose a reason for hiding this comment

The 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
Copy link
Member Author

Choose a reason for hiding this comment

The 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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should also be adjustable.

}

// Reboot.
k.lc.Reboot(false)

Expand Down