Skip to content
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 rule: fixed issue with alertmanager URL containing + #1582

Merged
merged 3 commits into from
Oct 2, 2019

Conversation

FUSAKLA
Copy link
Member

@FUSAKLA FUSAKLA commented Sep 28, 2019

fixes #1564

  • CHANGELOG entry if change is relevant to the end user.

Changes

  • fixed issue when Alertmanager URL contains + which can be for example in credentials

Verification

  • added tests which are passing
  • tested to startup the rule with various URLs

Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks very good to me and well tested 💪 however a philosophical question/idea: maybe it would be worth to error out if more than one + has been found in the parsedUrl.Scheme variable considering that none of the dns.QType variables have a +?

@FUSAKLA
Copy link
Member Author

FUSAKLA commented Sep 28, 2019

Thanks! Yes, good point. The function handles just parsing not validation. The validation is done in the resolver package so it eventually errors out afterwards (below example). This way the rule does not necessarily know all the resolvers types and who knows, maybe there will be some QType with + 😄
But yeah, I'm ok with erroring out if you think it will be safer this way.

Example:

$ ./thanos rule --alertmanagers.url=foo+bar+http:user:pass+word@test.haha --query=http://test.dev
...
level=info ts=2019-09-28T13:12:36.055664442Z caller=rule.go:591 msg="starting rule node"
...
level=error ts=2019-09-28T13:12:36.055936546Z caller=rule.go:363 msg="refreshing alertmanagers failed" err="alertmanager resolve: invalid lookup scheme \"foo+bar\""

@GiedriusS
Copy link
Member

Thanks! Yes, good point. The function handles just parsing not validation. The validation is done in the resolver package so it eventually errors out afterwards (below example). This way the rule does not necessarily know all the resolvers types and who knows, maybe there will be some QType with + smile
But yeah, I'm ok with erroring out if you think it will be safer this way.

Example:

$ ./thanos rule --alertmanagers.url=foo+bar+http:user:pass+word@test.haha --query=http://test.dev
...
level=info ts=2019-09-28T13:12:36.055664442Z caller=rule.go:591 msg="starting rule node"
...
level=error ts=2019-09-28T13:12:36.055936546Z caller=rule.go:363 msg="refreshing alertmanagers failed" err="alertmanager resolve: invalid lookup scheme \"foo+bar\""

Ah, I haven't checked. Then it should be all good, thanks for the example output.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Extremely small nit only =D then LGTM

cmd/thanos/rule.go Outdated Show resolved Hide resolved
Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
@FUSAKLA
Copy link
Member Author

FUSAKLA commented Oct 2, 2019

@bwplotka fixed and rebased, thanks for noticing :))

@GiedriusS GiedriusS merged commit 68c539c into thanos-io:master Oct 2, 2019
GiedriusS pushed a commit that referenced this pull request Oct 28, 2019
* fix rule: fixed issue with alertmanager URL containing +

Signed-off-by: Martin Chodur <m.chodur@seznam.cz>

* CR: updated changelog

Signed-off-by: Martin Chodur <m.chodur@seznam.cz>

* CR: add trailing period

Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ruler: alertmanager.url + symbol in password for basic auth interprets start of url as lookup scheme
3 participants