-
Notifications
You must be signed in to change notification settings - Fork 349
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
Remove sidecars of annotated namespaces when annotation is deleted #1209
Conversation
…eleted Signed-off-by: Ruben Vargas <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #1209 +/- ##
=======================================
Coverage 87.32% 87.32%
=======================================
Files 89 89
Lines 4891 4891
=======================================
Hits 4271 4271
Misses 457 457
Partials 163 163 Continue to review full report at Codecov.
|
// If deployment don't have the annotation and has an agent, this may be injected by the namespace | ||
// we need to clean it. | ||
agent, _ := inject.HasJaegerAgent(dep) | ||
_, depAnnotation := dep.Annotations[inject.Annotation] |
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.
s/depAnnotation/ok
-- you are not getting the annotation, you are getting a boolean on whether it was found.
agent, _ := inject.HasJaegerAgent(dep) | ||
_, depAnnotation := dep.Annotations[inject.Annotation] | ||
if agent && !depAnnotation{ | ||
jaegerInstance, label := dep.Labels[inject.Label] |
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 here.
"jaeger": jaegerInstance, | ||
}).Info("Removing Jaeger Agent sidecar") | ||
inject.CleanSidecar(jaegerInstance, dep) | ||
if err := r.client.Update(ctx, dep); err != 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.
Use Patch instead of Update, to reduce the risk of failure. Look at this one for reference: open-telemetry/opentelemetry-operator#54
Signed-off-by: Ruben Vargas <[email protected]>
log.WithFields(log.Fields{ | ||
"deployment": dep.Name, | ||
"namespace": dep.Namespace, | ||
"jaeger": jaegerInstance, | ||
}).Info("Removing Jaeger Agent sidecar") | ||
patch := client.MergeFrom(dep.DeepCopy()) |
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.
If dep
is a pointer, you might not need to do a DeepCopy, you can just dereference it.
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.
LGTM. A minor comment on the dep.DeepCopy()
, but this looks good. Have you done manual testing of this?
Yes I did manual testing, with the steps detailed in the issue on how to reproduce. |
…aegertracing#1209) Signed-off-by: Ruben Vargas <[email protected]>
Fixes #906
Signed-off-by: Ruben Vargas [email protected]