Skip to content

Commit 2ef5e1e

Browse files
authored
Merge pull request kubernetes#4122 from jsafrane/update-reconstruction-attach
Add note about uncertain attachability
2 parents 43b7fb7 + 57562ed commit 2ef5e1e

File tree

1 file changed

+31
-21
lines changed
  • keps/sig-storage/3756-volume-reconstruction

1 file changed

+31
-21
lines changed

keps/sig-storage/3756-volume-reconstruction/README.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -338,35 +338,45 @@ When kubelet starts, VolumeManager starts DSWP and reconciler
338338

339339
However, the first thing that the reconciler does before reconciling DSW and ASW
340340
is that it scans `/var/lib/kubelet/pods/*` and reconstructs **all** found
341-
volumes and adds them to ASW as *uncertain*. Only information that is available
342-
[in the Pod directory on the disk are reconstructed into ASW at this point.
343-
* Since the volume reconstruction can be imperfect and can miss `devicePath`,
344-
]() VolumeManager adds all reconstructed volumes to `volumesNeedDevicePath`
345-
array, to finish their reconstruction from `node.status.volumesAttached`
346-
later.
347-
* All volumes that failed reconstruction are added to
348-
`volumesFailedReconstruction` list.
341+
volumes and adds them to ASW as *uncertainly mounted* and *uncertainly attached*.
342+
Only information that is available in the Pod directory on the disk are
343+
reconstructed into ASW, because kubelet may not have connection to the API
344+
server at this point.
345+
346+
The volume reconstruction can be imperfect:
347+
* It can miss `devicePath`, which may not be possible to reconstruct from the OS.
348+
* For CSI volumes, it cannot decide if a volume is attach-able to
349+
[put it into](https://github.com/kubernetes/kubernetes/blob/89bfdf02762727506c9801d38b202873793d1106/pkg/kubelet/volumemanager/volume_manager.go#L368),
350+
or to [remove it from](https://github.com/kubernetes/kubernetes/blob/5134520a3bc3604d14a10900c7e07481f62d5912/pkg/kubelet/volumemanager/reconciler/reconciler_common.go#L298)
351+
`node.status.volumesInUse`, because it cannot read CSIDriver from the API
352+
server yet.
353+
354+
Kubelet puts the volumes to ASW as *uncertainly attached* and with possibly
355+
wrong `devicePath` it got from the volume plugin. Kubelet stores list of the
356+
reconstructed volumes in `volumesNeedUpdateFromNodeStatus` to fix both
357+
`devicePath` and attach-ability from `node.status.volumesAttached` once it
358+
establishes connection to the API server.
349359

350360
After **ASW** is populated, reconciler starts its
351-
[reconciliation loop](https://github.com/kubernetes/kubernetes/blob/cca3d557e6ff7f265eca8517d7c4fa719077c8d1/pkg/kubelet/volumemanager/reconciler/reconciler_new.go#L33-L69):
361+
[reconciliation loop](https://github.com/kubernetes/kubernetes/blob/16534deedf1e3f7301b20041fafe15ff7f178904/pkg/kubelet/volumemanager/reconciler/reconciler_new.go#L33-L75):
352362
1. `mountOrAttachVolumes()` - mounts (and attaches, if necessary) volumes that
353363
are in DSW, but not in ASW. This can happen even before DSW is fully
354364
populated.
355365

356-
2. `updateReconstructedDevicePaths()` - once kubelet gets connection to the API
357-
server and reads its own `Node.status`, volumes in `volumesNeedDevicePath`
358-
(i.e. all reconstructed volumes) are updated from
359-
`node.status.attachedVolumes`, overwriting any previous `devicePath` in
360-
*uncertain* mounts (i.e. potentially overwriting the reconstructed
361-
`devicePath` or even `devicePath` from `MountDevice` / `SetUp` that ended
362-
as *uncertain* (e.g. timed out). This happens only once,
363-
`volumesNeedDevicePath` is cleared afterwards.
366+
2. `updateReconstructedFromNodeStatus()` - once kubelet gets connection to the
367+
API server and reads its own `node.status`, volumes in
368+
`volumesNeedUpdateFromNodeStatus` (i.e. all reconstructed volumes) are
369+
updated from `node.status.volumesAttached`, overwriting any previous
370+
*uncertain attach-ability* and `devicePath` of *uncertain mounts* (i.e.
371+
potentially overwriting the reconstructed `devicePath` or even `devicePath`
372+
from `MountDevice` / `SetUp` that ended as *uncertain*). This
373+
happens only once, `volumesNeedUpdateFromNodeStatus` is cleared afterwards.
364374

365375
3. (Only once): Add all reconstructed volumes to `node.status.volumesInUse`.
366376

367377
4. Only after DSW was fully populated (i.e. VolumeManager can tell if a volume
368-
is really needed or not), **and** `devicePaths` were populated from
369-
`node.status`, VolumeManager can start unmounting volumes and calls:
378+
is really needed or not), **and** DSW was fixed from `node.status`,
379+
VolumeManager can start unmounting volumes and calls:
370380
1. `unmountVolumes()` - unmounts pod local volume mounts (`TearDown`) that
371381
are in ASW and are not in DSW.
372382
2. `unmountDetachDevices()` - unmounts global volume mounts (`UnmountDevice`)
@@ -389,9 +399,9 @@ for volumes that are still *uncertain*, not to overwrite the *certain* ones.
389399
### Old VolumeManager startup
390400

391401
When kubelet starts, VolumeManager starts DSWP and the reconciler
392-
[in parallel](https://github.com/kubernetes/kubernetes/blob/575616cc72dbfdd070ead81ec29c0d4f00226487/pkg/kubelet/volumemanager/volume_manager.go#L288-L292).
402+
[in parallel](https://github.com/kubernetes/kubernetes/blob/16534deedf1e3f7301b20041fafe15ff7f178904/pkg/kubelet/volumemanager/volume_manager.go#L288-L292).
393403

394-
[The reconciler](https://github.com/kubernetes/kubernetes/blob/44b72d034852eb6da8916c82ce722af604b196c5/pkg/kubelet/volumemanager/reconciler/reconciler.go#L33-L45)
404+
[The reconciler](https://github.com/kubernetes/kubernetes/blob/16534deedf1e3f7301b20041fafe15ff7f178904/pkg/kubelet/volumemanager/reconciler/reconciler.go#L33-L45)
395405
then periodically does:
396406
1. `unmountVolumes()` - unmounts (`TearDown`) pod local volumes that are in
397407
ASW and are not in DSW. Since the ASW is initially empty, this call

0 commit comments

Comments
 (0)