From b8c46205537fbfe6b8f167ed54f7364f658c63a5 Mon Sep 17 00:00:00 2001 From: Gary Date: Fri, 14 Jun 2024 13:04:37 +0800 Subject: [PATCH] chore(kb): add minio debug log (#25) Because we need more minio connection info when fails This commit adds the log --- cmd/main/main.go | 2 +- pkg/minio/minio.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/main/main.go b/cmd/main/main.go index c05c454..1f2f6b4 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -180,7 +180,7 @@ func main() { repository := repository.NewRepository(db) // Initialize Minio client - minioClient, err := minio.NewMinioClientAndInitBucket() + minioClient, _ := minio.NewMinioClientAndInitBucket() service := service.NewService(repository, minioClient, mgmtPrivateServiceClient, httpclient.NewRegistryClient(ctx)) diff --git a/pkg/minio/minio.go b/pkg/minio/minio.go index 48499a1..d5ebf2d 100644 --- a/pkg/minio/minio.go +++ b/pkg/minio/minio.go @@ -31,8 +31,13 @@ func NewMinioClientAndInitBucket() (*Minio, error) { if err != nil { return nil, err } - client, err := minio.New(cfg.Host+":"+cfg.Port, cfg.RootUser, cfg.RootUser, false) + client, err := minio.New(cfg.Host+":"+cfg.Port, cfg.RootUser, cfg.RootPwd, false) if err != nil { + // log connection error + log.Error("cannot connect to minio", + zap.String("host:port", cfg.Host+":"+cfg.Port), + zap.String("user", cfg.RootUser), + zap.String("pwd", cfg.RootPwd), zap.Error(err)) return nil, err } err = client.MakeBucket(cfg.BucketName, "us-east-1")