Summary
HttpClient.Register, SyncStrategy and SyncMetrics (cpdaemon/pkg/cpm/client.go:88, :120, :160) call c.client.Post / c.client.Get, which do not use the ctx they receive. When CPM is slow or unreachable, cancelling the context does not abort the request. cpdaemon's shutdown then waits for the full HTTP client timeout, which is 15 s by default.
Expected
Each call should build its request with http.NewRequestWithContext(ctx, ...) and return promptly with ctx.Err() once the context is cancelled.
Reproduction
TestCPMClient_HonoursContextCancellation/{register,sync_strategy,sync_metrics} in cpdaemon/pkg/cpm/client_contract_test.go. The fake server hangs for 3 s and the context expires after 200 ms; each call returns only when the server responds. The test is registered as a known failure.
Requirement REQ-CPM-CLIENT, verification-coverage round 7.
中文原文
CPM 客户端的三个方法使用 client.Post/Get,没有把 ctx 传给请求,取消不生效;CPM 慢或不可达时,关闭需要等满 HTTP 超时(默认 15 s)。应改用 http.NewRequestWithContext。
Summary
HttpClient.Register,SyncStrategyandSyncMetrics(cpdaemon/pkg/cpm/client.go:88, :120, :160) callc.client.Post/c.client.Get, which do not use thectxthey receive. When CPM is slow or unreachable, cancelling the context does not abort the request. cpdaemon's shutdown then waits for the full HTTP client timeout, which is 15 s by default.Expected
Each call should build its request with
http.NewRequestWithContext(ctx, ...)and return promptly withctx.Err()once the context is cancelled.Reproduction
TestCPMClient_HonoursContextCancellation/{register,sync_strategy,sync_metrics}incpdaemon/pkg/cpm/client_contract_test.go. The fake server hangs for 3 s and the context expires after 200 ms; each call returns only when the server responds. The test is registered as a known failure.Requirement REQ-CPM-CLIENT, verification-coverage round 7.
中文原文
CPM 客户端的三个方法使用
client.Post/Get,没有把 ctx 传给请求,取消不生效;CPM 慢或不可达时,关闭需要等满 HTTP 超时(默认 15 s)。应改用http.NewRequestWithContext。