Lorenzo Faresin 2021-08-16 15:44:42 +02:00
parent cb203b4a46
commit 007787405d
1 changed files with 21 additions and 17 deletions

View File

@ -112,26 +112,30 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi
createMode := os.FileMode(0777) createMode := os.FileMode(0777)
annotationCreateMode, exists := metadata.annotations["nfs.io/createMode"] annotationCreateMode, exists := metadata.annotations["nfs.io/createMode"]
if exists { if exists {
annotationCreateModeUInt, _ := strconv.ParseUint(annotationCreateMode, 8, 32) annotationCreateModeUInt, err := strconv.ParseUint(annotationCreateMode, 8, 32)
createMode = os.FileMode(annotationCreateModeUInt) if err != nil {
} glog.Warningf("nfs.io/createMode %s not parsable, skipped", annotationCreateMode)
} else {
createMode = os.FileMode(annotationCreateModeUInt)
}
}
createUID := "0" createUID := "0"
annotationCreateUID, exists := metadata.annotations["nfs.io/createUID"] annotationCreateUID, exists := metadata.annotations["nfs.io/createUID"]
if exists { if exists {
createUID = annotationCreateUID createUID = annotationCreateUID
} }
createGID := "0" createGID := "0"
annotationCreateGID, exists := metadata.annotations["nfs.io/createGID"] annotationCreateGID, exists := metadata.annotations["nfs.io/createGID"]
if exists { if exists {
createGID = annotationCreateGID createGID = annotationCreateGID
} }
uid, _ := strconv.Atoi(createUID) uid, _ := strconv.Atoi(createUID)
gid, _ := strconv.Atoi(createGID) gid, _ := strconv.Atoi(createGID)
glog.V(4).Infof("creating path %s with %#o mode, %d UID, %d GID", fullPath, createMode, uid, gid) 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 { if err := os.MkdirAll(fullPath, createMode); err != nil {
return nil, controller.ProvisioningFinished, errors.New("unable to create directory to provision new pv: " + err.Error()) return nil, controller.ProvisioningFinished, errors.New("unable to create directory to provision new pv: " + err.Error())
} }