Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 6445e1d

Browse files
committed
Exit init loop if client is ready
1 parent b9e81fa commit 6445e1d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

operator/controllers/execution/scan_controller.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -764,16 +764,19 @@ func (r *ScanReconciler) initS3Connection() *minio.Client {
764764
// Initialize minio client object.
765765
var minioClient *minio.Client
766766
const maxRetries = 5
767-
for i := 0; i < 5; i++ {
767+
for i := 0; i < maxRetries; i++ {
768768
client, err := minio.New(fmt.Sprintf("%s:%s", endpoint, port), accessKeyID, secretAccessKey, useSSL)
769-
if err != nil && i < maxRetries-1 {
769+
if err == nil {
770+
minioClient = client
771+
break
772+
}
773+
774+
if i < maxRetries-1 {
770775
r.Log.Info("Could not create minio client to communicate to s3 endpoint", "retiresLeft", maxRetries-i)
771776
time.Sleep(5 * time.Second)
772-
} else if err != nil {
777+
} else {
773778
r.Log.Error(err, "S3 Client init failed repeatedly. Process will exit.")
774779
panic(err)
775-
} else {
776-
minioClient = client
777780
}
778781
}
779782

0 commit comments

Comments
 (0)