Skip to content

Commit 845d2ef

Browse files
authored
increase opensearch checking timeout and replace verbose logging with more simple and indicative messages (#1085)
1 parent fcac599 commit 845d2ef

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

installer/cloud.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ func Cloud(c *types.Config, update bool) error {
212212
fmt.Println("Initializing User Auditor database [OK]")
213213
}
214214

215+
fmt.Println("Checking OpenSearch status")
216+
215217
indexURL := "http://localhost:9200/.utm-geoip?pretty"
216218
indexExists, err := utils.CheckIndexExistsWithRetry(indexURL)
217219
if err != nil {
@@ -228,6 +230,8 @@ func Cloud(c *types.Config, update bool) error {
228230
return err
229231
}
230232
fmt.Println("Initializing OpenSearch [OK]")
233+
} else {
234+
fmt.Println("OpenSearch status [OK]")
231235
}
232236

233237
fmt.Println("Waiting for Backend to be ready. This may take a while.")

installer/master.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ func Master(c *types.Config) error {
200200
fmt.Println("Initializing User Auditor database [OK]")
201201
}
202202

203+
fmt.Println("Checking OpenSearch status")
204+
203205
indexURL := "http://localhost:9200/.utm-geoip?pretty"
204206
indexExists, err := utils.CheckIndexExistsWithRetry(indexURL)
205207
if err != nil {
@@ -216,6 +218,8 @@ func Master(c *types.Config) error {
216218
return err
217219
}
218220
fmt.Println("Initializing OpenSearch [OK]")
221+
} else {
222+
fmt.Println("OpenSearch status [OK]")
219223
}
220224

221225
fmt.Println("Waiting for Backend to be ready. This may take a while.")

installer/utils/elastic.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func CheckIndexExists(url string) (bool, error) {
3030

3131
// retrying every 5 seconds up to a total duration of 1 minute.
3232
func CheckIndexExistsWithRetry(url string) (bool, error) {
33-
timeout := time.Minute
33+
timeout := 5 * time.Minute
3434
interval := 5 * time.Second
3535
deadline := time.Now().Add(timeout)
3636

@@ -41,8 +41,7 @@ func CheckIndexExistsWithRetry(url string) (bool, error) {
4141
return exists, nil
4242
}
4343
lastErr = err
44-
fmt.Printf("Attempt failed: %v. Retrying in %v...\n", err, interval)
4544
time.Sleep(interval)
4645
}
47-
return false, fmt.Errorf("failed after retries: %v", lastErr)
46+
return false, fmt.Errorf("OpenSearch status check failed after retries: %v", lastErr)
4847
}

0 commit comments

Comments
 (0)