-
Notifications
You must be signed in to change notification settings - Fork 451
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 annotations propagation #1505
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,9 @@ func TestDaemonSetNewDefault(t *testing.T) { | |
// verify sha256 podAnnotation | ||
expectedAnnotations := map[string]string{ | ||
"opentelemetry-operator-config/sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", | ||
"prometheus.io/path": "/metrics", | ||
"prometheus.io/port": "8888", | ||
"prometheus.io/scrape": "true", | ||
} | ||
assert.Equal(t, expectedAnnotations, d.Spec.Template.Annotations) | ||
|
||
|
@@ -103,9 +106,17 @@ func TestDaemonsetHostNetwork(t *testing.T) { | |
func TestDaemonsetPodAnnotations(t *testing.T) { | ||
// prepare | ||
testPodAnnotationValues := map[string]string{"annotation-key": "annotation-value"} | ||
|
||
// Add sha256 podAnnotation | ||
testPodAnnotationValues["opentelemetry-operator-config/sha256"] = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be moved up to the declaration of |
||
testPodAnnotationValues["prometheus.io/path"] = "/metrics" | ||
testPodAnnotationValues["prometheus.io/port"] = "8888" | ||
testPodAnnotationValues["prometheus.io/scrape"] = "true" | ||
|
||
otelcol := v1alpha1.OpenTelemetryCollector{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "my-instance", | ||
Name: "my-instance", | ||
Annotations: testPodAnnotationValues, | ||
}, | ||
Spec: v1alpha1.OpenTelemetryCollectorSpec{ | ||
PodAnnotations: testPodAnnotationValues, | ||
|
@@ -116,9 +127,6 @@ func TestDaemonsetPodAnnotations(t *testing.T) { | |
// test | ||
ds := DaemonSet(cfg, logger, otelcol) | ||
|
||
// Add sha256 podAnnotation | ||
testPodAnnotationValues["opentelemetry-operator-config/sha256"] = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" | ||
|
||
// verify | ||
assert.Equal(t, "my-instance-collector", ds.Name) | ||
assert.Equal(t, testPodAnnotationValues, ds.Spec.Template.Annotations) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ func Deployment(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTele | |
labels["app.kubernetes.io/name"] = naming.Collector(otelcol) | ||
|
||
annotations := Annotations(otelcol) | ||
podAnnotations := PodAnnotations(otelcol) | ||
|
||
return appsv1.Deployment{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
|
@@ -48,7 +47,7 @@ func Deployment(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTele | |
Template: corev1.PodTemplateSpec{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Labels: labels, | ||
Annotations: podAnnotations, | ||
Annotations: annotations, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this introduce a regression where you can no longer set specific pod annotations? I rely on exactly this currently in a few places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct , I missed this 👍🏼 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, so, to avoid this kind of regression, I would propagate the annotations into podAnnotations. WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be fine to append the annotations in to the pod annotations. How would you handle conflicts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT to take the Deployment's annotations as precedence? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yuriolisa i think the pod annotations should win, otherwise there would be no way to override something on the deployment. |
||
}, | ||
Spec: corev1.PodSpec{ | ||
ServiceAccountName: ServiceAccountName(otelcol), | ||
|
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 wonder why the pod annotations were separated from the others. Did you try to look it up in the history?
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 took a look at the history, but it seems this behavior was a try to fix a bug related to reconciling the collector once the configmap changes. However, I don't know why it wasn't simply added the sha256 onto the Deployment annotations and replicate them to the podAnnotations.
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.
#670
LGTM to get rid of 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.
Do you think we could have a situation in which pods should have a specific annotation not present on Deployment's annotations?