mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Merge pull request #62486 from vladimirvivien/csi-fsGroup-fix
Automatic merge from submit-queue (batch tested with PRs 62486, 62471, 62183). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. CSI - Update to apply fsGroup volume ownership **What this PR does / why we need it**: This PR correctly fixes the CSI internal driver to apply fsGroup volume ownership value during mount. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #62413 ```release-note NONE ```
This commit is contained in:
commit
6b6d1ea1ab
@ -219,6 +219,34 @@ func (c *csiMountMgr) SetUpAt(dir string, fsGroup *int64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// apply volume ownership
|
||||||
|
if !c.readOnly && fsGroup != nil {
|
||||||
|
err := volume.SetVolumeOwnership(c, fsGroup)
|
||||||
|
if err != nil {
|
||||||
|
// attempt to rollback mount.
|
||||||
|
glog.Error(log("mounter.SetupAt failed to set fsgroup volume ownership for [%s]: %v", c.volumeID, err))
|
||||||
|
glog.V(4).Info(log("mounter.SetupAt attempting to unpublish volume %s due to previous error", c.volumeID))
|
||||||
|
if unpubErr := csi.NodeUnpublishVolume(ctx, c.volumeID, dir); unpubErr != nil {
|
||||||
|
glog.Error(log(
|
||||||
|
"mounter.SetupAt failed to unpublish volume [%s]: %v (caused by previous NodePublish error: %v)",
|
||||||
|
c.volumeID, unpubErr, err,
|
||||||
|
))
|
||||||
|
return fmt.Errorf("%v (caused by %v)", unpubErr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if unmountErr := removeMountDir(c.plugin, dir); unmountErr != nil {
|
||||||
|
glog.Error(log(
|
||||||
|
"mounter.SetupAt failed to clean mount dir [%s]: %v (caused by previous NodePublish error: %v)",
|
||||||
|
dir, unmountErr, err,
|
||||||
|
))
|
||||||
|
return fmt.Errorf("%v (caused by %v)", unmountErr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
glog.V(4).Info(log("mounter.SetupAt sets fsGroup to [%d] for %s", *fsGroup, c.volumeID))
|
||||||
|
}
|
||||||
|
|
||||||
glog.V(4).Infof(log("mounter.SetUp successfully requested NodePublish [%s]", dir))
|
glog.V(4).Infof(log("mounter.SetUp successfully requested NodePublish [%s]", dir))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,8 @@ func TestMounterSetUp(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mounter.SetUp()
|
// Mounter.SetUp()
|
||||||
if err := csiMounter.SetUp(nil); err != nil {
|
fsGroup := int64(2000)
|
||||||
|
if err := csiMounter.SetUp(&fsGroup); err != nil {
|
||||||
t.Fatalf("mounter.Setup failed: %v", err)
|
t.Fatalf("mounter.Setup failed: %v", err)
|
||||||
}
|
}
|
||||||
path := csiMounter.GetPath()
|
path := csiMounter.GetPath()
|
||||||
|
Loading…
Reference in New Issue
Block a user