Skip to content

Commit

Permalink
chore: add meaningful logs to client initialization. (#10801)
Browse files Browse the repository at this point in the history
Signed-off-by: Humair Khan <HumairAK@users.noreply.github.com>
  • Loading branch information
HumairAK authored May 9, 2024
1 parent 3da46b6 commit 92046be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions backend/src/apiserver/client/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func CreateMinioClient(minioServiceHost string, minioServicePort string,
cred := createCredentialProvidersChain(endpoint, accessKey, secretKey)
minioClient, err := minio.NewWithCredentials(endpoint, cred, secure, region)
if err != nil {
return nil, errors.Wrapf(err, "Error while creating minio client: %+v", err)
return nil, errors.Wrapf(err, "Error while creating object store client: %+v", err)
}
return minioClient, nil
}
Expand All @@ -74,7 +74,7 @@ func CreateMinioClientOrFatal(minioServiceHost string, minioServicePort string,
b.MaxElapsedTime = initConnectionTimeout
err = backoff.Retry(operation, b)
if err != nil {
glog.Fatalf("Failed to create Minio client. Error: %v", err)
glog.Fatalf("Failed to create object store client. Error: %v", err)
}
return minioClient
}
Expand Down
12 changes: 7 additions & 5 deletions backend/src/apiserver/client_manager/client_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ func (c *ClientManager) Authenticators() []auth.Authenticator {

func (c *ClientManager) init() {
glog.Info("Initializing client manager")
glog.Info("Initializing DB client...")
db := InitDBClient(common.GetDurationConfig(initConnectionTimeout))
db.SetConnMaxLifetime(common.GetDurationConfig(dbConMaxLifeTime))

glog.Info("DB client initialized successfully")
// time
c.time = util.NewRealTime()

Expand All @@ -185,8 +186,9 @@ func (c *ClientManager) init() {
c.resourceReferenceStore = storage.NewResourceReferenceStore(db)
c.dBStatusStore = storage.NewDBStatusStore(db)
c.defaultExperimentStore = storage.NewDefaultExperimentStore(db)
glog.Info("Initializing Object store client...")
c.objectStore = initMinioClient(common.GetDurationConfig(initConnectionTimeout))

glog.Info("Object store client initialized successfully")
// Use default value of client QPS (5) & burst (10) defined in
// k8s.io/client-go/rest/config.go#RESTClientFor
clientParams := util.ClientParameters{
Expand Down Expand Up @@ -494,10 +496,10 @@ func initMinioClient(initConnectionTimeout time.Duration) storage.ObjectStoreInt
}

func createMinioBucket(minioClient *minio.Client, bucketName, region string) {
// Check to see if we already own this bucket.
// Check to see if it exists, and we have permission to access it.
exists, err := minioClient.BucketExists(bucketName)
if err != nil {
glog.Fatalf("Failed to check if Minio bucket exists. Error: %v", err)
glog.Fatalf("Failed to check if object store bucket exists. Error: %v", err)
}
if exists {
glog.Infof("We already own %s\n", bucketName)
Expand All @@ -506,7 +508,7 @@ func createMinioBucket(minioClient *minio.Client, bucketName, region string) {
// Create bucket if it does not exist
err = minioClient.MakeBucket(bucketName, region)
if err != nil {
glog.Fatalf("Failed to create Minio bucket. Error: %v", err)
glog.Fatalf("Failed to create object store bucket. Error: %v", err)
}
glog.Infof("Successfully created bucket %s\n", bucketName)
}
Expand Down

0 comments on commit 92046be

Please sign in to comment.