-
Notifications
You must be signed in to change notification settings - Fork 39
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
Delay removal of orphanPVC to avoid the removal of PVC in use #67
Conversation
@gurjotkaur20 this is great ! The only thing which i might want to do is add a finalizer instead of labels ( cc @avtarOPS ) Regardless, ill take look at it. |
controllers/druid/handler.go
Outdated
return err | ||
|
||
if _, ok := pvc.GetLabels()["toBeDeleted"]; ok { | ||
deletionTS := pvc.GetLabels()["deletionTimestamp"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can change the label name as the same label is used by the finalizer.
err := writers.Delete(ctx, sdk, drd, pvcList[i], emitEvents, &client.DeleteAllOfOptions{}) | ||
if err != nil { | ||
return err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This became way too big, we should refactor this, separating it into functions
controllers/druid/handler.go
Outdated
if err != nil { | ||
return err | ||
|
||
if _, ok := pvc.GetLabels()["toBeDeleted"]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the below should be consts
I have refactored the code and updated the label name. |
Fine by me :) |
controllers/druid/handler.go
Outdated
} else { | ||
// do nothing | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this block ?
controllers/druid/handler.go
Outdated
} else { | ||
// do nothing | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, why do we need this block ? can return nil ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, why do we need this block ? can return nil ?
Done changes for both else blocks.
d6a50d2
to
7212552
Compare
Fixes #32
Description
Possibly a race condition is causing removal of PVC in use.
The solution in the PR: Added two labels
toBeDeleted
anddeletionTimestamp
to mark the pvc for deletion. Do not delete the pvc right away, wait for 60s to delete it and avoid the race condition.This PR has:
Key changed/added files in this PR
controllers/druid/handler.go
controllers/druid/util.go