Use JoinPath() and relative paths

Use JoinPath() in newActionsRequest() and make sure we pass relative
paths to it. This should fix scale sets on GHES.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2025-07-06 19:22:43 +00:00
parent 379c39095e
commit 18902f884a
3 changed files with 3 additions and 16 deletions

View file

@ -45,14 +45,8 @@ func (s *ScaleSetClient) GenerateJitRunnerConfig(ctx context.Context, runnerName
return params.RunnerScaleSetJitRunnerConfig{}, fmt.Errorf("failed to ensure admin info: %w", err)
}
serviceURL, err := s.actionsServiceInfo.GetURL()
if err != nil {
return params.RunnerScaleSetJitRunnerConfig{}, fmt.Errorf("failed to get pipeline URL: %w", err)
}
jitConfigPath := fmt.Sprintf("/%s/%d/generatejitconfig", scaleSetEndpoint, scaleSetID)
jitConfigURL := serviceURL.JoinPath(jitConfigPath)
req, err := s.newActionsRequest(ctx, http.MethodPost, jitConfigURL.String(), bytes.NewBuffer(body))
jitConfigPath := fmt.Sprintf("%s/%d/generatejitconfig", scaleSetEndpoint, scaleSetID)
req, err := s.newActionsRequest(ctx, http.MethodPost, jitConfigPath, bytes.NewBuffer(body))
if err != nil {
return params.RunnerScaleSetJitRunnerConfig{}, fmt.Errorf("failed to create request: %w", err)
}

View file

@ -31,11 +31,7 @@ func (s *ScaleSetClient) newActionsRequest(ctx context.Context, method, path str
return nil, fmt.Errorf("failed to get pipeline URL: %w", err)
}
uri, err := actionsURI.Parse(path)
if err != nil {
return nil, fmt.Errorf("failed to parse path: %w", err)
}
uri := actionsURI.JoinPath(path)
q := uri.Query()
if q.Get("api-version") == "" {
q.Set("api-version", "6.0-preview")

View file

@ -671,14 +671,11 @@ Loop:
slog.ErrorContext(w.ctx, "error starting listener", "error", err, "consumer_id", w.consumerID)
if canceled := w.sleepWithCancel(2 * time.Second); canceled {
slog.InfoContext(w.ctx, "worker is stopped; exiting keepListenerAlive")
w.mux.Unlock()
return
}
// we failed to start the listener. Try again.
w.mux.Unlock()
continue
}
w.mux.Unlock()
select {
case <-w.quit: