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

[0.1] Delete machines #1180

Merged
merged 10 commits into from
Jul 24, 2019
Merged

Conversation

liztio
Copy link
Contributor

@liztio liztio commented Jul 22, 2019

What this PR does / why we need it:
Some pieces of cluster infrastructure (i.e. VPCs for CAPA) cannot be successfully deleted until after after the machines in the cluster are all deleted. This pull requests blocks cluster deletion until all owned resources are deleted.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #985 but it likely won't fix it until/unless we fix #1190

Special notes for your reviewer:
This only covers Machines, MachineSets, and MachineDeployments

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

Deleting a cluster will block until all owned MachineDeployments, MachineSets, and Machines are deleted. 

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 22, 2019
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 22, 2019
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

Looks good so far! Few comments

pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
@liztio liztio force-pushed the delete-machines branch 5 times, most recently from 2e61dc8 to ca9ee02 Compare July 23, 2019 14:45
@liztio
Copy link
Contributor Author

liztio commented Jul 23, 2019

/assign @ncdc

@ncdc
Copy link
Contributor

ncdc commented Jul 23, 2019

Currently reviewing.

/hold

pending comments

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 23, 2019
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller.go Show resolved Hide resolved
pkg/controller/cluster/cluster_controller_test.go Outdated Show resolved Hide resolved
pkg/controller/cluster/cluster_controller_test.go Outdated Show resolved Hide resolved
@liztio
Copy link
Contributor Author

liztio commented Jul 23, 2019

/test pull-cluster-api-test

2 similar comments
@vincepri
Copy link
Member

/test pull-cluster-api-test

@liztio
Copy link
Contributor Author

liztio commented Jul 24, 2019

/test pull-cluster-api-test

@liztio
Copy link
Contributor Author

liztio commented Jul 24, 2019

well it passes now 🤷‍♀️

pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
for _, child := range children {
accessor, err := meta.Accessor(child)
if err != nil {
return reconcile.Result{}, errors.Wrapf(err, "couldn't create accessor for %T", child)
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that Accessor is unlikely to fail, but I'd still like to include it in errList instead of returning early.

pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
children, err := r.listChildren(context.Background(), cluster)
if err != nil {
klog.Infof("Failed to list dependent objects of cluster %s/%s: %v", cluster.ObjectMeta.Namespace, cluster.ObjectMeta.Name, err)
return reconcile.Result{}, errors.WithStack(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need WithStack and instead we can return err directly because r.listChildren is our function, and it properly wraps/stacks all the errors it returns. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll be honest, I have no idea what WithStack does, I added it because you suggested it a few blocks up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess you only need to add it once?

Copy link
Contributor

Choose a reason for hiding this comment

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

By default, errors in Go do not include any stack trace information. Without it, it makes it very difficult to determine the source of an error (i.e. source code file & line), especially if the same error can be created in multiple places. github.com/pkg/errors makes it much easier to embed that stack information, and it includes a special custom format printer to print out the stack trace information.

The general guidance I've used in the past is that every line of code you write in a project that returns an error must either already have stack info, or you must wrap it. For first class functions (those defined in your project), you can/should assume that any errors they return are already wrapped. When you are invoking functions from vendored libraries, you can either check to see if they use github.com/pkg/errors, or you can just wrap.

pkg/controller/cluster/cluster_controller.go Outdated Show resolved Hide resolved
@liztio liztio force-pushed the delete-machines branch 2 times, most recently from 57fabbe to e6d4114 Compare July 24, 2019 15:57
@ncdc
Copy link
Contributor

ncdc commented Jul 24, 2019

1 last comment, then LGTM. I'd like 1 more review:
/assign @vincepri

@vincepri
Copy link
Member

Mostly nits, which can be fixed later.

/lgtm
/hold

Feel free to unhold when ready

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 24, 2019
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 24, 2019
liztio and others added 2 commits July 24, 2019 13:54
@ncdc
Copy link
Contributor

ncdc commented Jul 24, 2019

/lgtm
/approve

@liztio please remove the hold after you retest against CAPA.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 24, 2019
@liztio
Copy link
Contributor Author

liztio commented Jul 24, 2019

I0724 18:48:29.221278       1 scope.go:219] [cluster-actuator]/cluster.k8s.io/v1alpha1/default/whinnyapolis "level"=1 "msg"="updating cluster status"  
I0724 18:48:29.314440       1 cluster_controller.go:196] Cluster object whinnyapolis deletion successful, removing finalizer.

@liztio
Copy link
Contributor Author

liztio commented Jul 24, 2019

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 24, 2019
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liztio, ncdc, vincepri

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 24, 2019
@k8s-ci-robot k8s-ci-robot merged commit e818908 into kubernetes-sigs:release-0.1 Jul 24, 2019
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants