etcd: Add logs for unusual failures (#13460)

etcd operations, get/put/delete, should be logged when failed
with errors other than not found error. It will make it easier to
see connections issues from MinIO to etcd.
This commit is contained in:
Anis Elleuch 2021-10-18 16:43:04 +01:00 committed by GitHub
parent 838de23357
commit feabd0430c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"github.com/minio/minio/internal/logger"
etcd "go.etcd.io/etcd/client/v3"
)
@ -47,6 +48,7 @@ func saveKeyEtcdWithTTL(ctx context.Context, client *etcd.Client, key string, da
return etcdErrToErr(err, client.Endpoints())
}
_, err = client.Put(timeoutCtx, key, string(data), etcd.WithLease(lease.ID))
logger.LogIf(ctx, err)
return etcdErrToErr(err, client.Endpoints())
}
@ -57,6 +59,7 @@ func saveKeyEtcd(ctx context.Context, client *etcd.Client, key string, data []by
return saveKeyEtcdWithTTL(ctx, client, key, data, opts[0].ttl)
}
_, err := client.Put(timeoutCtx, key, string(data))
logger.LogIf(ctx, err)
return etcdErrToErr(err, client.Endpoints())
}
@ -65,6 +68,7 @@ func deleteKeyEtcd(ctx context.Context, client *etcd.Client, key string) error {
defer cancel()
_, err := client.Delete(timeoutCtx, key)
logger.LogIf(ctx, err)
return etcdErrToErr(err, client.Endpoints())
}
@ -73,6 +77,7 @@ func readKeyEtcd(ctx context.Context, client *etcd.Client, key string) ([]byte,
defer cancel()
resp, err := client.Get(timeoutCtx, key)
if err != nil {
logger.LogIf(ctx, err)
return nil, etcdErrToErr(err, client.Endpoints())
}
if resp.Count == 0 {