-
-
Notifications
You must be signed in to change notification settings - Fork 323
Fix interactive apply asks in no change situation #945
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
base: main
Are you sure you want to change the base?
Conversation
311c46b to
326113f
Compare
|
@tarrow if when |
|
@yxxhero An excellent question; I'm not certain but my belief is "no". I do not use the preapply hooks but my understanding from https://helmfile.readthedocs.io/en/latest/#hooks is that they are intended to be used for two types of different things:
In the case of 1 there is an argument that user's may expect to have the opportunity to confirm this action. However it seems never to have been the case that the hooks that would be executed are displayed to the user. In this case the user has no idea what they are agreeing to (unlike creating, updating or deleting releases which are printed before hand). If this feature is desired I would probably recommend adding an additional flag ( In case 2 it seems pretty clear that they would want this contextual information printed before being given the decision to make; in this case I believe this patch is an improvement for the user experience |
|
@mumoshu WDYT? |
|
Please let me know if you require anything more from me; if you determine that some other behaviour is desired let me know and I may be able to update the PR in order to facilitate that |
|
@mumoshu ping |
| // Traverse DAG of all the releases so that we don't suffer from false-positive missing dependencies | ||
| st.Releases = selectedAndNeededReleases | ||
|
|
||
| if !interactive || interactive && r.askForConfirmation(confMsg) { |
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.
@tarrow Hey! Thanks for your contribution. I was trying to understand the original issue and your change fully but had no luck so far unfortunately.. .so it would be great if you could clarify a bit!
In short, can't we just inject something like the below here?
if len(releasesToBeUpdated) == 0 && len(releasesToBeDeleted) == 0 {
return true, false, nil
}
(basically L1498-1501)
That way, I think we can fix the original issue without changing the behavior of preapply hooks.
I might have missed something but my mind says preapply hooks should run immediately before applying. Running it before prompting breaks that rule so I'm slightly inclined to not change it's behaviour this way.
BTW, do you have any motivation that you want some hooks to run even before prompting? We could add a new hook point for that, perhaps something like preprompt.
Alterntively, you could just use the existing prepare hook if you want some hooks to be run regardless of if there is any change to be applied.
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.
Hi @mumoshu! Thanks for the reply; sorry for the slow response.
In short, can't we just inject something like the below here?
Yes! I think we can; I'd be very happy with this solution if you are. I have uploaded an updated patch with this change.
For clarity: I don't use any of the pre-apply hooks. I was actually trying to minimise behaviour change.
I noticed in #522 you said that
preapplyis supposed to get triggered even on unmodified releases
I was trying to keep this behaviour. With this new patchset I believe that this will no longer be true. preapply will now not be triggered if there are no unmodified releases. I added this to the commit message any updated the docs. Please do double check that you're happy with this since I don't understand if this change is desired (since I don't use preapply hooks).
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
44541d2 to
9bbad20
Compare
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
@mumoshu could you take a look at the review once more? 🙏 |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
ping |
|
Thanks for the pings to keep this alive. To make it clear the Please do let me know what you think about it; happy to make adjustments or just continue the discussion about what is the most desirable behaviour. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
ping @mumoshu |
|
ping @mumoshu |
|
@tarrow please fix ci issue. |
9bbad20 to
d886a49
Compare
|
@yxxhero Hi! As I mentioned in #945 (comment) I left these failing deliberately to illustrate the changes this PR would make and to confirm that @mumoshu was happy with them
Did the helmfile team decide that you're happy to change this behaviour? If so let me know and I'll update the snapshot :) |
d802031 to
ed9f73a
Compare
|
@mumoshu WDYT? |
|
@mumoshu please will you confirm that you are happy with the changes @tarrow has made so we can move this PR forward? I find it very frustrating having to babysit Thanks |
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.
Pull Request Overview
This PR fixes the behavior of helmfile apply when running in interactive mode with no changes to apply. The main issue was that pre-apply hooks were being skipped when there were no releases to update or delete, and the interactive confirmation prompt was shown even when no changes were needed.
- Moves the early exit condition for no changes to occur before the interactive confirmation check
- Ensures pre-apply hooks always run before asking for confirmation in interactive mode
- Updates documentation to clarify when pre-apply hooks will and won't run
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/app/app.go | Adds early exit condition before interactive check to prevent unnecessary confirmation prompts when no changes are needed |
| docs/index.md | Updates documentation to clarify that preapply hooks won't run if there are no changes for any releases |
|
What is the reason this PR was newer merged? |
0d0193f to
a36fce9
Compare
a36fce9 to
e1ec1cf
Compare
I'm not sure. I've gone ahead and also included the update to a test snapshot that is necessary now these hooks no longer run (in a no diff release). If someone could approve the workflow that would be great :) |
e1ec1cf to
beb15ea
Compare
This commit makes the apply logic exit early in the event there are no changes to releases. I believe this effectively reverts helmfile#522. Updates relevant snapshots Fixes: helmfile#679 Signed-off-by: Thomas Arrow <thomas.arrow@wikimedia.de>
beb15ea to
fcc0d4d
Compare
|
Seems like there were more snapshots that are either new I missed relating to pre-apply hooks. I also updated these. Can someone approve the workflows again please ? |
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.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
docs/index.md
Outdated
|
|
||
| `preapply` hooks are triggered before a release is uninstalled, installed, or upgraded as part of `helmfile apply`. | ||
| This is the ideal event to hook into when you are going to use `helmfile apply` for every kind of change and you want the hook to be triggered regardless of whether the releases have changed or not. Be sure to make each `preapply` hook command idempotent. Otherwise, rerunning helmfile-apply on a transient failure may end up either breaking your cluster, or the hook that runs for the second time will never succeed. | ||
| This is the ideal event to hook into when you are going to use `helmfile apply` for every kind of change and it is acceptable for the hook to be triggered regardless of whether the releases have changed or not (n.b. if there are no changes for any releases then this will not run). Be sure to make each `preapply` hook command idempotent. Otherwise, rerunning helmfile-apply on a transient failure may end up either breaking your cluster, or the hook that runs for the second time will never succeed. |
Copilot
AI
Jan 24, 2026
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.
The documentation is self-contradictory. It first states "it is acceptable for the hook to be triggered regardless of whether the releases have changed or not" but then immediately says "(n.b. if there are no changes for any releases then this will not run)". Consider rewriting this to be clearer. For example: "This is the ideal event to hook into when you are going to use helmfile apply for every kind of change. Note that preapply hooks will only run if at least one release has changes to apply. Be sure to make each preapply hook command idempotent. Otherwise, rerunning helmfile-apply on a transient failure may end up either breaking your cluster, or the hook that runs for the second time will never succeed."
| This is the ideal event to hook into when you are going to use `helmfile apply` for every kind of change and it is acceptable for the hook to be triggered regardless of whether the releases have changed or not (n.b. if there are no changes for any releases then this will not run). Be sure to make each `preapply` hook command idempotent. Otherwise, rerunning helmfile-apply on a transient failure may end up either breaking your cluster, or the hook that runs for the second time will never succeed. | |
| This is the ideal event to hook into when you are going to use `helmfile apply` for every kind of change. Note that `preapply` hooks will only run if at least one release has changes to apply. Be sure to make each `preapply` hook command idempotent. Otherwise, rerunning `helmfile apply` on a transient failure may end up either breaking your cluster, or the hook that runs for the second time will never succeed. |
Code ReviewI've reviewed this PR and have the following observations: SummaryThis PR adds an early exit for Code ChangesThe implementation in if len(releasesToBeUpdated) == 0 && len(releasesToBeDeleted) == 0 {
return true, false, nil
}This correctly exits before the interactive prompt and before preapply hooks run. Concerns1. Breaking change to preapply hooks
2. Documentation contradiction
3. Migration considerations
RecommendationApprove with conditions:
The implementation correctly addresses issue #679 and is technically sound. The main blockers are documentation clarity and confirming the team is comfortable with the preapply behavior change. Overall: LGTM with documentation fix |
|
@tarrow The documentation change in Current text:
This is self-contradictory. I suggest rewriting to:
This is clearer and accurately reflects the new behavior introduced by this PR. |
|
@mumoshu This PR has been waiting for your final approval since September 2023. The implementation correctly addresses issue #679 and follows your suggestion from your review comment on Aug 16, 2023. Would you be able to provide approval or any final feedback needed to move this forward? The community is eagerly awaiting this fix - see comments from @outdooracorn and others. Thanks! |
Clarify conditions under which preapply hooks are triggered to include that they will no longer fire if there is a no-op. Recommended by the maintainer's copilot request
|
@yxxhero Thanks for nudging this along! I've adjusted the docs as you requested from your copilot review |
|
@tarrow fix DCO issue. |
This commit makes the apply logic exit early in the event there are no
changes to releases. I believe this effectively reverts #522.
Updates relevant snapshot
Fixes: #679