Sitelet https://github.com/Netis/cloud-probe/issues/265
Skip to content

cpdaemon CPM client ignores context cancellation (shutdown waits for the HTTP timeout) #265

Description

@vaderyang

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。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions