fix(cspc): cleanup bdcs after deletion or scaledown of cspi#1579
fix(cspc): cleanup bdcs after deletion or scaledown of cspi#1579vishnuitta merged 13 commits intoopenebs-archive:masterfrom
Conversation
cmd/cspc-operator/app/cleanup.go
Outdated
| }, | ||
| ) | ||
| if err != nil { | ||
| klog.Errorf("failed to list cspi for cspc %s to perform cleanup: %s", cspcObj.Name, err.Error()) |
There was a problem hiding this comment.
In the next PR's we can generate an event regarding the error.
There was a problem hiding this comment.
Will take this in next PR
| return err | ||
| } | ||
| err = cleanupCSPIResources(cspcGot) | ||
| return err |
There was a problem hiding this comment.
In the next PR's we can generate an event instead of returning an error. The event will be more visible to the user.
There was a problem hiding this comment.
Will take this in next PR
There was a problem hiding this comment.
can you take care of this in same PR?
| return nil | ||
| } | ||
| cspi.Finalizers = []string{} | ||
| cspi.Finalizers = util.RemoveString(cspi.Finalizers, apiscspc.PoolProtectionFinalizer) |
There was a problem hiding this comment.
hope this works even if cspi.Finalizers doesn't have PoolProtectionFinalizer
There was a problem hiding this comment.
It works in both cases when the cspi.Finalizers slice is nil or the PoolProtectionFinalizer is not present in the slice. https://play.golang.org/p/kgnN2Xv_U4r
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
code for future predicates Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
vishnuitta
left a comment
There was a problem hiding this comment.
can we remove the 'ownerReferences' which are on these objects CSPI/BDC/CSPC
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
| return nil | ||
| } | ||
| cspi.Finalizers = []string{} | ||
| cspi.Finalizers = util.RemoveString(cspi.Finalizers, apiscspc.PoolProtectionFinalizer) |
There was a problem hiding this comment.
Caller code of removeFinalizer is making a CSPI update call(but there won't be any problem since we are not performing any operation after removing the finalizer).
| if !util.ContainsString(cspi.Finalizers, apiscspc.PoolProtectionFinalizer) { | ||
| return nil | ||
| } | ||
|
|
There was a problem hiding this comment.
@vishnuitta should we need to check any CVR's on this pool before triggering zpool.Destroy not in this PR may be in next PR. What will you suggest regarding CVR checking?
There was a problem hiding this comment.
we will take this in upcoming PRs.
Signed-off-by: shubham <shubham.bajpai@mayadata.io>
Signed-off-by: shubham shubham.bajpai@mayadata.io
What this PR does / why we need it:
When a cspi is deleted or the cspc is scaled down by removing a poolSpec the bdcs for the cspi are not cleaned up. This results in stale resource and unwanted claims on bd which can be used by other resources. This PR adds the cleanup of bdcs in such cases.
Sample BDD output:
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Checklist:
documentationtagbreaking-changestagrequires-upgradetag