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

refactor: move autoremove into the jobexecutor #1463

Merged
merged 6 commits into from
Dec 6, 2022
Merged

Conversation

ChristopherHX
Copy link
Contributor

breaking: docker container are removed after job exit

In github-act-runner I directly instantiate the RunContext, but I also want to make use of autoremove due to randomized job container name.

breaking: docker container are removed after job exit
@ChristopherHX ChristopherHX requested a review from a team as a code owner November 24, 2022 20:54
@mergify
Copy link
Contributor

mergify bot commented Nov 24, 2022

@ChristopherHX this pull request has failed checks 🛠

@mergify mergify bot added the needs-work Extra attention is needed label Nov 24, 2022
@mergify
Copy link
Contributor

mergify bot commented Nov 24, 2022

@ChristopherHX this pull request has failed checks 🛠

@codecov
Copy link

codecov bot commented Nov 24, 2022

Codecov Report

Merging #1463 (c35950b) into master (4f8da0a) will increase coverage by 3.08%.
The diff coverage is 66.94%.

@@            Coverage Diff             @@
##           master    #1463      +/-   ##
==========================================
+ Coverage   57.50%   60.59%   +3.08%     
==========================================
  Files          32       44      +12     
  Lines        4594     6991    +2397     
==========================================
+ Hits         2642     4236    +1594     
- Misses       1729     2451     +722     
- Partials      223      304      +81     
Impacted Files Coverage Δ
pkg/common/file.go 0.00% <0.00%> (ø)
pkg/container/docker_logger.go 52.08% <ø> (ø)
pkg/container/host_environment.go 0.00% <0.00%> (ø)
pkg/container/util.go 0.00% <0.00%> (ø)
pkg/model/action.go 0.00% <0.00%> (ø)
pkg/model/step_result.go 0.00% <ø> (ø)
pkg/container/docker_run.go 12.82% <11.53%> (+7.27%) ⬆️
pkg/model/workflow.go 45.65% <23.58%> (-5.26%) ⬇️
...ontainer/linux_container_environment_extensions.go 24.32% <24.32%> (ø)
pkg/container/docker_pull.go 33.33% <33.33%> (ø)
... and 37 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2022

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ EDITORCONFIG editorconfig-checker 2 0 0.01s
✅ REPOSITORY gitleaks yes no 2.43s
✅ REPOSITORY git_diff yes no 0.0s
✅ REPOSITORY secretlint yes no 1.01s

See errors details in artifact MegaLinter reports on CI Job page
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@mergify mergify bot removed the needs-work Extra attention is needed label Nov 24, 2022
logger.WithField("jobResult", "success").Infof("\U0001F3C1 Job succeeded")
var err error
if rc.Config.AutoRemove || jobError == nil {
err = info.stopContainer()(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

This will fail if the job was canceled before (e.g. by os signal).
Please make sure that a fallback context is used in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the code to allow docker 1min for closing / removing the runner. Should be safe now.

Additionally I now reuse the existing joblogger instead of creating one. I always want to use my own logger provided to the RunContext executor.

Do we want to add a forceCancel context as field to the context, so we can force quit act by pressing ctrl+c twice? This could be the parent context of the context with a timeout.

Needs to be tested manually, I don't think we have tests for cancelling act.

Copy link
Member

Choose a reason for hiding this comment

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

Do we want to add a forceCancel context as field to the context, so we can force quit act by pressing ctrl+c twice? This could be the parent context of the context with a timeout.

That was the case before. The BackgroundContext used as a fallback was cancelable as well. That would then cancel/stop the cleanup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the case before. The BackgroundContext used as a fallback was cancelable as well. That would then cancel/stop the cleanup.

I want both a normal cancel with cleanup and additionally the opportunity to send another cancellation signal to abort cleanup and quit as soon as possible.
Previously we had one of them, but never both at the same time.
For Example this scenario

  • Start a long running job
  • cancel the normal context it while it executes the main stage
  • A new context for the post executors is created
  • This job has a long runnng post step
  • cancel again this time force cancel context, because I don't want to wait otherwise I have to open the task manager and kill act.
  • act stopped before hit 5min

Your CI system could just never fire the forcecancel context and you have an opt out.

Copy link
Member

Choose a reason for hiding this comment

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

I understood and I'm fine with that.
I just thought that it did work before, as a second cancelation was respected by act (if I remember correctly).

@mergify mergify bot requested a review from a team November 25, 2022 08:56
Copy link
Member

@KnisterPeter KnisterPeter left a comment

Choose a reason for hiding this comment

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

I will do some tests before approving, but the code looks fine now for me

@mergify mergify bot requested a review from a team November 25, 2022 10:07
Copy link
Member

@KnisterPeter KnisterPeter left a comment

Choose a reason for hiding this comment

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

Works as expected

@mergify mergify bot merged commit d9fe63e into master Dec 6, 2022
@mergify mergify bot deleted the refactor-autoremove branch December 6, 2022 15:45
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.

None yet

3 participants