-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
detect cycle in cli custom commands #765
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Pulak Kanti Bhowmick <[email protected]>
Signed-off-by: Pulak Kanti Bhowmick <[email protected]>
This is not wrong, but we still need to catch when atmos is executing atmos in a free form command. Walking the tree won't help with that. The only practical way is to set an environment variable for the sub command and increment it. We should allow some level of recursion, just not infinite. |
📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThe changes introduce a cycle detection mechanism for custom CLI commands in the Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info @osterman . I'll change accordingly |
Hi @osterman |
Signed-off-by: Pulak Kanti Bhowmick <[email protected]>
Only if we know conclusively, without a doubt, that it will result in infinite recursion. The problem I foresee is it we cannot easily determine anything conclusively. That is my way of saying, we probably need to allow for some recursion before triggering the circuit breaker. |
Signed-off-by: Pulak Kanti Bhowmick <[email protected]>
This reverts commit 41dd885.
Signed-off-by: Pulak Kanti Bhowmick <[email protected]>
I might be wrong but I have found that from code the command is run once. When there is a cycle and the command reaches to shell. Shell automatically runs that cyclic command. I have found no way to control it from code. That's why I am proposing a way to let the user know about the cycle and run/exit command based on user input. cc: @osterman |
Signed-off-by: Pulak Kanti Bhowmick <[email protected]>
This reverts commit 3498b40.
Please provide more technical details. This is conventional behavior of task runner functionality, and not something novel we are attempting to implement. |
As far as I can tell, this implementation never sets an environment variable, and that environment variable, therefore never passed to the recursive shell. Therefore, there is no circuit breaker. This is attempting strictly to implement a circuit breaker using the YAML definition, which is going be very complicated please implement the circuit breaker using an environment variable |
It is similar in principle to what we have going on in this other Pool request to send the Shell level. The difference is that at a certain depth we should fatally exit. |
Hi @osterman |
While trying this way, I have found we are submitting all the steps to a shell runner. https://github.com/cloudposse/atmos/blob/main/internal/exec/shell_utils.go#L77-L93 Now if we want to control the way of execution of cyclic custom command, we need to do something here. So far I don't find a way |
Simply check the ATMOS_SHLVL is not greater than some maximum (e.g. 10). If it is greater log a fatal error. Otherwise, increment the ATMOS_SHLVL envar before execution, and ensure the envar is passed to the command. If this doesn't work, then submit an example of why not, or there's no feedback that can be given. |
Based on the lines you provided, why can't we do something like:
|
In my testing, I have found this Execute shell command only runs once even for a loop |
What we want to catch is atmos calling atmos, infinitely. It is true that it only runs in once per command, but if that command is literally executing atmos, it will executed recursively. The case I am thinking of right now, is when the type is “shell” and not “atmos”. Start with this and worry about type atmos later. We want to catch this inside of workflow and custom commands. The first step would be to add some test cases where we do this, under example/tests. If you add that to this PR, I can review the test case you are using and better understand the behavior you are seeing. |
Yes, that would create an infinite loop! So in this case, when atmos executes:
It would first increment, and pass Then when |
Checking |
what
why
references
Summary by CodeRabbit
New Features
Bug Fixes
Documentation