Skip to content

Commit

Permalink
prevent mounting of root directory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MiaoZhou committed Mar 31, 2021
1 parent fab8b56 commit b8e2036
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/nfs-subdir-external-provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b8e2036

Please sign in to comment.