openshift / aws-efs-operator

Operator to manage AWS EFS on OpenShift
Apache License 2.0
3 stars 23 forks source link

Make PV/PVC owned by SharedVolume #20

Closed 2uasimojo closed 4 years ago

2uasimojo commented 4 years ago

By adding an OwnerReference to the SharedVolume to the PV and PVC it creates, kubernetes handles their deletion for us. This allows us to rip out a big chain of code, including:

Jira: OSD-4083 (sort of)

openshift-ci-robot commented 4 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 2uasimojo

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: - ~~[OWNERS](https://github.com/openshift/aws-efs-operator/blob/master/OWNERS)~~ [2uasimojo] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
codecov-commenter commented 4 years ago

Codecov Report

Merging #20 into master will decrease coverage by 0.24%. The diff coverage is 84.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #20      +/-   ##
==========================================
- Coverage   74.19%   73.94%   -0.25%     
==========================================
  Files          18       21       +3     
  Lines         620      664      +44     
==========================================
+ Hits          460      491      +31     
- Misses        153      166      +13     
  Partials        7        7              
Impacted Files Coverage Δ
cmd/manager/main.go 0.00% <0.00%> (ø)
pkg/controller/statics/statics.go 84.46% <ø> (ø)
pkg/test/client.go 47.36% <47.36%> (ø)
pkg/apis/awsefs/v1alpha1/owner.go 100.00% <100.00%> (ø)
pkg/controller/sharedvolume/pv_ensurable.go 100.00% <100.00%> (ø)
pkg/controller/sharedvolume/pvc_ensurable.go 100.00% <100.00%> (ø)
...controller/sharedvolume/sharedvolume_controller.go 83.33% <100.00%> (-2.96%) :arrow_down:
pkg/controller/statics/statics_controller.go 74.00% <100.00%> (+30.52%) :arrow_up:
pkg/util/ensurable.go 100.00% <100.00%> (ø)
pkg/util/owner.go 100.00% <100.00%> (ø)
... and 3 more
2uasimojo commented 4 years ago

/hold the phone. I swear this worked when I tested it, but I shouldn't be able to make a SharedVolume (namespace-scoped) owner of a PV (cluster-scoped). Test again.

2uasimojo commented 4 years ago

/hold cancel

Yeah, this works, even though it shouldn't. If I remove the OwnerReferences from the PV, then delete the SV, the PV goes to Released state, but doesn't get deleted. So it's clearly the OwnerReferences that's doing it.

:man_shrugging:

2uasimojo commented 4 years ago

I want these to merge in a particular order, so closing this one in favor of https://github.com/2uasimojo/aws-efs-operator/pull/4, which I'll repoint here once its predecessors merge.