-
Notifications
You must be signed in to change notification settings - Fork 459
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
internal/manifests/collector: switch internally to v1alpha2 #2532
Conversation
4499392
to
ffea150
Compare
0eec778
to
e5040f6
Compare
Could you add some description/link to the issue to explain what are you implementing here? |
@iblancasa ive added a description. Does it make sense to you? |
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.
A few thoughts, but it does feel like we're on a good path here!
Pods: m.Pods, | ||
} | ||
} | ||
out.Spec.OpenTelemetryCommonFields.Autoscaler = &v1alpha2.AutoscalerSpec{ |
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 we need to worry about the deprecated min and max replica fields?
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 did say no. Since you are still able to set min/max in the AutoscalerSpec.
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.
Since they are deprecated and this is a version bump... I would say this is the perfect moment to remove them
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 would prefer to keep the change as minimal as possible. We can add/remove/change behavior afterwards.
778c94d
to
ee38503
Compare
Seems there are still some tests failing that compare strings.
|
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 I would add require statements for returned error that was added to many manifest files
Well, now the formatting in the e2e tests seems to be slightly different. 🦝 |
Pods: m.Pods, | ||
} | ||
} | ||
out.Spec.OpenTelemetryCommonFields.Autoscaler = &v1alpha2.AutoscalerSpec{ |
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.
Since they are deprecated and this is a version bump... I would say this is the perfect moment to remove them
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
} | ||
|
||
// PodAnnotations return the spec annotations for OpenTelemetryCollector pod. | ||
func PodAnnotations(instance v1alpha1.OpenTelemetryCollector) map[string]string { | ||
func PodAnnotations(instance v1alpha2.OpenTelemetryCollector) (map[string]string, error) { |
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.
note: in the future, i think we should make the getConfigMapSHA a method on the collector itself that returns no error. Note worth doing in this PR, but doing so in the future would help us clean up a lot of the error checking this introduces.
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 made an issue for this:
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.
a few thoughts/questions. But overall i think this LGTM. I do think we should merge this after #2567 so that we don't incur a major performance hit from all this marshalling business we're doing now.
func Deployment(params manifests.Params) *appsv1.Deployment { | ||
name := naming.Collector(params.OtelCol.Name) | ||
labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, params.Config.LabelsFilter()) | ||
func Deployment(params manifests.Params) (*appsv1.Deployment, error) { |
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 after this change and #2516 go in, i will modify these signatures to not take in the whole manifests.Params
object, but only the object they need (i.e. collector in this case)
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.
"github.com/open-telemetry/opentelemetry-operator/internal/manifests" | ||
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" | ||
"github.com/open-telemetry/opentelemetry-operator/internal/naming" | ||
) | ||
|
||
func PodDisruptionBudget(params manifests.Params) *policyV1.PodDisruptionBudget { | ||
func PodDisruptionBudget(params manifests.Params) (*policyV1.PodDisruptionBudget, error) { | ||
otelCol, err := convert.V1Alpha1to2(params.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.
can you open an issue for cleaning this up after this is merged?
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.
collector_id: ${POD_NAME} | ||
endpoint: http://prometheus-cr-targetallocator:80 | ||
interval: 30s | ||
prometheus: |
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.
is there a reason we need to change the whitespacing for these now? I saw the indent call above in the serialization and wasn't sure why we need that.
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.
y, thats a bit weird. This one works fine. But as soon as we use yaml.Marshal
it falls back to ident = 4.
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.
The default yaml.Marshal
creates a newEncoder()
which is initliazed with ident = 4.
https://github.com/go-yaml/yaml/blob/f6f7691b1fdeb513f56608cd2c32c51f8194bf51/encode.go#L56-L67
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.
Great progress 🎉
Just one comment, I would prefer avoiding type config -> yaml -> type config translation.
return nil, err | ||
} | ||
|
||
confStr, err := otelCol.Spec.Config.Yaml() |
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.
The typed config is serialized to yaml and then back unserialized to map[interface{}]interface{}
The typed config could be easily converted to map[interface{}]interface{}
which is accepted in most signatures
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.
Could we add another toMap()
method and extend the scope of #2591 for 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.
please book a follow up ticket for this
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.
As discussed on the sig call, we will wait until the next release is published. |
…emetry#2532) * internal/manifests/collector: switch internally to v1alphav2 Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/manifests/collector: change svc account Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/api/convert: propagate ver upgrade error Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * intern/{api,manifests}: directly call yaml unmarshal Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/api/convert: map DaemonSetUpdateStrategy Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/manifests/collector: migrate configmap Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/api/convert: use go-yaml instead of sig-yaml Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * pkg/sidecar: upgrade internal use from v1alpha2 to v1alpha2 Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/manifests/collector: adapt cm, svc, ingress & route Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/api/convert: fix v1alpha1 to v1alpha2 Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/manifests/collector: evaluate returned error value in tests Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * apis/v1alpha2: config yaml method Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/manifests/collector: use v1alpha2.Config yaml method Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * controllers/builder: adapt ident in unit test Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/manifests/collector: fix test Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * tests/e2e: align to new indentation Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * internal/manifests/collector: cleanup Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> --------- Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
Description:
This PR replaces the internal dependency in
internal/manifests/collector
onv1alpha1
in the course of the migration tov1alpha2
.To convert the
v1alpha1
CR fetched and passed from the controller it adds ainternal/api/convert.v1alpha1to2()
function to upgrade tov1alpha2
.The next step is to migrate
opampbridge
,targetallocator
andmanifests
. It should then be possible to perform the final conversion fromv1alpha1
tov1alpha2
and back in the reconcile loop.Link to tracking Issue:
Testing:
Documentation: