Skip to content
This repository has been archived by the owner on Nov 20, 2021. It is now read-only.

Commit

Permalink
Add chmod on start
Browse files Browse the repository at this point in the history
Etcd 3.4.9 introduced a check on the data directory permissions that
require 0700. Since this causes the server to not come up we will
attempt to change the perms.
  • Loading branch information
ChrisRx committed Jul 13, 2020
1 parent a5c6605 commit 15cd873
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/manager/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ func (s *server) startEtcd(ctx context.Context, state string, peers []*Peer) err
if err := os.MkdirAll(cfg.Dir, 0700); err != nil && !os.IsExist(err) {
return errors.Wrapf(err, "cannot create etcd data dir: %#v", cfg.Dir)
}

// NOTE(chrism): etcd 3.4.9 introduced a check on the data directory
// permissions that require 0700. Since this causes the server to not come
// up we will attempt to change the perms.
log.Info("chmod data dir", zap.String("dir", s.cfg.Dir))
if err := os.Chmod(cfg.Dir, 0700); err != nil {
log.Error("chmod failed", zap.String("dir", s.cfg.Dir), zap.Error(err))
}
cfg.Logger = "zap"
cfg.Debug = s.cfg.Debug
cfg.ZapLoggerBuilder = func(c *embed.Config) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/snapshot/snapshot_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type FileSnapshotter struct {
}

func NewFileSnapshotter(path string) (*FileSnapshotter, error) {
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil && !os.IsExist(err) {
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil && !os.IsExist(err) {
return nil, errors.Wrapf(err, "cannot create snapshot directory: %#v", filepath.Dir(path))
}
return &FileSnapshotter{file: path}, nil
Expand Down

0 comments on commit 15cd873

Please sign in to comment.