Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

fix(sg): acknowledge command execution state to avoid recursion when executing short running commands#64181

Merged
BolajiOlajide merged 7 commits into
mainfrom
bo/fix-watch-func-zero-exit-commands
Jul 31, 2024
Merged

fix(sg): acknowledge command execution state to avoid recursion when executing short running commands#64181
BolajiOlajide merged 7 commits into
mainfrom
bo/fix-watch-func-zero-exit-commands

Conversation

@BolajiOlajide

@BolajiOlajide BolajiOlajide commented Jul 31, 2024

Copy link
Copy Markdown
Contributor

Some commands like the batcheshelper-builder aren't long running commands.
This command is used to build and load an image into docker. The cmd section returns an exit 0. This behavior combined with continueWatchOnExit results in an infinite loop where the process is continually restarted because sg doesn't know that the process has finished executing and isn't a long-running process.

CleanShot.2024-07-31.at.12.10.44.mp4

An example of the behavior is shown below as running sg start batches results in the batcheshelper-builder command continually restarted.

The fix is quite simple, we return an empty receiver channel when the process is done executing so that sg knows it's done and doesn't restart the command unless there's a change.

Test plan

  • Manual testing with go run ./dev/sg start batches doesn't result in an infinite loop anymore.
  • Add unit tests

Changelog

@cla-bot cla-bot Bot added the cla-signed label Jul 31, 2024
@BolajiOlajide BolajiOlajide self-assigned this Jul 31, 2024
@github-actions

Copy link
Copy Markdown
Contributor

💡 Learn more about each section: PR description tips, Test Plan and Changelog.

@BolajiOlajide BolajiOlajide marked this pull request as ready for review July 31, 2024 10:57
Comment thread sg.config.yaml Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed this as part of cleaning up because we do not use this dockerCommand anywhere in sg.

Comment thread dev/sg/internal/run/run.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved this further down so we can handle restarts before trying to rerun the command.

@BolajiOlajide BolajiOlajide requested a review from a team July 31, 2024 11:44
@BolajiOlajide BolajiOlajide force-pushed the bo/fix-watch-func-zero-exit-commands branch from 7d17bcb to 9da5d6f Compare July 31, 2024 17:03
@BolajiOlajide BolajiOlajide merged commit 776701b into main Jul 31, 2024
@BolajiOlajide BolajiOlajide deleted the bo/fix-watch-func-zero-exit-commands branch July 31, 2024 21:09
@bahrmichael

Copy link
Copy Markdown
Contributor

Thank you 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants