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

[Docker] Not stripping new line character from slack_api_url_file when using docker secrets #2891

Closed
vmvazque opened this issue Apr 20, 2022 · 2 comments

Comments

@vmvazque
Copy link

What did you do?

  • Created a file with https://hooks.slack.com/services/REDACTED in it (no new line)
  • Created a docker secret from the file
  • Mounted the secret onto the alertmanager container
  • set slack_api_url_file: '/my-created-secret'

What did you expect to see?
I expected alertmanager to read the URL from the file and use it to send slack alerts

What did you see instead? Under which circumstances?
Kept failing with

caller=notify.go:732 level=warn component=dispatcher receiver=slack-notifications integration=slack[0] msg="Notify attempt failed, will retry later" attempts=1 err="parse \"<redacted>\": net/url: invalid control character in URL"

Going into the container and doing cat -e /my-created-secret shows https://hooks.slack.com/services/REDACTED$. I think a new-line character is being added when the docker secret is created and alertmanager is failing to strip it out

Environment
Docker

  • System information:
    Linux 4.15.0-175-generic x86_64

  • Alertmanager version:

alertmanager, version 0.24.0 (branch: HEAD, revision: f484b17)
build user: root@265f14f5c6fc
build date: 20220325-09:31:33
go version: go1.17.8
platform: linux/amd64

  • Alertmanager configuration file:
global:
  slack_api_url_file: '/my-created-secret'

route:
  receiver: 'slack-notifications'

receivers:
- name: 'slack-notifications'
  slack_configs:
  - channel: '#dev-ops'
    send_resolved: true
    icon_url: 'https://avatars3.githubusercontent.com/u/3380462'
    title: |-
     [{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }}
    text: >-
     {{ range .Alerts -}}
     *Alert:* {{ .Annotations.title }}{{ if .Labels.severity }} - `{{ .Labels.severity }}`{{ end }}

     *Description:* {{ .Annotations.description }}
     {{ end }}
  • Logs:
ts=2022-04-20T23:24:39.254Z caller=dispatch.go:354 level=error component=dispatcher msg="Notify for alerts failed" num_alerts=2 err="slack-notifications/slack[0]: notify retry canceled after 17 attempts: parse \"<redacted>\": net/url: invalid control character in URL"
ts=2022-04-20T23:24:39.256Z caller=notify.go:732 level=warn component=dispatcher receiver=slack-notifications integration=slack[0] msg="Notify attempt failed, will retry later" attempts=1 err="parse \"<redacted>\": net/url: invalid control character in URL"
ts=2022-04-20T23:29:39.256Z caller=dispatch.go:354 level=error component=dispatcher msg="Notify for alerts failed" num_alerts=2 err="slack-notifications/slack[0]: notify retry canceled after 16 attempts: parse \"<redacted>\": net/url: invalid control character in URL"
ts=2022-04-20T23:29:39.259Z caller=notify.go:732 level=warn component=dispatcher receiver=slack-notifications integration=slack[0] msg="Notify attempt failed, will retry later" attempts=1 err="parse \"<redacted>\": net/url: invalid control character in URL"

@rgroothuijsen
Copy link

It did work for me, although I had to explicitly strip the invisible newline character from the file before creating the secret. Specifying not to write a newline can be done with commands such as echo -n http://api-url > secret_file.txt, but some text editors may have an option to show invisible characters.

@simonpasquier
Copy link
Member

It should be fixed by #2929. Feel free to reopen if it isn't the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants