Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions installer/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ func Cloud(c *types.Config, update bool) error {
fmt.Println("Initializing User Auditor database [OK]")
}

fmt.Println("Checking OpenSearch status")

indexURL := "http://localhost:9200/.utm-geoip?pretty"
indexExists, err := utils.CheckIndexExistsWithRetry(indexURL)
if err != nil {
Expand All @@ -228,6 +230,8 @@ func Cloud(c *types.Config, update bool) error {
return err
}
fmt.Println("Initializing OpenSearch [OK]")
} else {
fmt.Println("OpenSearch status [OK]")
}

fmt.Println("Waiting for Backend to be ready. This may take a while.")
Expand Down
4 changes: 4 additions & 0 deletions installer/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ func Master(c *types.Config) error {
fmt.Println("Initializing User Auditor database [OK]")
}

fmt.Println("Checking OpenSearch status")

indexURL := "http://localhost:9200/.utm-geoip?pretty"
indexExists, err := utils.CheckIndexExistsWithRetry(indexURL)
if err != nil {
Expand All @@ -216,6 +218,8 @@ func Master(c *types.Config) error {
return err
}
fmt.Println("Initializing OpenSearch [OK]")
} else {
fmt.Println("OpenSearch status [OK]")
}

fmt.Println("Waiting for Backend to be ready. This may take a while.")
Expand Down
5 changes: 2 additions & 3 deletions installer/utils/elastic.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func CheckIndexExists(url string) (bool, error) {

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

Expand All @@ -41,8 +41,7 @@ func CheckIndexExistsWithRetry(url string) (bool, error) {
return exists, nil
}
lastErr = err
fmt.Printf("Attempt failed: %v. Retrying in %v...\n", err, interval)
time.Sleep(interval)
}
return false, fmt.Errorf("failed after retries: %v", lastErr)
return false, fmt.Errorf("OpenSearch status check failed after retries: %v", lastErr)
}
Loading