-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 scheme required for webhook url in amtool #3509
Fix scheme required for webhook url in amtool #3509
Conversation
@@ -168,3 +168,36 @@ receivers: | |||
t.Errorf("Incorrect number of silences queried, expected: %v, actual: %v", expectedSils, len(sils)) | |||
} | |||
} | |||
|
|||
func TestRoutesShow(t *testing.T) { |
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.
Revert the fix and this test fails:
--- FAIL: TestRoutesShow (1.09s)
cli_test.go:202: amtool: error: scheme required for webhook url
cli_test.go:203:
Error Trace: /Users/grobinson/go/src/github.com/prometheus/alertmanager/test/cli/acceptance/cli_test.go:203
Error: Received unexpected error:
exit status 1
Test: TestRoutesShow
FAIL
@@ -503,11 +503,6 @@ func (c *WebhookConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { | |||
if c.URL != nil && c.URLFile != "" { | |||
return fmt.Errorf("at most one of url & url_file must be configured") | |||
} | |||
if c.URL != nil { |
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.
We think this is duplicate code as SecretURL
is just a URL
, whose UnmarshalYaml
function also calls parseURL
which contains the same check.
Thanks! I'd be inclined to have the fix in the release-0.26 branch. |
This commit fixes issue prometheus#3505 where amtool would fail with "error: scheme required for webhook url" when using amtool with --alertmanager.url. The issue here is that UnmarshalYaml for WebhookConfig checks if the scheme is present when c.URL is non-nil. However, UnmarshalYaml for SecretURL returns a non-nil, default value url.URL{} if the response from api/v2/status contains <secret> as the webhook URL. Signed-off-by: George Robinson <[email protected]>
3e63325
to
b6cdd41
Compare
Apologies for the force push, there was a spelling mistake in the commit message. |
I believe this warrants a 0.26.1. |
func (am *Alertmanager) showRouteCommand() ([]byte, error) { | ||
amURLFlag := "--alertmanager.url=" + am.getURL("/") | ||
args := []string{amURLFlag, "config", "routes", "show"} | ||
cmd := exec.Command(amtool, args...) |
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 we also add one for config routes test
?
Signed-off-by: George Robinson <[email protected]>
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!
Thank you very much for your contribution.
* Fix scheme required for webhook url in amtool This commit fixes issue #3505 where amtool would fail with "error: scheme required for webhook url" when using amtool with --alertmanager.url. The issue here is that UnmarshalYaml for WebhookConfig checks if the scheme is present when c.URL is non-nil. However, UnmarshalYaml for SecretURL returns a non-nil, default value url.URL{} if the response from api/v2/status contains <secret> as the webhook URL. Signed-off-by: George Robinson <[email protected]> * Add test for config routes test Signed-off-by: George Robinson <[email protected]> --------- Signed-off-by: George Robinson <[email protected]>
* Fix scheme required for webhook url in amtool This commit fixes issue #3505 where amtool would fail with "error: scheme required for webhook url" when using amtool with --alertmanager.url. The issue here is that UnmarshalYaml for WebhookConfig checks if the scheme is present when c.URL is non-nil. However, UnmarshalYaml for SecretURL returns a non-nil, default value url.URL{} if the response from api/v2/status contains <secret> as the webhook URL. Signed-off-by: George Robinson <[email protected]> * Add test for config routes test Signed-off-by: George Robinson <[email protected]> --------- Signed-off-by: George Robinson <[email protected]> Signed-off-by: gotjosh <[email protected]>
This commit fixes issue #3505 where amtool would fail with
error: scheme required for webhook url
when using amtool with--alertmanager.url
.The issue here is that
UnmarshalYaml
forWebhookConfig
checks if the scheme is present whenc.URL
is non-nil. However,UnmarshalYam
l forSecretURL
returns a non-nil, default valueurl.URL{}
if the response fromapi/v2/status
contains<secret>
as the webhook URL.