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

Cleanup Secret and Lease objects from tfstate #52

Merged
merged 3 commits into from
May 6, 2022

Conversation

bobh66
Copy link
Collaborator

@bobh66 bobh66 commented Apr 30, 2022

Signed-off-by: Bob Haddleton bob.haddleton@nokia.com

Description of your changes

Added code to the Delete method to clean up any Secret or Lease objects that were used by the Terraform
Kubernetes back end to store tfstate information.

Fixes #40

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Tested in an EKS deployment - verified that deleting a Workspace that is using a Kubernetes backend also deletes the associated Secret and Lease.

bobh66 added 2 commits April 29, 2022 08:54
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
Copy link
Collaborator

@ytsarev ytsarev left a comment

Choose a reason for hiding this comment

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

Overall looks great, thanks a ton! Please address the error-catching suggestion.

_ = c.kube.List(ctx, ll, client.MatchingLabels(labels))
for l := range ll.Items {
ls := ll.Items[l]
_ = c.kube.Delete(ctx, &ls)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to catch errors during this interaction with the kubernetes API

11:42:40 [ .. ] golangci-lint
internal/controller/workspace/workspace.go:331:2: Error return value of `c.kube.List` is not checked (errcheck)
	_ = c.kube.List(ctx, sl, client.MatchingLabels(labels))
	^
internal/controller/workspace/workspace.go:334:3: Error return value of `c.kube.Delete` is not checked (errcheck)
		_ = c.kube.Delete(ctx, &sec)
		^
internal/controller/workspace/workspace.go:337:2: Error return value of `c.kube.List` is not checked (errcheck)
	_ = c.kube.List(ctx, ll, client.MatchingLabels(labels))
	^
internal/controller/workspace/workspace.go:340:3: Error return value of `c.kube.Delete` is not checked (errcheck)
		_ = c.kube.Delete(ctx, &ls)
		^
11:42:49 [FAIL]

I've created #53 to enable automated check for that(slightly surprised that it was disabled :) )

Signed-off-by: Bob Haddleton <bob.haddleton@nokia.com>
Copy link
Collaborator

@ytsarev ytsarev left a comment

Choose a reason for hiding this comment

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

Looks great, thanks a lot for the additional fixes.

@ytsarev ytsarev merged commit ae5e665 into crossplane-contrib:master May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provider leaves terraform state Secrets and Leases behind
2 participants