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

fix: don't assume driver isn't nil in StepConnect #437

Merged
merged 2 commits into from
Jun 12, 2024

Conversation

lbajolet-hashicorp
Copy link
Contributor

When attempting to cleanup the existing connections to the VSphere cluster, we get the driver from the state shared between all steps in order to run the commands necessary for that.

This can however fail, if the step couldn't succeed for any reason.

Then, if the connection fails and the driver isn't set in the state, when running Cleanup on the connect step, we get the driver from state and cast it to a driver.Driver.
This will make the plugin crash, and so we change how we proceed here, by getting the driver with a GetOk, exiting if it failed to be fetched from state, then casting the result if it was created in state.

This should prevent crashes like those.

Closes: #436

When attempting to cleanup the existing connections to the VSphere
cluster, we get the driver from the state shared between all steps in
order to run the commands necessary for that.

This can however fail, if the step couldn't succeed for any reason.

Then, if the connection fails and the driver isn't set in the state,
when running Cleanup on the connect step, we get the driver from state
and cast it to a driver.Driver.
This will make the plugin crash, and so we change how we proceed here,
by getting the driver with a `GetOk`, exiting if it failed to be fetched
from state, then casting the result if it was created in state.

This should prevent crashes like those.
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

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

LGTM - just let a couple nits for the messages.

@tenthirtyam tenthirtyam changed the title common/connect: don't assume driver isn't nil fix: don't assume driver isn't nil in StepConnect May 30, 2024
Copy link
Member

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: Ryan Johnson <johnsonryan@vmware.com>
@nywilken nywilken merged commit 6fe9830 into main Jun 12, 2024
12 checks passed
@nywilken nywilken deleted the fix_crash_on_connect_cleanup branch June 12, 2024 17:08
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.

Crash when connecting with insecure_connection=false
3 participants