-
Notifications
You must be signed in to change notification settings - Fork 33
Bug 1943378: Fix InstanceCreate volume cleanup #191
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
Bug 1943378: Fix InstanceCreate volume cleanup #191
Conversation
|
@pierreprinetti: This pull request references Bugzilla bug 1943378, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
@openshift-ci[bot]: GitHub didn't allow me to request PR reviews from the following users: eurijon. Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
bbef234 to
f161d8c
Compare
| } | ||
|
|
||
| // Turn off deferred cleanup | ||
| instanceCreateSuccessful = true |
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.
Typically you don't want to "disable" a destructive action in the happy path, but want to do it the other way around: enable the cleanup when something goes wrong.
One easy way to do it would be to rename the variable to something like needVolumeCleanup and set it to true while handling the server creation failure. This also has the nice side effect of removing the negative condition in the cleanup check (easier to read).
8038781 to
42bd7c7
Compare
42bd7c7 to
ba4c79c
Compare
|
Is it a bit clearer now? I don't dislike comments by the way. |
ba4c79c to
944f18a
Compare
| func (is *InstanceService) InstanceCreate(clusterName string, name string, clusterSpec *openstackconfigv1.OpenstackClusterProviderSpec, config *openstackconfigv1.OpenstackProviderSpec, cmd string, keyName string, configClient configclient.ConfigV1Interface) (instance *Instance, err error) { | ||
| // This variable is used in early returns to trigger the deletion of | ||
| // associated resources in case of failure to create the server. | ||
| needsCleanup := true |
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.
Why initializing needsCleanup to true? Initially, we don't need cleanup - it's only after failing to provision the node.
944f18a to
46d9b4c
Compare
With this change, the volume cleanup is triggered by any early failure of InstanceCreate. That is to say: if InstanceCreate creates a volume, that volume will be deleted if any of the next steps fail and cause the server never to be created.
46d9b4c to
b44d7d7
Compare
|
@pierreprinetti: This pull request references Bugzilla bug 1943378, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
@openshift-ci[bot]: GitHub didn't allow me to request PR reviews from the following users: eurijon. Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
mandre
left a comment
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.
/lgtm
/hold pending CI
|
Clarified out-of-band. I have changed the commit (and PR) description to explain the problem I'm trying to solve, then reset to a version @mandre and I found more talkative. Then seasoned with comments. |
|
/hold cancel |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mandre The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@pierreprinetti: All pull requests linked via external trackers have merged: Bugzilla bug 1943378 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
* improve generator readme * add prerequisites section * improve readme
With this change, the volume cleanup is triggered by any early failure
of InstanceCreate. That is to say: if InstanceCreate creates a volume,
that volume will be deleted if any of the next steps fail and cause the
server never to be created.