Skip to content

Conversation

vflaux
Copy link
Contributor

@vflaux vflaux commented Sep 8, 2025

What does it do ?

Fix a race condition between the signal handler setup and the signal send in the test for handleSigterm().

In the test, in rare case the SIGTERM signal could be send before the handleSigterm() calls signal.Notify().

In this case, the cancel function is never called.

The test always pass because it silently ignore this with the select case sig := <-sigChan.

I think we need to test that the signal received is a SIGTERM and that the cancel func has been called. Not one of the two conditions.

Motivation

This primarily concerns testing and ensuring correctness. There is most likely no issue when the controller run.

I could reproduce this with go test -timeout 30s -count 1000 -run ^TestHandleSigterm$ sigs.k8s.io/external-dns/controller after removing the sig := <-sigChan select case in the current code.

Found this when trying to understand this race condition report: https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_external-dns/5810/pull-external-dns-unit-test/1963995845443457024

Not sure if this would fix as I'm not able to reproduce it.

More

  • Yes, this PR title follows Conventional Commits
  • Yes, I added unit tests
  • Yes, I updated end user documentation accordingly

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 8, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mloiseleur for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the controller Issues or PRs related to the controller label Sep 8, 2025
@k8s-ci-robot k8s-ci-robot requested a review from szuecs September 8, 2025 13:12
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 8, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @vflaux. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 8, 2025
@vflaux vflaux force-pushed the fix_sigterm_handler branch from 09a2b7c to ad9a3b1 Compare September 8, 2025 13:36
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 8, 2025
@vflaux vflaux force-pushed the fix_sigterm_handler branch from ad9a3b1 to b1c4916 Compare September 8, 2025 13:39
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 8, 2025
@vflaux
Copy link
Contributor Author

vflaux commented Sep 8, 2025

Probably not needed if #5798 is merged.

@mloiseleur mloiseleur changed the title fix(controller): race condition in handleSigterm() test test(controller): race condition in handleSigterm() Sep 8, 2025
Fix a race condition between the signal handler setup and the signal
send in the test for handleSigterm()
@vflaux vflaux force-pushed the fix_sigterm_handler branch from b1c4916 to 04b6ada Compare September 19, 2025 15:23
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. controller Issues or PRs related to the controller do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants