-
Notifications
You must be signed in to change notification settings - Fork 444
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
Collector Instances Not Discovered Due to Case Sensitivity in matchLabels #3350
Comments
I would like to work on this |
It would be great if we could figure out a way to do this without redefining all the K8s and Prometheus structs ourselves. I originally did it this way because it was simple and standalone TA wasn't a very popular thing to do. @davidhaja feel free to take a stab at it. |
@swiatekm Maybe if we implement a custon unmarshal function this could work, wdyt? |
Maybe, I'm honestly not that familiar with the unmarshalling magic for these structs. I'm hoping that someone more knowledgeable can make it work, or at least try different approaches to see what conclusively doesn't work. |
The way I see is either we try to support the flexible/case insensitive unmarshalling in TA, or we change both the marshalling and unmarshalling to follow (and require) the k8s camel case convention. I've tried multiple yaml packages, but none of them supports case insensitive parsing of YAML files.
I ended up with github.com/goccy/go-yaml because of its feature set. I've described the feature that my change is using for providing case insensitive parsing. |
Component(s)
target allocator
What happened?
Description
While running TA without using the OTel Operator, I spent some time trying to understand why the TA was not discovering my collector instances and just figured out that I was using this config file:
Highlight the
matchLabels
key. This is using camel case, which is the convention while working with Kubernetes resources, but TA’s unmarshal method is only accepting lower case.Even though TA is using the
LabelSelector
under thek8s.io/apimachinery/pkg/apis/meta/v1
package, this is not working because this package doesn’t contain any annotations to YAML marshal.Initially, I was thinking about converting the whole config into JSON and using the
YAMLToJSON
method available in thegithub.com/ghodss/yaml
package, but after doing that I noticed the configs related to Prometheus from thegithub.com/prometheus/prometheus/config
package stopped working, since they don’t support any JSON annotations for marshalling.I had another idea in mind! Keep using YAML for marshalling and redefine the
LabelMatcher
struct inside the TA project.I’d like to get your opinion on that and check if you folks see any other solution. Maybe ask Prometheus maintainers to add JSON annotations to the Config struct? Not sure. Looking forward to your feedback.
Steps to Reproduce
Start the TA using the following config
Expected Result
Be compatible with K8S semantics
Actual Result
Not compatibility with K8S semantics
Kubernetes Version
NA
Operator version
NA
Collector version
NA
Environment information
Environment
NA
Log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: