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

Commit 15cd873

Browse files
committed
Add chmod on start
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.
1 parent a5c6605 commit 15cd873

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pkg/manager/server.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ func (s *server) startEtcd(ctx context.Context, state string, peers []*Peer) err
201201
if err := os.MkdirAll(cfg.Dir, 0700); err != nil && !os.IsExist(err) {
202202
return errors.Wrapf(err, "cannot create etcd data dir: %#v", cfg.Dir)
203203
}
204+
205+
// NOTE(chrism): etcd 3.4.9 introduced a check on the data directory
206+
// permissions that require 0700. Since this causes the server to not come
207+
// up we will attempt to change the perms.
208+
log.Info("chmod data dir", zap.String("dir", s.cfg.Dir))
209+
if err := os.Chmod(cfg.Dir, 0700); err != nil {
210+
log.Error("chmod failed", zap.String("dir", s.cfg.Dir), zap.Error(err))
211+
}
204212
cfg.Logger = "zap"
205213
cfg.Debug = s.cfg.Debug
206214
cfg.ZapLoggerBuilder = func(c *embed.Config) error {

pkg/snapshot/snapshot_file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type FileSnapshotter struct {
1313
}
1414

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

0 commit comments

Comments
 (0)