-
Couldn't load subscription status.
- Fork 561
fix(labels): ensure app.kubernetes.io/version reflects image tag on workloads #4243
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
base: main
Are you sure you want to change the base?
fix(labels): ensure app.kubernetes.io/version reflects image tag on workloads #4243
Conversation
- Fix version label logic in Collector, OpAMPBridge, and TargetAllocator manifests - Add fallback logic: spec image > config image > latest - Add comprehensive tests for all components (Collector, OpAMPBridge, TargetAllocator) - Fix expectations for default config values (0.0.0 instead of latest) Fixes open-telemetry#4175 Signed-off-by: andrefrco <andre.frco@gmail.com> fix(manifests): fix app.kubernetes.io/version label logic
|
I'll check the e2e tests failure asap |
Signed-off-by: andrefrco <andre.frco@gmail.com>
Replace len(image) == 0 with image == "" for better string validation in Collector, OpAMPBridge, and TargetAllocator deployment manifests.
- Add config parameter to updateCollectorStatus for consistent image resolution - Remove hardcoded version assertion from kubeletstats e2e test
Fixed the e2e test by removing the hardcoded version assertion from kubeletstats test (to avoid version-specific checks). Also added the same image resolution logic to UpdateCollectorStatus for consistency since it creates labelSelectors. |
Description:
This PR makes sure the
app.kubernetes.io/versionlabel on workloads (Deployment, DaemonSet, and StatefulSet) matches the tag from the image passed via the--collector-image,--target-allocator-image, or--operator-opamp-bridge-imageCLI flags in cases where.spec.imageisn’t set directly in the OpenTelemetryCollector, OpAMPBridge, or TargetAllocator CR.Before this, if
.spec.imagewasn’t defined, the operator would fall back to setting "latest" as the label even though the actual image (like 0.129.1) came from the CLI flag. This caused theservice.versionresource attribute to be incorrect in the workloads.Link to tracking Issue(s):
app.kubernetes.io/versionis wrong when using global--collector-imageoption #4175Testing:
Added 3 unit tests per workload type:
Fixed a DefaultTests that incorrectly expected "latest" when using config.New(). Since config.New() returns a config with a fallback value (e.g.) used for tests, the test was updated to reflect that version "0.0.0" instead of "latest".
I've also tested the change locally using minikube and confirmed that the app.kubernetes.io/version label is now correctly set on the generated workloads.
Documentation:
This is a bug fix, no doc changes required.
Design consideration:
I thought about changing the
labels.Labels()function to accept aconfig.Configparameter, which would let us handle the version resolution in a single place. Something like:That way, we could reuse this logic across all components (services, serviceMonitors, etc) using the resourceImage and filterLabels together.
But I was a bit worried it might make the labels package more complex than it needs to be, since it would have to know about operator components and global config.
So for now, I went with a simpler approach and kept the logic outside. I'm new here and happy to improve this if there's a better way 🙂