Skip to content

Commit

Permalink
provisioner: Use chmod instead of umask
Browse files Browse the repository at this point in the history
umask affects the entire process, while this is clearer
  • Loading branch information
yuvipanda authored and dlorenc committed Sep 27, 2017
1 parent f64234b commit d7bb7c3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/localkube/storage_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"os"
"path"
"syscall"
"time"

"github.com/golang/glog"
Expand Down Expand Up @@ -70,14 +69,15 @@ var _ controller.Provisioner = &hostPathProvisioner{}
func (p *hostPathProvisioner) Provision(options controller.VolumeOptions) (*v1.PersistentVolume, error) {
path := path.Join(p.pvDir, options.PVName)

// Drop our umask to 0 temporarily, so we can actually create the hostpath directory as 0777
// Otherwise it just gets created as 0755, since default umask is 022
oldMask := syscall.Umask(0)
defer syscall.Umask(oldMask)
if err := os.MkdirAll(path, 0777); err != nil {
return nil, err
}

// Explictly chmod created dir, so we know mode is set to 0777 regardless of umask
if err := os.Chmod(path, 0777); err != nil {
return nil, err
}

pv := &v1.PersistentVolume{
ObjectMeta: meta_v1.ObjectMeta{
Name: options.PVName,
Expand Down

0 comments on commit d7bb7c3

Please sign in to comment.