Skip to content

Add a fallback to the slack notification provider - #1322

Merged
matheuscscp merged 1 commit into
fluxcd:mainfrom
hloeung:slack-notifications-include-fallback
Jun 10, 2026
Merged

Add a fallback to the slack notification provider#1322
matheuscscp merged 1 commit into
fluxcd:mainfrom
hloeung:slack-notifications-include-fallback

Conversation

@hloeung

@hloeung hloeung commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This PR adds a short "fallback" message consisting of the components which is used to form the AuthorName as well as the first line of event.Message which is used as the Text.

Slack documentation says that the fallback text is used in clients that don't show formatted text (e.g. mobile notifications). Keeping it to use the first line of event.Message should keep it short enough for mobile notifications and such..

In Mattermost, fallback is actually a requirement, see Mattermost Message Attachment options. Various deployments are using the Slack notification provider for Mattermost notifications - we're one of them.

@hloeung hloeung changed the title Add fallback message to the slack notification provider Add a fallback to the slack notification provider Jun 6, 2026
@hloeung
hloeung force-pushed the slack-notifications-include-fallback branch from 687e0b4 to 0ffa32f Compare June 6, 2026 03:14
@matheuscscp

Copy link
Copy Markdown
Member

@hloeung Nice one! Can you please test this e2e and print a screenshot from a mobile notification?

@hloeung

hloeung commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

We're currently using image: ghcr.io/fluxcd/notification-controller:v1.7.5. Any chance of getting an image built and published with this change for testing (under a different tag)?

@matheuscscp

matheuscscp commented Jun 9, 2026

Copy link
Copy Markdown
Member

Sure, I checked out your branch, rebased with upstream main and pushed so I could trigger this:

https://github.com/fluxcd/notification-controller/actions/runs/27192646039/job/80276362068

Keep an eye on the Publish images step, it will print the image with ghcr.io/...:rc-<git sha>@<digest>

@hloeung

hloeung commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for that.

Using ghcr.io/fluxcd/notification-controller:rc-aab38700, I can confirm that with this change, a fallback field and message is added.

 kubectl describe po notification-controller-6c7884998c-vhl72 -n flux-system | grep ghcr
    Image:           ghcr.io/fluxcd/notification-controller:rc-aab38700
    Image ID:        ghcr.io/fluxcd/notification-controller@sha256:14fcfa99c1d494a83c026d17bd68b32007eedad681305ca82c39425946184a28
  Normal  Pulling    59m   kubelet            spec.containers{manager}: Pulling image "ghcr.io/fluxcd/notification-controller:rc-aab38700"
  Normal  Pulled     59m   kubelet            spec.containers{manager}: Successfully pulled image "ghcr.io/fluxcd/notification-controller:rc-aab38700" in 6.561s (6.561s including waiting). Image size: 51972671 bytes.

I'm using a Mattermost to IRC bridge (https://github.com/42wim/matterircd) and added some additional logging.

With logging, I can confirm the presence of fallback and is being used:

[2026-06-10T02:11:24Z]  WARN bridge/mattermost: Using fallback text: 'terraform/stg-REDACTED.flux-terraform: error running Init: rpc error: code = Internal desc = There are some problems with the CLI configuration:'
|12:11 <is-flux-bot> [wc544…] terraform/stg-REDACTED.flux-terraform: error running Init: rpc error: code = Internal desc = There are some problems with the CLI configuration:
|12:11 <is-flux-bot> ┃ terraform/stg-REDACTED.flux-terraform
|12:11 <is-flux-bot> ┃ error running Init: rpc error: code = Internal desc = There are some problems with the CLI configuration:
|12:11 <is-flux-bot> ┃ ╷
|12:11 <is-flux-bot> ┃ │ Error: The specified plugin cache dir /home/runner/.terraform.d/plugin-cache/ cannot be opened: stat /home/runner/.terraform.d/plugin-cache/: no such file or directory
|12:11 <is-flux-bot> ┃ │
|12:11 <is-flux-bot> ┃ ╵
|12:11 <is-flux-bot> ┃

As well as an earlier applied successfully message:

[2026-06-10T02:05:31Z]  WARN bridge/mattermost: Using fallback text: 'terraform/stg-REDACTED.flux-terraform: Applied successfully'
|12:05 <is-flux-bot> [ghej3…] terraform/stg-REDACTED.flux-terraform: Applied successfully
|12:05 <is-flux-bot> ┃ terraform/stg-REDACTED.flux-terraform
|12:05 <is-flux-bot> ┃ Applied successfully
|12:05 <is-flux-bot> ┃ summary
|12:05 <is-flux-bot> ┃ Terraform event detected

Messages shown via the Mattermost UI is unchanged, as expected.

@matheuscscp matheuscscp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! 🚀

Just one nit. Please fix, rebase with upstream main and force-push 🙏

Comment thread internal/notifier/slack.go Outdated
Signed-off-by: Haw Loeung <haw.loeung@canonical.com>
@hloeung
hloeung force-pushed the slack-notifications-include-fallback branch from 0ffa32f to 13b0249 Compare June 10, 2026 08:16
@hloeung

hloeung commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Done! Thanks @matheuscscp, much appreciated.

@matheuscscp
matheuscscp merged commit de47f1f into fluxcd:main Jun 10, 2026
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants