-
Notifications
You must be signed in to change notification settings - Fork 229
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
fix: resource deletion and adoption for 3 controllers #777
Conversation
related comment for reference: #776 (comment) steps to reproduce:
|
controllers/collector_controller.go
Outdated
@@ -170,17 +170,32 @@ func (r *CollectorReconciler) mutate(obj client.Object, co fluentbitv1alpha2.Col | |||
|
|||
func (r *CollectorReconciler) delete(ctx context.Context, co *fluentbitv1alpha2.Collector) error { | |||
var sa corev1.ServiceAccount | |||
if err := r.Delete(ctx, &sa); err != nil && !errors.IsNotFound(err) { | |||
err := r.Get(ctx, client.ObjectKey{Namespace: co.Namespace, Name: co.Name}, &sa) |
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.
I think it can call the delete
directly like this
sa := corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: co.Name,
Namespace: co.Namespace,
},
}
if err := r.Delete(ctx, &sa); err != nil && !errors.IsNotFound(err) {
return err
}
No need to call get
.
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.
it seems like other controllers (fluentbit, fluentd) have to update like this as well.
btw, does it make sense to check the owner reference before deletion? what if there's another resource which is not managed by this operator (i.e. fluentbit collector) with the same name?
e5ced54
to
a778c0d
Compare
@wanjunlei PTAL. thank you. cc @benjaminhuo
the lifecycle of the existing resources without owner reference but with the same name will be managed by this operator, like creation, updating, deletion. |
Signed-off-by: Jason Zhang <ksdpmx@gmail.com>
a778c0d
to
fa6fb43
Compare
@wanjunlei are you ok with @ksdpmx‘s new change? |
@ksdpmx Thank you for this big refactoring |
What this PR does / why we need it:
resources like sa, svc and sts haven't been generated before callingDelete()
which leads to the remaining finalizer for collector.resource deletion and adoption cleanup and fix for 3 controllers
Which issue(s) this PR fixes:
Fixes #
Does this PR introduced a user-facing change?
Additional documentation, usage docs, etc.: