mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: set bridge scaletest generator timeout per request (#21626)
<!-- If you have used AI to produce some or all of this PR, please ensure you have read our [AI Contribution guidelines](https://coder.com/docs/about/contributing/AI_CONTRIBUTING) before submitting. -->
This commit is contained in:
@@ -92,10 +92,6 @@ type Runner struct {
|
||||
}
|
||||
|
||||
func NewRunner(client *codersdk.Client, cfg Config) *Runner {
|
||||
httpTimeout := cfg.HTTPTimeout
|
||||
if httpTimeout <= 0 {
|
||||
httpTimeout = 30 * time.Second
|
||||
}
|
||||
return &Runner{
|
||||
client: client,
|
||||
cfg: cfg,
|
||||
@@ -103,7 +99,6 @@ func NewRunner(client *codersdk.Client, cfg Config) *Runner {
|
||||
providerStrategy: NewProviderStrategy(cfg.Provider),
|
||||
clock: quartz.NewReal(),
|
||||
httpClient: &http.Client{
|
||||
Timeout: httpTimeout,
|
||||
Transport: newTracingTransport(cfg, http.DefaultTransport),
|
||||
},
|
||||
}
|
||||
@@ -189,6 +184,10 @@ func (r *Runner) makeRequest(ctx context.Context, logger slog.Logger, url, token
|
||||
mode: r.cfg.Mode,
|
||||
})
|
||||
|
||||
// Set timeout per request
|
||||
ctx, cancel := context.WithTimeout(ctx, r.cfg.HTTPTimeout)
|
||||
defer cancel()
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(r.cfg.RequestBody))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("create request: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user