Skip to content

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

Merged
nywilken merged 2 commits intomainfrom
fix_crash_on_connect_cleanup
Jun 12, 2024
Merged

fix: don't assume driver isn't nil in StepConnect#437
nywilken merged 2 commits intomainfrom
fix_crash_on_connect_cleanup

Conversation

@lbajolet-hashicorp
Copy link
Copy Markdown
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.
@lbajolet-hashicorp lbajolet-hashicorp requested a review from a team as a code owner May 17, 2024 14:48
@tenthirtyam tenthirtyam self-requested a review May 17, 2024 15:52
@tenthirtyam tenthirtyam added this to the v1.3.1 milestone May 17, 2024
Copy link
Copy Markdown
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
Copy Markdown
Contributor

@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
@nywilken nywilken deleted the fix_crash_on_connect_cleanup branch June 12, 2024 17:08
@vmware vmware locked as resolved and limited conversation to collaborators Jun 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when connecting with insecure_connection=false

3 participants