mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 13:55:41 +00:00
kubelet: expose containerStatuses.volumeMounts
For KEP-3857: Recursive Read-only (RRO) mounts Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
dd0882a83e
commit
6f12e1d8e5
@ -337,6 +337,8 @@ type ContainerResources struct {
|
||||
}
|
||||
|
||||
// Status represents the status of a container.
|
||||
//
|
||||
// Status does not contain VolumeMap because CRI API is unaware of volume names.
|
||||
type Status struct {
|
||||
// ID of the container.
|
||||
ID ContainerID
|
||||
|
@ -1976,6 +1976,9 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
|
||||
ImageID: cs.ImageRef,
|
||||
ContainerID: cid,
|
||||
}
|
||||
if oldStatus != nil {
|
||||
status.VolumeMounts = oldStatus.VolumeMounts // immutable
|
||||
}
|
||||
switch {
|
||||
case cs.State == kubecontainer.ContainerStateRunning:
|
||||
status.State.Running = &v1.ContainerStateRunning{StartedAt: metav1.NewTime(cs.StartedAt)}
|
||||
@ -2117,6 +2120,22 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
|
||||
Image: container.Image,
|
||||
State: defaultWaitingState,
|
||||
}
|
||||
// status.VolumeMounts cannot be propagated from kubecontainer.Status
|
||||
// because the CRI API is unaware of the volume names.
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.RecursiveReadOnlyMounts) {
|
||||
for _, vol := range container.VolumeMounts {
|
||||
volStatus := v1.VolumeMountStatus{
|
||||
Name: vol.Name,
|
||||
MountPath: vol.MountPath,
|
||||
ReadOnly: vol.ReadOnly,
|
||||
}
|
||||
if vol.ReadOnly {
|
||||
rroMode := v1.RecursiveReadOnlyDisabled
|
||||
volStatus.RecursiveReadOnly = &rroMode // Disabled or Enabled
|
||||
}
|
||||
status.VolumeMounts = append(status.VolumeMounts, volStatus)
|
||||
}
|
||||
}
|
||||
oldStatus, found := oldStatuses[container.Name]
|
||||
if found {
|
||||
if oldStatus.State.Terminated != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user