Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use chan only to notify command is done #5244

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Warashi
Copy link
Contributor

@Warashi Warashi commented Sep 30, 2024

What this PR does / why we need it:

The original IsRunning method has a bug when the command exits with an error.
After the command is done with an error, IsRunning returns true once if GracefulStop is not called.
This comes from using chan error to both pass the result and notify the finish.
This PR splits these things to chan struct{} and atomic.Pointer[error].

Which issue(s) this PR fixes:

The flaky test TestGracefulStopCommand.

Fixes #4630

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

@Warashi
Copy link
Contributor Author

Warashi commented Sep 30, 2024

I'll run the test 5 times and make this PR ready for review if all tests are passed.

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 23.96%. Comparing base (c1a06aa) to head (d10876a).
Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
pkg/app/launcher/cmd/launcher/binary.go 84.61% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5244      +/-   ##
==========================================
+ Coverage   23.95%   23.96%   +0.01%     
==========================================
  Files         437      437              
  Lines       46997    47005       +8     
==========================================
+ Hits        11258    11267       +9     
  Misses      34835    34835              
+ Partials      904      903       -1     
Flag Coverage Δ
23.96% <84.61%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Shinnosuke Sawada-Dazai <[email protected]>
@Warashi
Copy link
Contributor Author

Warashi commented Sep 30, 2024

I realized there are no test for the result of GracefulStop, so I added that.

@Warashi
Copy link
Contributor Author

Warashi commented Sep 30, 2024

I'll run the test 5 times and make this PR ready for review if all tests are passed.

The tests are passed 5 times.

https://github.com/pipe-cd/pipecd/actions/runs/11100844567/job/30838021571

スクリーンショット 2024-09-30 16 07 47

@Warashi Warashi marked this pull request as ready for review September 30, 2024 07:08
@Warashi Warashi changed the title Use chan only to notify command is done to avoid race condition Use chan only to notify command is done Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A unit test is flaky: TestGracefulStopCommand
2 participants