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
Rework volume reconstruction #108180
Rework volume reconstruction #108180
Changes from all commits
2ccd232
71a6177
d51b597
750a1c8
6013b77
6a751d0
c423a80
1bdeb9f
88348d7
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 |
---|---|---|
|
@@ -175,6 +175,12 @@ type ActualStateOfWorld interface { | |
// SyncReconstructedVolume check the volume.outerVolumeSpecName in asw and | ||
// the one populated from dsw , if they do not match, update this field from the value from dsw. | ||
SyncReconstructedVolume(volumeName v1.UniqueVolumeName, podName volumetypes.UniquePodName, outerVolumeSpecName string) | ||
|
||
// UpdateReconstructedDevicePath updates devicePath of a reconstructed volume | ||
// from Node.Status.VolumesAttached. The ASW is updated only when the volume is still | ||
// uncertain. If the volume got mounted in the meantime, its devicePath must have | ||
// been fixed by such an update. | ||
UpdateReconstructedDevicePath(volumeName v1.UniqueVolumeName, devicePath string) | ||
} | ||
|
||
// MountedVolume represents a volume that has successfully been mounted to a pod. | ||
|
@@ -390,6 +396,24 @@ func (asw *actualStateOfWorld) MarkDeviceAsUnmounted( | |
return asw.SetDeviceMountState(volumeName, operationexecutor.DeviceNotMounted, "", "") | ||
} | ||
|
||
func (asw *actualStateOfWorld) UpdateReconstructedDevicePath(volumeName v1.UniqueVolumeName, devicePath string) { | ||
asw.RLock() | ||
defer asw.RUnlock() | ||
|
||
volumeObj, volumeExists := asw.attachedVolumes[volumeName] | ||
if !volumeExists { | ||
return | ||
} | ||
if volumeObj.deviceMountState != operationexecutor.DeviceMountUncertain { | ||
// Reconciler must have updated volume state, i.e. when a pod uses the volume and | ||
// succeeded mounting the volume. Such update has fixed the device path. | ||
return | ||
} | ||
|
||
volumeObj.devicePath = devicePath | ||
asw.attachedVolumes[volumeName] = volumeObj | ||
} | ||
|
||
func (asw *actualStateOfWorld) GetDeviceMountState(volumeName v1.UniqueVolumeName) operationexecutor.DeviceMountState { | ||
asw.RLock() | ||
defer asw.RUnlock() | ||
|
@@ -525,7 +549,16 @@ func (asw *actualStateOfWorld) AddPodToVolume(markVolumeOpts operationexecutor.M | |
} | ||
|
||
podObj, podExists := volumeObj.mountedPods[podName] | ||
if !podExists { | ||
|
||
updateUncertainVolume := false | ||
if podExists { | ||
// Update uncertain volumes - the new markVolumeOpts may have updated information. | ||
// Especially reconstructed volumes (marked as uncertain during reconstruction) need | ||
// an update. | ||
updateUncertainVolume = utilfeature.DefaultFeatureGate.Enabled(features.SELinuxMountReadWriteOncePod) && podObj.volumeMountStateForPod == operationexecutor.VolumeMountUncertain | ||
} | ||
if !podExists || updateUncertainVolume { | ||
// Add new mountedPod or update existing one. | ||
podObj = mountedPod{ | ||
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. Does not doing this results in real breakage? (sorry just curious, I suspected it will but I don't know for sure). 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. I don't know, you told me that we can't trust reconstructed volumes. And I think we should not trust Uncertain volumes either, so I update everything. |
||
podName: podName, | ||
podUID: podUID, | ||
|
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.
Do we still need something like https://github.com/kubernetes/kubernetes/pull/103181/files#diff-44ca3bc69624dc3e1184df22f6b88f256b55174b47e6bf5d8f148a9a07469ccfR892 ?
Not a blocker but just a follow up question.
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.
I'm not sure I follow, can you please elaborate?
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.
So there was this bug - #103143 which was reported because during reconstruction we do not get correct
outerSpecName
and if populator loop did not add volume to DSOW because of api-server unavailability then we never properly mount the volume.After your change - it looks like the entire data structure stored in ASOW is replaced for uncertain volumes, so we still need
SyncReconstructedVolume
?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.
You're correct, with
SELinuxMountReadWriteOncePod
feature enabled it should not be necessary to callSyncReconstructedVolume
. I added a new commit that removes it.