rename Gid => GID

according to stylecheck
This commit is contained in:
huweiwen 2023-12-08 23:46:05 +08:00 committed by 胡玮文
parent ce81cc70a6
commit f9a9b6f660
12 changed files with 74 additions and 74 deletions

View File

@ -370,8 +370,8 @@ type mountedPod struct {
// call for volumes that do not need to update contents should not fail. // call for volumes that do not need to update contents should not fail.
remountRequired bool remountRequired bool
// volumeGidValue contains the value of the GID annotation, if present. // volumeGIDValue contains the value of the GID annotation, if present.
volumeGidValue string volumeGIDValue string
// volumeMountStateForPod stores state of volume mount for the pod. if it is: // volumeMountStateForPod stores state of volume mount for the pod. if it is:
// - VolumeMounted: means volume for pod has been successfully mounted // - VolumeMounted: means volume for pod has been successfully mounted
@ -484,7 +484,7 @@ func (asw *actualStateOfWorld) CheckAndMarkVolumeAsUncertainViaReconstruction(op
mounter := opts.Mounter mounter := opts.Mounter
blockVolumeMapper := opts.BlockVolumeMapper blockVolumeMapper := opts.BlockVolumeMapper
outerVolumeSpecName := opts.OuterVolumeSpecName outerVolumeSpecName := opts.OuterVolumeSpecName
volumeGidValue := opts.VolumeGidVolume volumeGIDValue := opts.VolumeGIDVolume
volumeSpec := opts.VolumeSpec volumeSpec := opts.VolumeSpec
podObj = mountedPod{ podObj = mountedPod{
@ -493,7 +493,7 @@ func (asw *actualStateOfWorld) CheckAndMarkVolumeAsUncertainViaReconstruction(op
mounter: mounter, mounter: mounter,
blockVolumeMapper: blockVolumeMapper, blockVolumeMapper: blockVolumeMapper,
outerVolumeSpecName: outerVolumeSpecName, outerVolumeSpecName: outerVolumeSpecName,
volumeGidValue: volumeGidValue, volumeGIDValue: volumeGIDValue,
volumeSpec: volumeSpec, volumeSpec: volumeSpec,
remountRequired: false, remountRequired: false,
volumeMountStateForPod: operationexecutor.VolumeMountUncertain, volumeMountStateForPod: operationexecutor.VolumeMountUncertain,
@ -731,7 +731,7 @@ func (asw *actualStateOfWorld) AddPodToVolume(markVolumeOpts operationexecutor.M
mounter := markVolumeOpts.Mounter mounter := markVolumeOpts.Mounter
blockVolumeMapper := markVolumeOpts.BlockVolumeMapper blockVolumeMapper := markVolumeOpts.BlockVolumeMapper
outerVolumeSpecName := markVolumeOpts.OuterVolumeSpecName outerVolumeSpecName := markVolumeOpts.OuterVolumeSpecName
volumeGidValue := markVolumeOpts.VolumeGidVolume volumeGIDValue := markVolumeOpts.VolumeGIDVolume
volumeSpec := markVolumeOpts.VolumeSpec volumeSpec := markVolumeOpts.VolumeSpec
asw.Lock() asw.Lock()
defer asw.Unlock() defer asw.Unlock()
@ -760,7 +760,7 @@ func (asw *actualStateOfWorld) AddPodToVolume(markVolumeOpts operationexecutor.M
mounter: mounter, mounter: mounter,
blockVolumeMapper: blockVolumeMapper, blockVolumeMapper: blockVolumeMapper,
outerVolumeSpecName: outerVolumeSpecName, outerVolumeSpecName: outerVolumeSpecName,
volumeGidValue: volumeGidValue, volumeGIDValue: volumeGIDValue,
volumeSpec: volumeSpec, volumeSpec: volumeSpec,
volumeMountStateForPod: markVolumeOpts.VolumeMountState, volumeMountStateForPod: markVolumeOpts.VolumeMountState,
seLinuxMountContext: markVolumeOpts.SELinuxMountContext, seLinuxMountContext: markVolumeOpts.SELinuxMountContext,
@ -1311,7 +1311,7 @@ func getMountedVolume(
PodUID: mountedPod.podUID, PodUID: mountedPod.podUID,
Mounter: mountedPod.mounter, Mounter: mountedPod.mounter,
BlockVolumeMapper: mountedPod.blockVolumeMapper, BlockVolumeMapper: mountedPod.blockVolumeMapper,
VolumeGidValue: mountedPod.volumeGidValue, VolumeGIDValue: mountedPod.volumeGIDValue,
VolumeSpec: mountedPod.volumeSpec, VolumeSpec: mountedPod.volumeSpec,
DeviceMountPath: attachedVolume.deviceMountPath, DeviceMountPath: attachedVolume.deviceMountPath,
SELinuxMountContext: seLinuxMountContext}} SELinuxMountContext: seLinuxMountContext}}

View File

@ -61,7 +61,7 @@ type DesiredStateOfWorld interface {
// added. // added.
// If a pod with the same unique name already exists under the specified // If a pod with the same unique name already exists under the specified
// volume, this is a no-op. // volume, this is a no-op.
AddPodToVolume(podName types.UniquePodName, pod *v1.Pod, volumeSpec *volume.Spec, outerVolumeSpecName string, volumeGidValue string, seLinuxContainerContexts []*v1.SELinuxOptions) (v1.UniqueVolumeName, error) AddPodToVolume(podName types.UniquePodName, pod *v1.Pod, volumeSpec *volume.Spec, outerVolumeSpecName string, volumeGIDValue string, seLinuxContainerContexts []*v1.SELinuxOptions) (v1.UniqueVolumeName, error)
// MarkVolumesReportedInUse sets the ReportedInUse value to true for the // MarkVolumesReportedInUse sets the ReportedInUse value to true for the
// reportedVolumes. For volumes not in the reportedVolumes list, the // reportedVolumes. For volumes not in the reportedVolumes list, the
@ -193,8 +193,8 @@ type volumeToMount struct {
// the volume.DeviceMounter interface // the volume.DeviceMounter interface
pluginIsDeviceMountable bool pluginIsDeviceMountable bool
// volumeGidValue contains the value of the GID annotation, if present. // volumeGIDValue contains the value of the GID annotation, if present.
volumeGidValue string volumeGIDValue string
// reportedInUse indicates that the volume was successfully added to the // reportedInUse indicates that the volume was successfully added to the
// VolumesInUse field in the node's status. // VolumesInUse field in the node's status.
@ -262,7 +262,7 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
pod *v1.Pod, pod *v1.Pod,
volumeSpec *volume.Spec, volumeSpec *volume.Spec,
outerVolumeSpecName string, outerVolumeSpecName string,
volumeGidValue string, volumeGIDValue string,
seLinuxContainerContexts []*v1.SELinuxOptions) (v1.UniqueVolumeName, error) { seLinuxContainerContexts []*v1.SELinuxOptions) (v1.UniqueVolumeName, error) {
dsw.Lock() dsw.Lock()
defer dsw.Unlock() defer dsw.Unlock()
@ -336,7 +336,7 @@ func (dsw *desiredStateOfWorld) AddPodToVolume(
podsToMount: make(map[types.UniquePodName]podToMount), podsToMount: make(map[types.UniquePodName]podToMount),
pluginIsAttachable: attachable, pluginIsAttachable: attachable,
pluginIsDeviceMountable: deviceMountable, pluginIsDeviceMountable: deviceMountable,
volumeGidValue: volumeGidValue, volumeGIDValue: volumeGIDValue,
reportedInUse: false, reportedInUse: false,
desiredSizeLimit: sizeLimit, desiredSizeLimit: sizeLimit,
effectiveSELinuxMountFileLabel: effectiveSELinuxMountLabel, effectiveSELinuxMountFileLabel: effectiveSELinuxMountLabel,
@ -606,7 +606,7 @@ func (dsw *desiredStateOfWorld) GetVolumesToMount() []VolumeToMount {
PluginIsAttachable: volumeObj.pluginIsAttachable, PluginIsAttachable: volumeObj.pluginIsAttachable,
PluginIsDeviceMountable: volumeObj.pluginIsDeviceMountable, PluginIsDeviceMountable: volumeObj.pluginIsDeviceMountable,
OuterVolumeSpecName: podObj.outerVolumeSpecName, OuterVolumeSpecName: podObj.outerVolumeSpecName,
VolumeGidValue: volumeObj.volumeGidValue, VolumeGIDValue: volumeObj.volumeGIDValue,
ReportedInUse: volumeObj.reportedInUse, ReportedInUse: volumeObj.reportedInUse,
MountRequestTime: podObj.mountRequestTime, MountRequestTime: podObj.mountRequestTime,
DesiredSizeLimit: volumeObj.desiredSizeLimit, DesiredSizeLimit: volumeObj.desiredSizeLimit,

View File

@ -65,7 +65,7 @@ func Test_AddPodToVolume_Positive_NewPodNewVolume(t *testing.T) {
// Act // Act
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxContainerContexts */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxContainerContexts */)
// Assert // Assert
if err != nil { if err != nil {
@ -111,7 +111,7 @@ func Test_AddPodToVolume_Positive_ExistingPodExistingVolume(t *testing.T) {
// Act // Act
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxContainerContexts */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxContainerContexts */)
// Assert // Assert
if err != nil { if err != nil {
@ -318,7 +318,7 @@ func Test_DeletePodFromVolume_Positive_PodExistsVolumeExists(t *testing.T) {
volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]} volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxContainerContexts */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxContainerContexts */)
if err != nil { if err != nil {
t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err) t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err)
} }
@ -417,19 +417,19 @@ func Test_MarkVolumesReportedInUse_Positive_NewPodNewVolume(t *testing.T) {
pod3Name := util.GetUniquePodName(pod3) pod3Name := util.GetUniquePodName(pod3)
generatedVolume1Name, err := dsw.AddPodToVolume( generatedVolume1Name, err := dsw.AddPodToVolume(
pod1Name, pod1, volume1Spec, volume1Spec.Name(), "" /* volumeGidValue */, nil /* seLinuxContainerContexts */) pod1Name, pod1, volume1Spec, volume1Spec.Name(), "" /* volumeGIDValue */, nil /* seLinuxContainerContexts */)
if err != nil { if err != nil {
t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err) t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err)
} }
generatedVolume2Name, err := dsw.AddPodToVolume( generatedVolume2Name, err := dsw.AddPodToVolume(
pod2Name, pod2, volume2Spec, volume2Spec.Name(), "" /* volumeGidValue */, nil /* seLinuxContainerContexts */) pod2Name, pod2, volume2Spec, volume2Spec.Name(), "" /* volumeGIDValue */, nil /* seLinuxContainerContexts */)
if err != nil { if err != nil {
t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err) t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err)
} }
generatedVolume3Name, err := dsw.AddPodToVolume( generatedVolume3Name, err := dsw.AddPodToVolume(
pod3Name, pod3, volume3Spec, volume3Spec.Name(), "" /* volumeGidValue */, nil /* seLinuxContainerContexts */) pod3Name, pod3, volume3Spec, volume3Spec.Name(), "" /* volumeGIDValue */, nil /* seLinuxContainerContexts */)
if err != nil { if err != nil {
t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err) t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err)
} }
@ -865,7 +865,7 @@ func Test_AddPodToVolume_SELinuxSinglePod(t *testing.T) {
// Act // Act
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, seLinuxContainerContexts) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, seLinuxContainerContexts)
// Assert // Assert
if tc.expectError { if tc.expectError {
@ -1214,7 +1214,7 @@ func Test_AddPodToVolume_SELinux_MultiplePods(t *testing.T) {
// Act // Act
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, seLinuxContainerContexts) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, seLinuxContainerContexts)
// Assert // Assert
if err != nil { if err != nil {
@ -1238,7 +1238,7 @@ func Test_AddPodToVolume_SELinux_MultiplePods(t *testing.T) {
// Act // Act
generatedVolumeName2, err := dsw.AddPodToVolume( generatedVolumeName2, err := dsw.AddPodToVolume(
pod2Name, pod2, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, seLinuxContainerContexts) pod2Name, pod2, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, seLinuxContainerContexts)
// Assert // Assert
if tc.expectError { if tc.expectError {
if err == nil { if err == nil {

View File

@ -312,7 +312,7 @@ func (dswp *desiredStateOfWorldPopulator) processPodVolumes(
continue continue
} }
pvc, volumeSpec, volumeGidValue, err := pvc, volumeSpec, volumeGIDValue, err :=
dswp.createVolumeSpec(logger, podVolume, pod, mounts, devices) dswp.createVolumeSpec(logger, podVolume, pod, mounts, devices)
if err != nil { if err != nil {
logger.Error(err, "Error processing volume", "pod", klog.KObj(pod), "volumeName", podVolume.Name) logger.Error(err, "Error processing volume", "pod", klog.KObj(pod), "volumeName", podVolume.Name)
@ -323,7 +323,7 @@ func (dswp *desiredStateOfWorldPopulator) processPodVolumes(
// Add volume to desired state of world // Add volume to desired state of world
_, err = dswp.desiredStateOfWorld.AddPodToVolume( _, err = dswp.desiredStateOfWorld.AddPodToVolume(
uniquePodName, pod, volumeSpec, podVolume.Name, volumeGidValue, seLinuxContainerContexts[podVolume.Name]) uniquePodName, pod, volumeSpec, podVolume.Name, volumeGIDValue, seLinuxContainerContexts[podVolume.Name])
if err != nil { if err != nil {
logger.Error(err, "Failed to add volume to desiredStateOfWorld", "pod", klog.KObj(pod), "volumeName", podVolume.Name, "volumeSpecName", volumeSpec.Name()) logger.Error(err, "Failed to add volume to desiredStateOfWorld", "pod", klog.KObj(pod), "volumeName", podVolume.Name, "volumeSpecName", volumeSpec.Name())
dswp.desiredStateOfWorld.AddErrorToPod(uniquePodName, err.Error()) dswp.desiredStateOfWorld.AddErrorToPod(uniquePodName, err.Error())
@ -494,7 +494,7 @@ func (dswp *desiredStateOfWorldPopulator) createVolumeSpec(
pvName, pvcUID := pvc.Spec.VolumeName, pvc.UID pvName, pvcUID := pvc.Spec.VolumeName, pvc.UID
logger.V(5).Info("Found bound PV for PVC", "PVC", klog.KRef(pod.Namespace, pvcSource.ClaimName), "PVCUID", pvcUID, "PVName", pvName) logger.V(5).Info("Found bound PV for PVC", "PVC", klog.KRef(pod.Namespace, pvcSource.ClaimName), "PVCUID", pvcUID, "PVName", pvName)
// Fetch actual PV object // Fetch actual PV object
volumeSpec, volumeGidValue, err := volumeSpec, volumeGIDValue, err :=
dswp.getPVSpec(pvName, pvcSource.ReadOnly, pvcUID) dswp.getPVSpec(pvName, pvcSource.ReadOnly, pvcUID)
if err != nil { if err != nil {
return nil, nil, "", fmt.Errorf( return nil, nil, "", fmt.Errorf(
@ -533,7 +533,7 @@ func (dswp *desiredStateOfWorldPopulator) createVolumeSpec(
podVolume.Name, podVolume.Name,
volumeMode) volumeMode)
} }
return pvc, volumeSpec, volumeGidValue, nil return pvc, volumeSpec, volumeGIDValue, nil
} }
// Do not return the original volume object, since the source could mutate it // Do not return the original volume object, since the source could mutate it
@ -614,8 +614,8 @@ func (dswp *desiredStateOfWorldPopulator) getPVSpec(
expectedClaimUID) expectedClaimUID)
} }
volumeGidValue := getPVVolumeGidAnnotationValue(pv) volumeGIDValue := getPVVolumeGidAnnotationValue(pv)
return volume.NewSpecFromPersistentVolume(pv, pvcReadOnly), volumeGidValue, nil return volume.NewSpecFromPersistentVolume(pv, pvcReadOnly), volumeGIDValue, nil
} }
func getPVVolumeGidAnnotationValue(pv *v1.PersistentVolume) string { func getPVVolumeGidAnnotationValue(pv *v1.PersistentVolume) string {

View File

@ -406,7 +406,7 @@ func TestFindAndRemoveDeletedPodsWithUncertain(t *testing.T) {
PodUID: pod.UID, PodUID: pod.UID,
VolumeName: expectedVolumeName, VolumeName: expectedVolumeName,
OuterVolumeSpecName: "dswp-test-volume-name", OuterVolumeSpecName: "dswp-test-volume-name",
VolumeGidVolume: "", VolumeGIDVolume: "",
VolumeSpec: volume.NewSpecFromPersistentVolume(pv, false), VolumeSpec: volume.NewSpecFromPersistentVolume(pv, false),
VolumeMountState: operationexecutor.VolumeMountUncertain, VolumeMountState: operationexecutor.VolumeMountUncertain,
} }
@ -1392,7 +1392,7 @@ func reconcileASW(asw cache.ActualStateOfWorld, dsw cache.DesiredStateOfWorld, t
PodUID: volumeToMount.Pod.UID, PodUID: volumeToMount.Pod.UID,
VolumeName: volumeToMount.VolumeName, VolumeName: volumeToMount.VolumeName,
OuterVolumeSpecName: volumeToMount.OuterVolumeSpecName, OuterVolumeSpecName: volumeToMount.OuterVolumeSpecName,
VolumeGidVolume: volumeToMount.VolumeGidValue, VolumeGIDVolume: volumeToMount.VolumeGIDValue,
VolumeSpec: volumeToMount.VolumeSpec, VolumeSpec: volumeToMount.VolumeSpec,
VolumeMountState: operationexecutor.VolumeMounted, VolumeMountState: operationexecutor.VolumeMounted,
} }

View File

@ -163,7 +163,7 @@ func Test_Run_Positive_VolumeAttachAndMount(t *testing.T) {
volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]} volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
@ -269,7 +269,7 @@ func Test_Run_Positive_VolumeAttachAndMountMigrationEnabled(t *testing.T) {
pod, pod,
migratedSpec, migratedSpec,
migratedSpec.Name(), migratedSpec.Name(),
"", /* volumeGidValue */ "", /* volumeGIDValue */
nil, /* SELinuxContexts */ nil, /* SELinuxContexts */
) )
@ -361,7 +361,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabled(t *testing.T) {
volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]} volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeName}) dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeName})
// Assert // Assert
@ -441,7 +441,7 @@ func Test_Run_Negative_VolumeMountControllerAttachEnabled(t *testing.T) {
volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]} volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
@ -520,7 +520,7 @@ func Test_Run_Positive_VolumeAttachMountUnmountDetach(t *testing.T) {
volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]} volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
@ -623,7 +623,7 @@ func Test_Run_Positive_VolumeUnmountControllerAttachEnabled(t *testing.T) {
volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]} volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
@ -731,7 +731,7 @@ func Test_Run_Positive_VolumeAttachAndMap(t *testing.T) {
} }
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
@ -844,7 +844,7 @@ func Test_Run_Positive_BlockVolumeMapControllerAttachEnabled(t *testing.T) {
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeName}) dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeName})
// Assert // Assert
@ -942,7 +942,7 @@ func Test_Run_Positive_BlockVolumeAttachMapUnmapDetach(t *testing.T) {
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
@ -1067,7 +1067,7 @@ func Test_Run_Positive_VolumeUnmapControllerAttachEnabled(t *testing.T) {
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
@ -1349,7 +1349,7 @@ func Test_Run_Positive_VolumeFSResizeControllerAttachEnabled(t *testing.T) {
volumeSpec := &volume.Spec{PersistentVolume: pv} volumeSpec := &volume.Spec{PersistentVolume: pv}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
volumeName, err := dsw.AddPodToVolume( volumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err) t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err)
@ -1370,7 +1370,7 @@ func Test_Run_Positive_VolumeFSResizeControllerAttachEnabled(t *testing.T) {
// Simulate what DSOWP does // Simulate what DSOWP does
pvWithSize.Spec.Capacity[v1.ResourceStorage] = tc.newPVSize pvWithSize.Spec.Capacity[v1.ResourceStorage] = tc.newPVSize
volumeSpec = &volume.Spec{PersistentVolume: pvWithSize} volumeSpec = &volume.Spec{PersistentVolume: pvWithSize}
dsw.AddPodToVolume(podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxContexts */) dsw.AddPodToVolume(podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxContexts */)
t.Logf("Changing size of the volume to %s", tc.newPVSize.String()) t.Logf("Changing size of the volume to %s", tc.newPVSize.String())
newSize := tc.newPVSize.DeepCopy() newSize := tc.newPVSize.DeepCopy()
@ -1604,7 +1604,7 @@ func Test_UncertainDeviceGlobalMounts(t *testing.T) {
volumeSpec := &volume.Spec{PersistentVolume: pv} volumeSpec := &volume.Spec{PersistentVolume: pv}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
volumeName, err := dsw.AddPodToVolume( volumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err) t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err)
@ -1827,7 +1827,7 @@ func Test_UncertainVolumeMountState(t *testing.T) {
volumeSpec := &volume.Spec{PersistentVolume: pv} volumeSpec := &volume.Spec{PersistentVolume: pv}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
volumeName, err := dsw.AddPodToVolume( volumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
// Assert // Assert
if err != nil { if err != nil {
t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err) t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err)
@ -2166,7 +2166,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
volumeSpecCopy := &volume.Spec{Volume: &pod.Spec.Volumes[0]} volumeSpecCopy := &volume.Spec{Volume: &pod.Spec.Volumes[0]}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
generatedVolumeName, err := dsw.AddPodToVolume( generatedVolumeName, err := dsw.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeName}) dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeName})
if err != nil { if err != nil {
@ -2193,7 +2193,7 @@ func Test_Run_Positive_VolumeMountControllerAttachEnabledRace(t *testing.T) {
klog.InfoS("UnmountDevice called") klog.InfoS("UnmountDevice called")
var generatedVolumeNameCopy v1.UniqueVolumeName var generatedVolumeNameCopy v1.UniqueVolumeName
generatedVolumeNameCopy, err = dsw.AddPodToVolume( generatedVolumeNameCopy, err = dsw.AddPodToVolume(
podName, pod, volumeSpecCopy, volumeSpec.Name(), "" /* volumeGidValue */, nil /* seLinuxLabel */) podName, pod, volumeSpecCopy, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* seLinuxLabel */)
dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeNameCopy}) dsw.MarkVolumesReportedInUse([]v1.UniqueVolumeName{generatedVolumeNameCopy})
return nil return nil
} }

View File

@ -115,7 +115,7 @@ func (rc *reconciler) updateStates(reconstructedVolumes map[v1.UniqueVolumeName]
Mounter: volume.mounter, Mounter: volume.mounter,
BlockVolumeMapper: volume.blockVolumeMapper, BlockVolumeMapper: volume.blockVolumeMapper,
OuterVolumeSpecName: volume.outerVolumeSpecName, OuterVolumeSpecName: volume.outerVolumeSpecName,
VolumeGidVolume: volume.volumeGidValue, VolumeGIDVolume: volume.volumeGIDValue,
VolumeSpec: volume.volumeSpec, VolumeSpec: volume.volumeSpec,
VolumeMountState: operationexecutor.VolumeMountUncertain, VolumeMountState: operationexecutor.VolumeMountUncertain,
SELinuxMountContext: volume.seLinuxMountContext, SELinuxMountContext: volume.seLinuxMountContext,

View File

@ -74,7 +74,7 @@ type reconstructedVolume struct {
volumeSpec *volumepkg.Spec volumeSpec *volumepkg.Spec
outerVolumeSpecName string outerVolumeSpecName string
pod *v1.Pod pod *v1.Pod
volumeGidValue string volumeGIDValue string
devicePath string devicePath string
mounter volumepkg.Mounter mounter volumepkg.Mounter
deviceMounter volumepkg.DeviceMounter deviceMounter volumepkg.DeviceMounter
@ -98,7 +98,7 @@ func (rv reconstructedVolume) MarshalLog() interface{} {
VolumeSpecName: rv.volumeSpec.Name(), VolumeSpecName: rv.volumeSpec.Name(),
OuterVolumeSpecName: rv.outerVolumeSpecName, OuterVolumeSpecName: rv.outerVolumeSpecName,
PodUID: string(rv.pod.UID), PodUID: string(rv.pod.UID),
VolumeGIDValue: rv.volumeGidValue, VolumeGIDValue: rv.volumeGIDValue,
DevicePath: rv.devicePath, DevicePath: rv.devicePath,
SeLinuxMountContext: rv.seLinuxMountContext, SeLinuxMountContext: rv.seLinuxMountContext,
} }
@ -386,7 +386,7 @@ func (rc *reconciler) reconstructVolume(volume podVolume) (rvolume *reconstructe
outerVolumeSpecName: volume.volumeSpecName, outerVolumeSpecName: volume.volumeSpecName,
pod: pod, pod: pod,
deviceMounter: deviceMounter, deviceMounter: deviceMounter,
volumeGidValue: "", volumeGIDValue: "",
// devicePath is updated during updateStates() by checking node status's VolumesAttached data. // devicePath is updated during updateStates() by checking node status's VolumesAttached data.
// TODO: get device path directly from the volume mount path. // TODO: get device path directly from the volume mount path.
devicePath: "", devicePath: "",

View File

@ -195,7 +195,7 @@ func TestCleanOrphanVolumes(t *testing.T) {
volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]} volumeSpec := &volume.Spec{Volume: &pod.Spec.Volumes[0]}
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
volumeName, err := rcInstance.desiredStateOfWorld.AddPodToVolume( volumeName, err := rcInstance.desiredStateOfWorld.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* SELinuxContext */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* SELinuxContext */)
if err != nil { if err != nil {
t.Fatalf("Error adding volume %s to dsow: %v", volumeSpec.Name(), err) t.Fatalf("Error adding volume %s to dsow: %v", volumeSpec.Name(), err)
} }
@ -318,7 +318,7 @@ func TestReconstructVolumesMount(t *testing.T) {
podName := util.GetUniquePodName(pod) podName := util.GetUniquePodName(pod)
volumeName, err := rcInstance.desiredStateOfWorld.AddPodToVolume( volumeName, err := rcInstance.desiredStateOfWorld.AddPodToVolume(
podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGidValue */, nil /* SELinuxContext */) podName, pod, volumeSpec, volumeSpec.Name(), "" /* volumeGIDValue */, nil /* SELinuxContext */)
if err != nil { if err != nil {
t.Fatalf("Error adding volume %s to dsow: %v", volumeSpec.Name(), err) t.Fatalf("Error adding volume %s to dsow: %v", volumeSpec.Name(), err)
} }

View File

@ -334,14 +334,14 @@ func (vm *volumeManager) GetExtraSupplementalGroupsForPod(pod *v1.Pod) []int64 {
supplementalGroups := sets.New[string]() supplementalGroups := sets.New[string]()
for _, mountedVolume := range vm.actualStateOfWorld.GetMountedVolumesForPod(podName) { for _, mountedVolume := range vm.actualStateOfWorld.GetMountedVolumesForPod(podName) {
if mountedVolume.VolumeGidValue != "" { if mountedVolume.VolumeGIDValue != "" {
supplementalGroups.Insert(mountedVolume.VolumeGidValue) supplementalGroups.Insert(mountedVolume.VolumeGIDValue)
} }
} }
result := make([]int64, 0, supplementalGroups.Len()) result := make([]int64, 0, supplementalGroups.Len())
for _, group := range supplementalGroups.UnsortedList() { for _, group := range supplementalGroups.UnsortedList() {
iGroup, extra := getExtraSupplementalGid(group, pod) iGroup, extra := getExtraSupplementalGID(group, pod)
if !extra { if !extra {
continue continue
} }
@ -585,22 +585,22 @@ func getExpectedVolumes(pod *v1.Pod) []string {
return mounts.Union(devices).UnsortedList() return mounts.Union(devices).UnsortedList()
} }
// getExtraSupplementalGid returns the value of an extra supplemental GID as // getExtraSupplementalGID returns the value of an extra supplemental GID as
// defined by an annotation on a volume and a boolean indicating whether the // defined by an annotation on a volume and a boolean indicating whether the
// volume defined a GID that the pod doesn't already request. // volume defined a GID that the pod doesn't already request.
func getExtraSupplementalGid(volumeGidValue string, pod *v1.Pod) (int64, bool) { func getExtraSupplementalGID(volumeGIDValue string, pod *v1.Pod) (int64, bool) {
if volumeGidValue == "" { if volumeGIDValue == "" {
return 0, false return 0, false
} }
gid, err := strconv.ParseInt(volumeGidValue, 10, 64) gid, err := strconv.ParseInt(volumeGIDValue, 10, 64)
if err != nil { if err != nil {
return 0, false return 0, false
} }
if pod.Spec.SecurityContext != nil { if pod.Spec.SecurityContext != nil {
for _, existingGid := range pod.Spec.SecurityContext.SupplementalGroups { for _, existingGID := range pod.Spec.SecurityContext.SupplementalGroups {
if gid == int64(existingGid) { if gid == int64(existingGID) {
return 0, false return 0, false
} }
} }

View File

@ -170,7 +170,7 @@ type MarkVolumeOpts struct {
Mounter volume.Mounter Mounter volume.Mounter
BlockVolumeMapper volume.BlockVolumeMapper BlockVolumeMapper volume.BlockVolumeMapper
OuterVolumeSpecName string OuterVolumeSpecName string
VolumeGidVolume string VolumeGIDVolume string
VolumeSpec *volume.Spec VolumeSpec *volume.Spec
VolumeMountState VolumeMountState VolumeMountState VolumeMountState
SELinuxMountContext string SELinuxMountContext string
@ -438,8 +438,8 @@ type VolumeToMount struct {
// the volume.DeviceMounter interface // the volume.DeviceMounter interface
PluginIsDeviceMountable bool PluginIsDeviceMountable bool
// VolumeGidValue contains the value of the GID annotation, if present. // VolumeGIDValue contains the value of the GID annotation, if present.
VolumeGidValue string VolumeGIDValue string
// DevicePath contains the path on the node where the volume is attached. // DevicePath contains the path on the node where the volume is attached.
// For non-attachable volumes this is empty. // For non-attachable volumes this is empty.
@ -739,8 +739,8 @@ type MountedVolume struct {
// BlockVolumeMapper is only required for block volumes and not required for file system volumes. // BlockVolumeMapper is only required for block volumes and not required for file system volumes.
BlockVolumeMapper volume.BlockVolumeMapper BlockVolumeMapper volume.BlockVolumeMapper
// VolumeGidValue contains the value of the GID annotation, if present. // VolumeGIDValue contains the value of the GID annotation, if present.
VolumeGidValue string VolumeGIDValue string
// VolumeSpec is a volume spec containing the specification for the volume // VolumeSpec is a volume spec containing the specification for the volume
// that should be mounted. // that should be mounted.

View File

@ -616,7 +616,7 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
VolumeName: volumeToMount.VolumeName, VolumeName: volumeToMount.VolumeName,
Mounter: volumeMounter, Mounter: volumeMounter,
OuterVolumeSpecName: volumeToMount.OuterVolumeSpecName, OuterVolumeSpecName: volumeToMount.OuterVolumeSpecName,
VolumeGidVolume: volumeToMount.VolumeGidValue, VolumeGIDVolume: volumeToMount.VolumeGIDValue,
VolumeSpec: volumeToMount.VolumeSpec, VolumeSpec: volumeToMount.VolumeSpec,
VolumeMountState: VolumeMounted, VolumeMountState: VolumeMounted,
SELinuxMountContext: volumeToMount.SELinuxLabel, SELinuxMountContext: volumeToMount.SELinuxLabel,
@ -785,7 +785,7 @@ func (og *operationGenerator) GenerateUnmountVolumeFunc(
PodUID: volumeToUnmount.PodUID, PodUID: volumeToUnmount.PodUID,
VolumeName: volumeToUnmount.VolumeName, VolumeName: volumeToUnmount.VolumeName,
OuterVolumeSpecName: volumeToUnmount.OuterVolumeSpecName, OuterVolumeSpecName: volumeToUnmount.OuterVolumeSpecName,
VolumeGidVolume: volumeToUnmount.VolumeGidValue, VolumeGIDVolume: volumeToUnmount.VolumeGIDValue,
VolumeSpec: volumeToUnmount.VolumeSpec, VolumeSpec: volumeToUnmount.VolumeSpec,
VolumeMountState: VolumeMountUncertain, VolumeMountState: VolumeMountUncertain,
} }
@ -801,14 +801,14 @@ func (og *operationGenerator) GenerateUnmountVolumeFunc(
} }
klog.Infof( klog.Infof(
"UnmountVolume.TearDown succeeded for volume %q (OuterVolumeSpecName: %q) pod %q (UID: %q). InnerVolumeSpecName %q. PluginName %q, VolumeGidValue %q", "UnmountVolume.TearDown succeeded for volume %q (OuterVolumeSpecName: %q) pod %q (UID: %q). InnerVolumeSpecName %q. PluginName %q, VolumeGIDValue %q",
volumeToUnmount.VolumeName, volumeToUnmount.VolumeName,
volumeToUnmount.OuterVolumeSpecName, volumeToUnmount.OuterVolumeSpecName,
volumeToUnmount.PodName, volumeToUnmount.PodName,
volumeToUnmount.PodUID, volumeToUnmount.PodUID,
volumeToUnmount.InnerVolumeSpecName, volumeToUnmount.InnerVolumeSpecName,
volumeToUnmount.PluginName, volumeToUnmount.PluginName,
volumeToUnmount.VolumeGidValue) volumeToUnmount.VolumeGIDValue)
// Update actual state of world // Update actual state of world
markVolMountedErr := actualStateOfWorld.MarkVolumeAsUnmounted( markVolMountedErr := actualStateOfWorld.MarkVolumeAsUnmounted(
@ -1052,7 +1052,7 @@ func (og *operationGenerator) GenerateMapVolumeFunc(
VolumeName: volumeToMount.VolumeName, VolumeName: volumeToMount.VolumeName,
BlockVolumeMapper: blockVolumeMapper, BlockVolumeMapper: blockVolumeMapper,
OuterVolumeSpecName: volumeToMount.OuterVolumeSpecName, OuterVolumeSpecName: volumeToMount.OuterVolumeSpecName,
VolumeGidVolume: volumeToMount.VolumeGidValue, VolumeGIDVolume: volumeToMount.VolumeGIDValue,
VolumeSpec: volumeToMount.VolumeSpec, VolumeSpec: volumeToMount.VolumeSpec,
VolumeMountState: VolumeMounted, VolumeMountState: VolumeMounted,
} }
@ -1225,7 +1225,7 @@ func (og *operationGenerator) GenerateUnmapVolumeFunc(
PodUID: volumeToUnmount.PodUID, PodUID: volumeToUnmount.PodUID,
VolumeName: volumeToUnmount.VolumeName, VolumeName: volumeToUnmount.VolumeName,
OuterVolumeSpecName: volumeToUnmount.OuterVolumeSpecName, OuterVolumeSpecName: volumeToUnmount.OuterVolumeSpecName,
VolumeGidVolume: volumeToUnmount.VolumeGidValue, VolumeGIDVolume: volumeToUnmount.VolumeGIDValue,
VolumeSpec: volumeToUnmount.VolumeSpec, VolumeSpec: volumeToUnmount.VolumeSpec,
VolumeMountState: VolumeMountUncertain, VolumeMountState: VolumeMountUncertain,
} }
@ -1256,14 +1256,14 @@ func (og *operationGenerator) GenerateUnmapVolumeFunc(
} }
klog.Infof( klog.Infof(
"UnmapVolume succeeded for volume %q (OuterVolumeSpecName: %q) pod %q (UID: %q). InnerVolumeSpecName %q. PluginName %q, VolumeGidValue %q", "UnmapVolume succeeded for volume %q (OuterVolumeSpecName: %q) pod %q (UID: %q). InnerVolumeSpecName %q. PluginName %q, VolumeGIDValue %q",
volumeToUnmount.VolumeName, volumeToUnmount.VolumeName,
volumeToUnmount.OuterVolumeSpecName, volumeToUnmount.OuterVolumeSpecName,
volumeToUnmount.PodName, volumeToUnmount.PodName,
volumeToUnmount.PodUID, volumeToUnmount.PodUID,
volumeToUnmount.InnerVolumeSpecName, volumeToUnmount.InnerVolumeSpecName,
volumeToUnmount.PluginName, volumeToUnmount.PluginName,
volumeToUnmount.VolumeGidValue) volumeToUnmount.VolumeGIDValue)
// Update actual state of world // Update actual state of world
markVolUnmountedErr := actualStateOfWorld.MarkVolumeAsUnmounted( markVolUnmountedErr := actualStateOfWorld.MarkVolumeAsUnmounted(