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(terraform): don't init in status handler #6825

Merged
merged 2 commits into from
Feb 8, 2025
Merged

Conversation

eysi09
Copy link
Collaborator

@eysi09 eysi09 commented Feb 6, 2025

What this PR does / why we need it:

Before this fix, we were calling terraform init in the getStatusHandler which is an undesired side effect.

With this refactor we now call it in the prepareEnvironment handler which is were it should be.

Also note that in PR #6706 we changed the provider init flow such that we now always call prepareEnvironment and the getStatusHandler isn't really used any more.

That's why I also removed the call to that handler from the prepareEnvironment function and instead moved the logic there.

It's basically duplicated across both handlers now which is fine because we're removing the status handler in 0.14.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Before this fix, we were calling `terraform init` in the
`getStatusHandler` which is an undesired side effect.

With this refactor we now call it in the `prepareEnvironment` handler
which is were it should be.

Also note that in PR #6706 we changed the provider init flow such that
we now always call `prepareEnvironment` and the `getStatusHandler`
isn't really used any more.

That's why I also removed the call to that handler from the
`prepareEnvironment` function and instead moved the logic there.

It's basically duplicated across both handlers now which is fine because
we're removing the status handler in 0.14.
@eysi09 eysi09 marked this pull request as draft February 7, 2025 08:20
@eysi09 eysi09 marked this pull request as ready for review February 7, 2025 13:08
@eysi09 eysi09 requested a review from twelvemo February 7, 2025 13:09
@twelvemo
Copy link
Collaborator

twelvemo commented Feb 7, 2025

Also note that in PR #6706 we changed the provider init flow such that we now always call prepareEnvironment and the getStatusHandler isn't really used any more.

Just for understanding, did you mean we always call prepareEnvironment and the getEnvironmentStatus handler is not called any longer? The getStatus deploy action handler is still called.

@eysi09
Copy link
Collaborator Author

eysi09 commented Feb 7, 2025

Just for understanding, did you mean we always call prepareEnvironment and the getEnvironmentStatus handler is not called any longer? The getStatus deploy action handler is still called.

This is only on the provider level.

Specifically, when initialising providers we dropped the flow where first we call getEnviromentStatus, then depending on the result call prepareEnvironment.

It was just a needless abstraction that really complicated the whole process and didn't add any value. Now we always call prepareEnvironment and expect it knows what to do and can exit early if needed.

However, we still call the getEnvironmentStatus handler for statusOnly commands but we'll remove this in 0.14 and just return something like unknown for providers in status commands.

But we didn't change anything around the action level life cycle.

Does that answer your question?

@twelvemo
Copy link
Collaborator

twelvemo commented Feb 7, 2025

Just for understanding, did you mean we always call prepareEnvironment and the getEnvironmentStatus handler is not called any longer? The getStatus deploy action handler is still called.

This is only on the provider level.

Specifically, when initialising providers we dropped the flow where first we call getEnviromentStatus, then depending on the result call prepareEnvironment.

It was just a needless abstraction that really complicated the whole process and didn't add any value. Now we always call prepareEnvironment and expect it knows what to do and can exit early if needed.

However, we still call the getEnvironmentStatus handler for statusOnly commands but we'll remove this in 0.14 and just return something like unknown for providers in status commands.

But we didn't change anything around the action level life cycle.

Does that answer your question?

Yes thanks, that's also how i understood it, just wanted to make sure :-)

Copy link
Collaborator

@twelvemo twelvemo left a comment

Choose a reason for hiding this comment

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

👍

@eysi09 eysi09 added this pull request to the merge queue Feb 8, 2025
Merged via the queue into main with commit 3c07295 Feb 8, 2025
40 checks passed
@eysi09 eysi09 deleted the refactor-tf-init branch February 8, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants