Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #12018 #12112

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions etcdmain/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,9 @@ func startProxy(cfg *config) error {
}

cfg.ec.Dir = filepath.Join(cfg.ec.Dir, "proxy")
if fileutil.Exist(cfg.ec.Dir) {
err = fileutil.CheckDirPermission(cfg.ec.Dir, fileutil.PrivateDirMode)
if err != nil {
return err
}
} else {
err = os.MkdirAll(cfg.ec.Dir, fileutil.PrivateDirMode)
if err != nil {
return err
}
err = fileutil.TouchDirAll(cfg.ec.Dir)
if err != nil {
return err
}

var peerURLs []string
Expand Down
18 changes: 9 additions & 9 deletions pkg/transport/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,17 @@ func (info TLSInfo) Empty() bool {
}

func SelfCert(lg *zap.Logger, dirpath string, hosts []string, additionalUsages ...x509.ExtKeyUsage) (info TLSInfo, err error) {
if fileutil.Exist(dirpath) {
err = fileutil.CheckDirPermission(dirpath, fileutil.PrivateDirMode)
if err != nil {
return
}
} else {
if err = os.MkdirAll(dirpath, fileutil.PrivateDirMode); err != nil {
return
info.Logger = lg
err = fileutil.TouchDirAll(dirpath)
if err != nil {
if info.Logger != nil {
info.Logger.Warn(
"cannot create cert directory",
zap.Error(err),
)
}
return
}
info.Logger = lg

certPath := filepath.Join(dirpath, "cert.pem")
keyPath := filepath.Join(dirpath, "key.pem")
Expand Down