mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-14 06:15:45 +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 represents the status of a container.
|
||||||
|
//
|
||||||
|
// Status does not contain VolumeMap because CRI API is unaware of volume names.
|
||||||
type Status struct {
|
type Status struct {
|
||||||
// ID of the container.
|
// ID of the container.
|
||||||
ID ContainerID
|
ID ContainerID
|
||||||
|
@ -1976,6 +1976,9 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
|
|||||||
ImageID: cs.ImageRef,
|
ImageID: cs.ImageRef,
|
||||||
ContainerID: cid,
|
ContainerID: cid,
|
||||||
}
|
}
|
||||||
|
if oldStatus != nil {
|
||||||
|
status.VolumeMounts = oldStatus.VolumeMounts // immutable
|
||||||
|
}
|
||||||
switch {
|
switch {
|
||||||
case cs.State == kubecontainer.ContainerStateRunning:
|
case cs.State == kubecontainer.ContainerStateRunning:
|
||||||
status.State.Running = &v1.ContainerStateRunning{StartedAt: metav1.NewTime(cs.StartedAt)}
|
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,
|
Image: container.Image,
|
||||||
State: defaultWaitingState,
|
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]
|
oldStatus, found := oldStatuses[container.Name]
|
||||||
if found {
|
if found {
|
||||||
if oldStatus.State.Terminated != nil {
|
if oldStatus.State.Terminated != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user