-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set mode and permissions from PVC annotation (nfs.io/createMode,nfs/createUID,nfs/createGID) #121
Changes from 1 commit
cb203b4
0077874
70f1a83
fe5a8e9
7f8c418
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,11 +110,33 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi | |
} | ||
} | ||
|
||
glog.V(4).Infof("creating path %s", fullPath) | ||
if err := os.MkdirAll(fullPath, 0777); err != nil { | ||
createMode := os.FileMode(0777) | ||
annotationCreateMode, exists := metadata.annotations["nfs.io/createMode"] | ||
if exists { | ||
annotationCreateModeUInt, _ := strconv.ParseUint(annotationCreateMode, 8, 32) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the error here ignored? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
createMode = os.FileMode(annotationCreateModeUInt) | ||
} | ||
|
||
createUID := "0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. root:root is really the default everywhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like the previous pull request behavior |
||
annotationCreateUID, exists := metadata.annotations["nfs.io/createUID"] | ||
if exists { | ||
createUID = annotationCreateUID | ||
} | ||
createGID := "0" | ||
annotationCreateGID, exists := metadata.annotations["nfs.io/createGID"] | ||
if exists { | ||
createGID = annotationCreateGID | ||
} | ||
|
||
uid, _ := strconv.Atoi(createUID) | ||
gid, _ := strconv.Atoi(createGID) | ||
|
||
glog.V(4).Infof("creating path %s with %#o mode, %d UID, %d GID", fullPath, createMode, uid, gid) | ||
if err := os.MkdirAll(fullPath, createMode); err != nil { | ||
return nil, controller.ProvisioningFinished, errors.New("unable to create directory to provision new pv: " + err.Error()) | ||
} | ||
os.Chmod(fullPath, 0777) | ||
os.Chmod(fullPath, createMode) | ||
os.Chown(fullPath, uid, gid) | ||
|
||
pv := &v1.PersistentVolume{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please format this file with
gofmt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed