Minor localhost/backend check for worker url

This commit is contained in:
Frikky
2023-10-22 23:10:35 +02:00
parent 27c4a17bbc
commit 1285c1f36c
+7 -2
View File
@@ -1818,14 +1818,19 @@ func sendWorkerRequest(workflowExecution shuffle.ExecutionRequest) error {
} }
streamUrl := fmt.Sprintf("http://shuffle-workers:33333/api/v1/execute") streamUrl := fmt.Sprintf("http://shuffle-workers:33333/api/v1/execute")
if (containerId == "" || containerId == "shuffle-orborus") && !strings.Contains(workerServerUrl, "shuffle-backend") { if containerId == "" || containerId == "shuffle-orborus" {
streamUrl = fmt.Sprintf("%s:33333/api/v1/execute", parsedBaseurl) streamUrl = fmt.Sprintf("%s:33333/api/v1/execute", parsedBaseurl)
} }
if len(workerServerUrl) > 0 && !strings.Contains(workerServerUrl, "shuffle-backend") { if len(workerServerUrl) > 0 {
streamUrl = fmt.Sprintf("%s:33333/api/v1/execute", workerServerUrl) streamUrl = fmt.Sprintf("%s:33333/api/v1/execute", workerServerUrl)
} }
if strings.Contains(streamUrl, "localhost") || strings.Contains(streamUrl, "shuffle-backend") {
log.Printf("[INFO] Using default worker server url as previous is invalid: %s", streamUrl)
streamUrl = fmt.Sprintf("http://shuffle-workers:33333/api/v1/execute")
}
client := &http.Client{} client := &http.Client{}
req, err := http.NewRequest( req, err := http.NewRequest(
"POST", "POST",