prevent mounting of root directory

If storageClass enable pathPattern like:

`pathPattern: "${.PVC.annotations.nfs.io/storage-path}"`

but pvc without annotation would make empty `customPath` and create a pv with nfs root path.
This commit is contained in:
zhoumiao 2021-03-31 21:23:20 +08:00
parent fab8b5623e
commit b8e203661b
1 changed files with 4 additions and 2 deletions

View File

@ -104,8 +104,10 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi
pathPattern, exists := options.StorageClass.Parameters["pathPattern"]
if exists {
customPath := metadata.stringParser(pathPattern)
path = filepath.Join(p.path, customPath)
fullPath = filepath.Join(mountPath, customPath)
if customPath != "" {
path = filepath.Join(p.path, customPath)
fullPath = filepath.Join(mountPath, customPath)
}
}
glog.V(4).Infof("creating path %s", fullPath)