Skip to content

Commit 23a15d0

Browse files
authored
Merge pull request #117574 from mpatlasov/automated-cherry-pick-of-#117022-upstream-release-1.27
Automated cherry pick of #117022: Fix directory mismatch for `volume.SetVolumeOwnership()`
2 parents 1985034 + 57e67a9 commit 23a15d0

File tree

18 files changed

+27
-29
lines changed

18 files changed

+27
-29
lines changed

pkg/volume/configmap/configmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func (b *configMapVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterA
252252
setPerms := func(_ string) error {
253253
// This may be the first time writing and new files get created outside the timestamp subdirectory:
254254
// change the permissions on the whole volume and not only in the timestamp directory.
255-
return volume.SetVolumeOwnership(b, mounterArgs.FsGroup, nil /*fsGroupChangePolicy*/, volumeutil.FSGroupCompleteHook(b.plugin, nil))
255+
return volume.SetVolumeOwnership(b, dir, mounterArgs.FsGroup, nil /*fsGroupChangePolicy*/, volumeutil.FSGroupCompleteHook(b.plugin, nil))
256256
}
257257
err = writer.Write(payload, setPerms)
258258
if err != nil {

pkg/volume/csi/csi_mounter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func (c *csiMountMgr) SetUpAt(dir string, mounterArgs volume.MounterArgs) error
333333
// Driver doesn't support applying FSGroup. Kubelet must apply it instead.
334334

335335
// fullPluginName helps to distinguish different driver from csi plugin
336-
err := volume.SetVolumeOwnership(c, mounterArgs.FsGroup, mounterArgs.FSGroupChangePolicy, util.FSGroupCompleteHook(c.plugin, c.spec))
336+
err := volume.SetVolumeOwnership(c, dir, mounterArgs.FsGroup, mounterArgs.FSGroupChangePolicy, util.FSGroupCompleteHook(c.plugin, c.spec))
337337
if err != nil {
338338
// At this point mount operation is successful:
339339
// 1. Since volume can not be used by the pod because of invalid permissions, we must return error

pkg/volume/downwardapi/downwardapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func (b *downwardAPIVolumeMounter) SetUpAt(dir string, mounterArgs volume.Mounte
223223
setPerms := func(_ string) error {
224224
// This may be the first time writing and new files get created outside the timestamp subdirectory:
225225
// change the permissions on the whole volume and not only in the timestamp directory.
226-
return volume.SetVolumeOwnership(b, mounterArgs.FsGroup, nil /*fsGroupChangePolicy*/, volumeutil.FSGroupCompleteHook(b.plugin, nil))
226+
return volume.SetVolumeOwnership(b, dir, mounterArgs.FsGroup, nil /*fsGroupChangePolicy*/, volumeutil.FSGroupCompleteHook(b.plugin, nil))
227227
}
228228
err = writer.Write(data, setPerms)
229229
if err != nil {

pkg/volume/emptydir/empty_dir.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func (ed *emptyDir) SetUpAt(dir string, mounterArgs volume.MounterArgs) error {
280280
err = fmt.Errorf("unknown storage medium %q", ed.medium)
281281
}
282282

283-
volume.SetVolumeOwnership(ed, mounterArgs.FsGroup, nil /*fsGroupChangePolicy*/, volumeutil.FSGroupCompleteHook(ed.plugin, nil))
283+
volume.SetVolumeOwnership(ed, dir, mounterArgs.FsGroup, nil /*fsGroupChangePolicy*/, volumeutil.FSGroupCompleteHook(ed.plugin, nil))
284284

285285
// If setting up the quota fails, just log a message but don't actually error out.
286286
// We'll use the old du mechanism in this case, at least until we support

pkg/volume/fc/disk_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func diskSetUp(manager diskManager, b fcDiskMounter, volPath string, mounter mou
9191
}
9292

9393
if !b.readOnly {
94-
volume.SetVolumeOwnership(&b, fsGroup, fsGroupChangePolicy, util.FSGroupCompleteHook(b.plugin, nil))
94+
volume.SetVolumeOwnership(&b, volPath, fsGroup, fsGroupChangePolicy, util.FSGroupCompleteHook(b.plugin, nil))
9595
}
9696

9797
return nil

pkg/volume/flexvolume/mounter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (f *flexVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs)
9595
if !f.readOnly {
9696
if f.plugin.capabilities.FSGroup {
9797
// fullPluginName helps to distinguish different driver from flex volume plugin
98-
volume.SetVolumeOwnership(f, mounterArgs.FsGroup, mounterArgs.FSGroupChangePolicy, util.FSGroupCompleteHook(f.plugin, f.spec))
98+
volume.SetVolumeOwnership(f, dir, mounterArgs.FsGroup, mounterArgs.FSGroupChangePolicy, util.FSGroupCompleteHook(f.plugin, f.spec))
9999
}
100100
}
101101

pkg/volume/gcepd/gce_pd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, mounterArgs volume.Mounte
430430

431431
klog.V(4).Infof("mount of disk %s succeeded", dir)
432432
if !b.readOnly {
433-
if err := volume.SetVolumeOwnership(b, mounterArgs.FsGroup, mounterArgs.FSGroupChangePolicy, util.FSGroupCompleteHook(b.plugin, nil)); err != nil {
433+
if err := volume.SetVolumeOwnership(b, dir, mounterArgs.FsGroup, mounterArgs.FSGroupChangePolicy, util.FSGroupCompleteHook(b.plugin, nil)); err != nil {
434434
klog.Errorf("SetVolumeOwnership returns error %v", err)
435435
}
436436
}

pkg/volume/git_repo/git_repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (b *gitRepoVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArg
235235
return fmt.Errorf("failed to exec 'git reset --hard': %s: %v", output, err)
236236
}
237237

238-
volume.SetVolumeOwnership(b, mounterArgs.FsGroup, nil /*fsGroupChangePolicy*/, volumeutil.FSGroupCompleteHook(b.plugin, nil))
238+
volume.SetVolumeOwnership(b, dir, mounterArgs.FsGroup, nil /*fsGroupChangePolicy*/, volumeutil.FSGroupCompleteHook(b.plugin, nil))
239239

240240
volumeutil.SetReady(b.getMetaDir())
241241
return nil

pkg/volume/iscsi/disk_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func diskSetUp(manager diskManager, b iscsiDiskMounter, volPath string, mounter
9696
}
9797

9898
if !b.readOnly {
99-
volume.SetVolumeOwnership(&b, fsGroup, fsGroupChangePolicy, util.FSGroupCompleteHook(b.plugin, nil))
99+
volume.SetVolumeOwnership(&b, volPath, fsGroup, fsGroupChangePolicy, util.FSGroupCompleteHook(b.plugin, nil))
100100
}
101101

102102
return nil

pkg/volume/local/local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ func (m *localVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs)
615615
if !m.readOnly {
616616
// Volume owner will be written only once on the first volume mount
617617
if len(refs) == 0 {
618-
return volume.SetVolumeOwnership(m, mounterArgs.FsGroup, mounterArgs.FSGroupChangePolicy, util.FSGroupCompleteHook(m.plugin, nil))
618+
return volume.SetVolumeOwnership(m, dir, mounterArgs.FsGroup, mounterArgs.FSGroupChangePolicy, util.FSGroupCompleteHook(m.plugin, nil))
619619
}
620620
}
621621
return nil

0 commit comments

Comments
 (0)