Skip to content

Conversation

@pierreprinetti
Copy link
Member

@pierreprinetti pierreprinetti commented Jul 21, 2021

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.

@openshift-ci openshift-ci bot requested review from iamemilio and mdbooth July 21, 2021 13:04
@openshift-ci openshift-ci bot added bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Jul 21, 2021
@openshift-ci
Copy link

openshift-ci bot commented Jul 21, 2021

@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
  • bug is open, matching expected state (open)
  • bug target release (4.9.0) matches configured target release for branch (4.9.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @eurijon

In response to this:

Bug 1943378: Fix InstanceCreate volume cleanup

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
Copy link

openshift-ci bot commented Jul 21, 2021

@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:

@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
  • bug is open, matching expected state (open)
  • bug target release (4.9.0) matches configured target release for branch (4.9.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @eurijon

In response to this:

Bug 1943378: Fix InstanceCreate volume cleanup

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.

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.

}

// Turn off deferred cleanup
instanceCreateSuccessful = true
Copy link
Member

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).

@pierreprinetti pierreprinetti force-pushed the bz1943378-fixup branch 4 times, most recently from 8038781 to 42bd7c7 Compare July 22, 2021 09:20
@pierreprinetti
Copy link
Member Author

pierreprinetti commented Jul 22, 2021

Is it a bit clearer now?

I don't dislike comments by the way.

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
Copy link
Member

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.

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.
@openshift-ci
Copy link

openshift-ci bot commented Jul 22, 2021

@pierreprinetti: This pull request references Bugzilla bug 1943378, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.9.0) matches configured target release for branch (4.9.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @eurijon

In response to this:

Bug 1943378: Fix InstanceCreate volume cleanup

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
Copy link

openshift-ci bot commented Jul 22, 2021

@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:

@pierreprinetti: This pull request references Bugzilla bug 1943378, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.9.0) matches configured target release for branch (4.9.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @eurijon

In response to this:

Bug 1943378: Fix InstanceCreate volume cleanup

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.

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.

Copy link
Member

@mandre mandre left a 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

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 22, 2021
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 22, 2021
@pierreprinetti
Copy link
Member Author

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.

@mandre
Copy link
Member

mandre commented Jul 22, 2021

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 22, 2021
@mandre
Copy link
Member

mandre commented Jul 22, 2021

/approve

@openshift-ci
Copy link

openshift-ci bot commented Jul 22, 2021

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 22, 2021
@openshift-merge-robot openshift-merge-robot merged commit 58f8692 into openshift:master Jul 22, 2021
@openshift-ci
Copy link

openshift-ci bot commented Jul 22, 2021

@pierreprinetti: All pull requests linked via external trackers have merged:

Bugzilla bug 1943378 has been moved to the MODIFIED state.

In response to this:

Bug 1943378: Fix InstanceCreate volume cleanup

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.

@pierreprinetti pierreprinetti deleted the bz1943378-fixup branch July 22, 2021 15:58
pierreprinetti pushed a commit to shiftstack/cluster-api-provider-openstack that referenced this pull request Apr 22, 2024
* improve generator readme

* add prerequisites section

* improve readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants