-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Skip unused volumes in VolumeManager #81163
Conversation
My old attempt to fix this looks extremely convoluted... What happens in kubelet-side WaitForAttachAndMount since it also reads spec.volumes?
|
I believe that the
My guess is that the other failures are flake... retesting them now to verify. /test pull-kubernetes-integration |
Yes, test failure is legit, @jsafrane volumemanager needs some kind of fix as well since it gets list of volumes to wait for from spec.volumes instead of desired state. I'm sure you can fix it in a nicer way than I did. |
/assign @jingxu97 |
7506c53
to
fb4c781
Compare
You're right, I reworked In addition, I moved most of the code to /hold TODO:
|
fb4c781
to
46589a0
Compare
@wongma7, can you please take a look at the current status? I'll squash the commits if this is the way to go. I could not find any elegant way how to e2e test this. From storage test I can't get the global mount directory or name to check in |
IMO it doesn't need to work for all plugins. Maybe just gcepd, e.g. kubernetes/test/e2e/storage/pd.go Line 616 in 1addcf4
Initially I was thinking to ssh into the node and parse the mounts. Then you could e.g. make sure that the test pod UID has 0 (non secret/token etc.)* mounts. |
|
||
for _, podVolume := range pod.Spec.Volumes { | ||
expectedVolumes = append(expectedVolumes, podVolume.Name) | ||
for _, container := range pod.Spec.Containers { |
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.
what about initContainers?
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.
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.
Wrote too early, the issue is reproducible only in this PR.
I extracted GetPodVolumeNames
and used it consistently in VolumeManager and DSWP.
pvMode: v1.PersistentVolumeBlock, | ||
podMode: v1.PersistentVolumeFilesystem, | ||
expectMount: false, | ||
expectError: true, |
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.
where does the error come from, is it a timeout or won't expectedVolumes
have len 0?
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.
It's not timeout, DSWP has stored error into DSW and WaitForAttachAndMount
asynchronously picked it up within ~podAttachAndMountRetryInterval
(300ms)
46589a0
to
a572ff0
Compare
a572ff0
to
7a9d142
Compare
Ha, we mount unused volumes even to pod directory. I can test that. |
The function will be handy in subsequent patches. Also change custom maps into sets.String.
DesiredStateOfWorldPopulator should skip a volume that is not used in any pod. "Used" means either mounted (via volumeMounts) or used as raw block device (via volumeDevices). Especially when block feature is disabled, a block volume must not get into DesiredStateOfWorld, because it would be formatted and mounted there.
7a9d142
to
2c79ffe
Compare
Added e2e test. Now it should be complete. |
e2e test added, commits squashed a bit |
/retest |
mounts = sets.NewString() | ||
devices = sets.NewString() | ||
|
||
addContainerVolumes(pod.Spec.Containers, mounts, devices) |
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 may need to be updated again after #59484
/lgtm |
/assign @tallclair @derekwaynecarr Note that there is a small behavior change - before this PR, kubelet mounted / mapped as raw block everything that was in |
kubelet changes lgtm. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: derekwaynecarr, jsafrane The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Review the full test history for this PR. Silence the bot with an |
DesiredStateOfWorldPopulator should skip a volume that is not used in any pod. "Used" means either mounted (via volumeMounts) or used as raw block device (via volumeDevices) in a container in the pod.
Especially when block feature is disabled, a block volume must not get into DesiredStateOfWorld, because it would be formatted and mounted there, potentially overwriting any existing raw block data.
/kind bug
Fixes #76044
Does this PR introduce a user-facing change?:
Change of Kubernetes behavior
Previously, all volumes were reported in
node.status.volumesInUse
and they were mounted / mapped as raw block devices in kubelet. With this PR, only the volumes that are actually used will be reported there and mounted/mapped. In most cases this won't make a difference (why would anyone put a volume to a pod and then not use it in any container?)cc: @wongma7 @msau42 @bertinatto