Skip to content

Commit d6ef382

Browse files
committed
Ignore context cancelation error
1 parent b966ef2 commit d6ef382

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

integration-tests/pkg/executor/executor_cri.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func (c *criExecutor) GetContainerStats(ctx context.Context, containerID string)
294294

295295
stats, err := c.runtimeService.ContainerStats(ctx, containerID)
296296
if err != nil {
297-
return nil, fmt.Errorf("error getting container stats: %w", err)
297+
return nil, err
298298
}
299299

300300
return &ContainerStat{

integration-tests/pkg/executor/executor_docker_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (d *dockerAPIExecutor) GetContainerStats(ctx context.Context, containerID s
9999
// instructs the server to get a single stat, rather than waiting for more.
100100
statsResp, err := d.client.ContainerStatsOneShot(ctx, containerID)
101101
if err != nil {
102-
return nil, fmt.Errorf("error getting container stats: %w", err)
102+
return nil, err
103103
}
104104

105105
var stats container.StatsResponse

integration-tests/suites/base.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ func (s *IntegrationTestSuiteBase) SnapshotContainerStats() {
197197
}
198198

199199
stat, err := s.Executor().GetContainerStats(s.statsCtx, s.Collector().ContainerID())
200-
if err != nil {
200+
201+
// The stats context will be canceled at the end of the test. If it happens
202+
// while the request is in flight, ignore the error.
203+
if err != nil && err != context.Canceled {
201204
assert.FailNowf(s.T(), "fail to get container stats", "%v", err)
202205
return
203206
}

0 commit comments

Comments
 (0)