Skip to content

test: fix goleak check in combination with script tests#44228

Merged
giorio94 merged 1 commit intocilium:mainfrom
giorio94:mio/goleak-scripttest
Feb 16, 2026
Merged

test: fix goleak check in combination with script tests#44228
giorio94 merged 1 commit intocilium:mainfrom
giorio94:mio/goleak-scripttest

Conversation

@giorio94
Copy link
Copy Markdown
Member

@giorio94 giorio94 commented Feb 6, 2026

Currently, multiple script tests are intended to validate that no goroutines are leaked once the tests end, deferring the invocation of the dedicated [testutils.GoleakVerifyNone] function. However, the underlying [goleak.VerifyNone] utility is incompatible with t.Parallel [1], which is set by default by script tests, and no check is actually performed.

Let's get this fixed by using [goleak.VerifyTestMain] instead, as also suggested by goleak documentation itself. This commit fixes all occurrences spotted via:

$ git grep -l GoleakVerifyNone | xargs grep -l testdata

It is worth additionally mentioning that:

  • GoleakVerifyTestMain was already invoked in the redirectpolicy package, and is thus not added;
  • The functions previously ignored in the devices_controller tests do not appear to be necessary anymore, and have been omitted; yet, we need to additionally ignore one metrics related goroutine that is otherwise flagged when IPSec is enabled;
  • One of the script tests in the route/reconciler package did not correctly stop the hive, causing a few goroutines to be leaked.

Ideally we should have a linter to catch this problem directly in CI, but that's deferred for the future.

[1]: https://pkg.go.dev/go.uber.org/goleak#VerifyNone

Tentatively marked for backport to v1.19 as well, given that it is a test only change.

@giorio94 giorio94 added the release-note/misc This PR makes changes that have no direct user impact. label Feb 6, 2026
@giorio94 giorio94 requested review from a team as code owners February 6, 2026 13:37
@giorio94
Copy link
Copy Markdown
Member Author

giorio94 commented Feb 6, 2026

/ci-integration

@giorio94 giorio94 added the needs-backport/1.19 This PR / issue needs backporting to the v1.19 branch label Feb 6, 2026
@giorio94
Copy link
Copy Markdown
Member Author

giorio94 commented Feb 6, 2026

/test

@giorio94
Copy link
Copy Markdown
Member Author

giorio94 commented Feb 6, 2026

Conformance Runtime seems to have failed due to a legitimate goleak in the linux package (that obviously I didn't manage to trigger when testing locally). Will double-check later.

@giorio94 giorio94 force-pushed the mio/goleak-scripttest branch from cbf99fc to cf67130 Compare February 6, 2026 17:24
@giorio94
Copy link
Copy Markdown
Member Author

giorio94 commented Feb 6, 2026

[...] (that obviously I didn't manage to trigger when testing locally).

Build tags hit again, should be fixed now.

@giorio94
Copy link
Copy Markdown
Member Author

giorio94 commented Feb 6, 2026

/test

Copy link
Copy Markdown
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this great finding and for all the details helping understanding the fix! :D

Copy link
Copy Markdown
Member

@tklauser tklauser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Copy Markdown
Member

@dylandreimerink dylandreimerink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for my codeowners

@giorio94 giorio94 enabled auto-merge February 10, 2026 09:02
@giorio94
Copy link
Copy Markdown
Member Author

@cilium/envoy @cilium/sig-servicemesh Gentle ping 🙏

@giorio94 giorio94 enabled auto-merge February 12, 2026 14:12
@giorio94
Copy link
Copy Markdown
Member Author

I think GitHub is confused here, because of the codeowners changes that got recently merged. Attempting a rebase.

Currently, multiple script tests are intended to validate that no
goroutines are leaked once the tests end, deferring the invocation
of the dedicated [testutils.GoleakVerifyNone] function. However,
the underlying [goleak.VerifyNone] utility is incompatible with
t.Parallel [1], which is set by default by script tests, and no
check is actually performed.

Let's get this fixed by using [goleak.VerifyTestMain] instead, as
also suggested by goleak documentation itself. This commit fixes all
occurrences spotted via:

$ git grep -l GoleakVerifyNone | xargs grep -l testdata

It is worth additionally mentioning that:

* GoleakVerifyTestMain was already invoked in the redirectpolicy
  package, and is thus not added;
* The functions previously ignored in the devices_controller tests
  do not appear to be necessary anymore, and have been omitted; yet,
  we need to additionally ignore one metrics related goroutine that
  is otherwise flagged when IPSec is enabled;
* One of the script tests in the route/reconciler package did not
  correctly stop the hive, causing a few goroutines to be leaked.

Ideally we should have a linter to catch this problem directly
in CI, but that's deferred for the future.

[1]: https://pkg.go.dev/go.uber.org/goleak#VerifyNone

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
@giorio94 giorio94 force-pushed the mio/goleak-scripttest branch from cf67130 to 50434ce Compare February 12, 2026 14:16
@giorio94 giorio94 requested review from a team as code owners February 12, 2026 14:16
@giorio94
Copy link
Copy Markdown
Member Author

/test

@giorio94 giorio94 added this pull request to the merge queue Feb 16, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Feb 16, 2026
Merged via the queue into cilium:main with commit 8c6252f Feb 16, 2026
84 of 85 checks passed
@giorio94 giorio94 deleted the mio/goleak-scripttest branch February 16, 2026 09:42
@glrf glrf mentioned this pull request Feb 17, 2026
12 tasks
@glrf glrf added backport-pending/1.19 The backport for Cilium 1.19.x for this PR is in progress. and removed needs-backport/1.19 This PR / issue needs backporting to the v1.19 branch labels Feb 17, 2026
@github-actions github-actions bot added backport-done/1.19 The backport for Cilium 1.19.x for this PR is done. and removed backport-pending/1.19 The backport for Cilium 1.19.x for this PR is in progress. labels Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-done/1.19 The backport for Cilium 1.19.x for this PR is done. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants