-
Notifications
You must be signed in to change notification settings - Fork 440
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
[target-allocator] Fix bug found when using relabel-config filterStrategy with serviceMonitors #1232
[target-allocator] Fix bug found when using relabel-config filterStrategy with serviceMonitors #1232
Conversation
5577956
to
aa8201e
Compare
2e57707
to
08a34e6
Compare
func (tf *RelabelConfigTargetFilter) replaceRelabelConfig(cfg []*relabel.Config) []*relabel.Config { | ||
outCfg := make([]*relabel.Config, len(cfg)) | ||
out, err := yaml2.Marshal(cfg) | ||
if err != nil { | ||
tf.log.V(2).Info("Error Marshaling", "error", err) | ||
return cfg | ||
} | ||
|
||
byteArr := replaceShard([]byte(out)) | ||
err = yaml2.Unmarshal(byteArr, &outCfg) | ||
if err != nil { | ||
tf.log.Info("Error Unmarshalling", "error", err) | ||
return cfg | ||
} | ||
|
||
return outCfg | ||
} | ||
|
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.
rather than marshaling and then unmarshaling, it's probably more efficient to just iterate through the relabel config list and do the replacement.
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.
Thanks for the review! Changed according to this suggestion.
// See this thread [https://github.com/open-telemetry/opentelemetry-operator/pull/1124/files#r983145795] | ||
// for why SHARD == 0 is a necessary substitution. Otherwise the keep action that uses this env variable, | ||
// would not match the regex and all targets end up dropped. | ||
shard := "0" |
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.
nit: also should include that shard will always be 0 here, and it doesn't make sense to read the SHARD from the environment.
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.
Added!
cdccb88
to
e993c52
Compare
e993c52
to
2554098
Compare
@jaronoff97 can this be 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.
@pavolloffay once the conflicts are fixed, this should be good to go! (cc @moh-osman3)
2554098
to
52cfabc
Compare
Just finished resolving merge conflicts and retested in my cluster! Thanks for the review y'all! |
…tegy with serviceMonitors (open-telemetry#1232) * env variable substitution for * remove unnessary env variable lookup and gofmt * fix linter issues * addressing review feedback * add to unit test * addressing feedback * change go.mod to use later version of prometheus * run gofmt * rebasing go.mod and running go mod tidy
Resolves #1231
Also adds to go.mod
to use the latest version of prometheus. This should avoid other dependencies bringing in older versions of prometheus, which is missing a relabel method I'm using.