Kubelet should honour the VolumeAttributes which are reported by the volume plugin - #126806
Conversation
|
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/hold |
I tested that locally and every container creation will trigger a new mount, but that's just a counter and not a real system mount. I think that's not a big issue. |
crio log: |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
/test pull-kubernetes-node-crio-cgrpv2-imagevolume-e2e |
|
@carlory we may have to change something SELinux related: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/126806/pull-kubernetes-node-crio-cgrpv2-imagevolume-e2e/1825835412535382016 |
331e052 to
6d88f17
Compare
| vol.SELinuxLabeled = true | ||
| relabelVolume = true | ||
| } | ||
| hostPath, err := volumeutil.GetPath(vol.Mounter) |
There was a problem hiding this comment.
I am concerned of moving and changing so much code that is not under the feature gate. Was it added alongside the feature?
Ideally we want to minimize the number of potential regressions and keep existing codepaths as close to what they were without the feature gate as possible
There was a problem hiding this comment.
I am concerned of moving and changing so much code that is not under the feature gate. Was it added alongside the feature?
It just adds a new conditon check for the previous code. It doesn't change the code itself. I add the feature-gate check in line 289. If the feature-gate is disabled, the image will be nil and old logic will be executed. @SergeyKanzhelev
| Name: mount.Name, | ||
| ContainerPath: containerPath, | ||
| HostPath: hostPath, | ||
| Image: image, |
There was a problem hiding this comment.
I wonder how it worked without the image before? What is the image field is being used for if it was not passed here before and nothing broke?
There was a problem hiding this comment.
It aims to add all missing mount information to the runtime when the volume source is image and let them decide.
There was a problem hiding this comment.
@SergeyKanzhelev some volume attributes reported by the image volume plugin, i.e. relabel, read-only, etc., aren't sent to the implementation of CRI runtime in previous kubelet implementation.
func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, hostDomain string, podIPs []string, podVolumes kubecontainer.VolumeMap, hu hostutil.HostUtils, subpather subpath.Interface, expandEnvs []kubecontainer.EnvVar, supportsRRO bool, imageVolumes kubecontainer.ImageVolumes) ([]kubecontainer.Mount, func(), error) {
mountEtcHostsFile := shouldMountHostsFile(pod, podIPs)
klog.V(3).InfoS("Creating hosts mount for container", "pod", klog.KObj(pod), "containerName", container.Name, "podIPs", podIPs, "path", mountEtcHostsFile)
mounts := []kubecontainer.Mount{}
var cleanupAction func()
for i, mount := range container.VolumeMounts {
// Check if the mount is referencing an OCI volume
if imageVolumes != nil && utilfeature.DefaultFeatureGate.Enabled(features.ImageVolume) {
if image, ok := imageVolumes[mount.Name]; ok {
mounts = append(mounts, kubecontainer.Mount{
Name: mount.Name,
ContainerPath: mount.MountPath,
Image: image,
})
continue
}
}
...skipped..
mounts = append(mounts, kubecontainer.Mount{
Name: mount.Name,
ContainerPath: containerPath,
HostPath: hostPath,
ReadOnly: mount.ReadOnly || mustMountRO,
RecursiveReadOnly: rro,
SELinuxRelabel: relabelVolume,
Propagation: propagation,
})
}
...skipped..
return mounts, cleanupAction, nilWhat's the result? Please see the without this fix section in my PR's description.
|
After bind-mount stuff was fixed for selinux stuff - cri-o/cri-o#8521, what is the new behaviour? @carlory can you please confirm without your change and with your change? |
@gnufied since cri-o/cri-o#8521 is merged, the root cause is fixed, so it won't occur again with or without this PR. Why not revert selinux configuration in this PR, please see #126806 (comment). This PR mainly aims to add all missing mount information to the runtime and let them decide. |
No existing test is broken. I am adding new test. |
updated. |
1a81cfa to
d05abe1
Compare
d05abe1 to
69d6e0e
Compare
69d6e0e to
2529d7d
Compare
|
lost track of this PR. Now it only have test files in it. Perhaps a wrong force push? |
In order to make the new test to check the new feature without the fix, I pushed the first commit to the same PR. @SergeyKanzhelev I'm trying to update the Edit: New tests fail as expected without the fix. |
|
/cc @saschagrunert @SergeyKanzhelev @gnufied Please review it again. Edit: I'm trying to reduce the number of changed lines but fail to achieve that. I give up and revert it to the previous state. It just adds a new conditon check for the previous code. It doesn't change the code itself. I add the feature-gate check in line 304. If the feature-gate is disabled, the image will be nil and old logic will be executed. |
… references an `image` volume source type, It passes the missing mount attributes to the CRI implementation, including `readOnly`, `propagation`, and `recursiveReadOnly`. When the readOnly field of the containerMount is explicitly set to false, the kubelet will take the `readOnly`as true to the CRI implementation because the image volume plugin requires the mount to be read-only. 2. Fix a bug where the pod is unexpectedly running when the `image` volume source type is used and mounted to `/etc/hosts` in the container.
a79af52 to
b6c9c2d
Compare
SergeyKanzhelev
left a comment
There was a problem hiding this comment.
/lgtm
/approve
thank you for resolving all comments
|
LGTM label has been added. DetailsGit tree hash: 6e55785d79059f36a6f30a4b66504a8ec513e314 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: carlory, saschagrunert, SergeyKanzhelev The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Kubelet should honour the VolumeAttributes which are reported by the volume plugin
What type of PR is this?
/kind bug
What this PR does / why we need it:
pods.yaml
imagevolume source type and are mounted to/volumein the container./etc/hostsin the container but use different volume source types.without this fix
pod3 is running but pod4 has
CreateContainerErrorstatus.pod1 mount with
rwoptionwith this fix
pod3 and pod4 has
CreateContainerErrorstatus.pod1 mount with
rooptionWhich issue(s) this PR fixes:
Related to kubernetes/enhancements#4639
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: