Skip to content

Commit a5a69a8

Browse files
committed
Fix health check url creation
1 parent 5de624c commit a5a69a8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

internal/app/container_manager.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111
"io/fs"
1212
"net/http"
13+
"net/url"
1314
"os"
1415
"path"
1516
"slices"
@@ -524,16 +525,22 @@ func (m *ContainerManager) WaitForHealth(attempts int) error {
524525

525526
var err error
526527
var resp *http.Response
527-
url := m.GetProxyUrl()
528+
proxyUrl, err := url.Parse(m.GetProxyUrl())
529+
if err != nil {
530+
return err
531+
}
528532
if !m.stripAppPath {
529533
// Apps like Streamlit require the app path to be present
530-
url = url + m.app.Path
534+
proxyUrl = proxyUrl.JoinPath(m.app.Path)
531535
}
532536

533-
url += m.health
537+
proxyUrl = proxyUrl.JoinPath(m.health)
538+
if err != nil {
539+
return err
540+
}
534541

535542
for attempt := 1; attempt <= attempts; attempt++ {
536-
resp, err = client.Get(url)
543+
resp, err = client.Get(proxyUrl.String())
537544
statusCode := "N/A"
538545
if err == nil {
539546
if resp.StatusCode == http.StatusOK {
@@ -546,7 +553,7 @@ func (m *ContainerManager) WaitForHealth(attempts int) error {
546553
resp.Body.Close()
547554
}
548555

549-
m.Debug().Msgf("Attempt %d failed on %s : status %s err %s", attempt, url, statusCode, err)
556+
m.Debug().Msgf("Attempt %d failed on %s : status %s err %s", attempt, proxyUrl, statusCode, err)
550557
time.Sleep(1 * time.Second)
551558
}
552559
return err

0 commit comments

Comments
 (0)