From 62f874b19b579f4cda25e97da6aaffa74d6c6e5e Mon Sep 17 00:00:00 2001 From: Michelle Au Date: Wed, 30 Jan 2019 17:33:51 -0800 Subject: [PATCH] Mark volume as in use even when node status didn't change --- pkg/kubelet/kubelet_node_status.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/kubelet/kubelet_node_status.go b/pkg/kubelet/kubelet_node_status.go index bc86e4d0060..ab276ad0e5d 100644 --- a/pkg/kubelet/kubelet_node_status.go +++ b/pkg/kubelet/kubelet_node_status.go @@ -427,6 +427,23 @@ func (kl *Kubelet) tryUpdateNodeStatus(tryNumber int) error { now := kl.clock.Now() if utilfeature.DefaultFeatureGate.Enabled(features.NodeLease) && now.Before(kl.lastStatusReportTime.Add(kl.nodeStatusReportFrequency)) { if !podCIDRChanged && !nodeStatusHasChanged(&originalNode.Status, &node.Status) { + // We must mark the volumes as ReportedInUse in volume manager's dsw even + // if no changes were made to the node status (no volumes were added or removed + // from the VolumesInUse list). + // + // The reason is that on a kubelet restart, the volume manager's dsw is + // repopulated and the volume ReportedInUse is initialized to false, while the + // VolumesInUse list from the Node object still contains the state from the + // previous kubelet instantiation. + // + // Once the volumes are added to the dsw, the ReportedInUse field needs to be + // synced from the VolumesInUse list in the Node.Status. + // + // The MarkVolumesAsReportedInUse() call cannot be performed in dsw directly + // because it does not have access to the Node object. + // This also cannot be populated on node status manager init because the volume + // may not have been added to dsw at that time. + kl.volumeManager.MarkVolumesAsReportedInUse(node.Status.VolumesInUse) return nil } }