Loggers to catch the e2e flake.

release-3.5
Piotr Tabor 2021-05-13 09:09:32 +02:00
parent f2bc5eee91
commit f5c26814ab
2 changed files with 18 additions and 3 deletions

View File

@ -32,7 +32,10 @@ const (
// IsDirWriteable checks if dir is writable by writing and removing a file
// to dir. It returns nil if dir is writable.
func IsDirWriteable(dir string) error {
f := filepath.Join(dir, ".touch")
f, err := filepath.Abs(filepath.Join(dir, ".touch"))
if err != nil {
return err
}
if err := ioutil.WriteFile(f, []byte(""), PrivateFileMode); err != nil {
return err
}

View File

@ -203,8 +203,14 @@ func SelfCert(lg *zap.Logger, dirpath string, hosts []string, selfSignedCertVali
return
}
certPath := filepath.Join(dirpath, "cert.pem")
keyPath := filepath.Join(dirpath, "key.pem")
certPath, err := filepath.Abs(filepath.Join(dirpath, "cert.pem"))
if err != nil {
return
}
keyPath, err := filepath.Abs(filepath.Join(dirpath, "key.pem"))
if err != nil {
return
}
_, errcert := os.Stat(certPath)
_, errkey := os.Stat(keyPath)
if errcert == nil && errkey == nil {
@ -468,6 +474,10 @@ func (info TLSInfo) ServerConfig() (*tls.Config, error) {
return nil, err
}
if info.Logger == nil {
info.Logger = zap.NewNop()
}
cfg.ClientAuth = tls.NoClientCert
if info.TrustedCAFile != "" || info.ClientCertAuth {
cfg.ClientAuth = tls.RequireAndVerifyClientCert
@ -475,6 +485,8 @@ func (info TLSInfo) ServerConfig() (*tls.Config, error) {
cs := info.cafiles()
if len(cs) > 0 {
info.Logger.Info("Loading cert pool", zap.Strings("cs", cs),
zap.Any("tlsinfo", info))
cp, err := tlsutil.NewCertPool(cs)
if err != nil {
return nil, err