Merge pull request #446 from gabriel-samfira/fix-url-composition

Use JoinPath() and relative paths
This commit is contained in:
Gabriel 2025-07-06 22:56:35 +03:00 committed by GitHub
commit e14f3858ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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) return params.RunnerScaleSetJitRunnerConfig{}, fmt.Errorf("failed to ensure admin info: %w", err)
} }
serviceURL, err := s.actionsServiceInfo.GetURL() jitConfigPath := fmt.Sprintf("%s/%d/generatejitconfig", scaleSetEndpoint, scaleSetID)
if err != nil { req, err := s.newActionsRequest(ctx, http.MethodPost, jitConfigPath, bytes.NewBuffer(body))
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))
if err != nil { if err != nil {
return params.RunnerScaleSetJitRunnerConfig{}, fmt.Errorf("failed to create request: %w", err) 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) return nil, fmt.Errorf("failed to get pipeline URL: %w", err)
} }
uri, err := actionsURI.Parse(path) uri := actionsURI.JoinPath(path)
if err != nil {
return nil, fmt.Errorf("failed to parse path: %w", err)
}
q := uri.Query() q := uri.Query()
if q.Get("api-version") == "" { if q.Get("api-version") == "" {
q.Set("api-version", "6.0-preview") 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) slog.ErrorContext(w.ctx, "error starting listener", "error", err, "consumer_id", w.consumerID)
if canceled := w.sleepWithCancel(2 * time.Second); canceled { if canceled := w.sleepWithCancel(2 * time.Second); canceled {
slog.InfoContext(w.ctx, "worker is stopped; exiting keepListenerAlive") slog.InfoContext(w.ctx, "worker is stopped; exiting keepListenerAlive")
w.mux.Unlock()
return return
} }
// we failed to start the listener. Try again. // we failed to start the listener. Try again.
w.mux.Unlock()
continue continue
} }
w.mux.Unlock()
select { select {
case <-w.quit: case <-w.quit: