Commit Graph

59 Commits

Author SHA1 Message Date
Stefan Prodan 6ba1a713fe
Sanitize provider data loaded from secret
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-04-09 18:35:01 +03:00
Sunny 68c38244cc Exclude eventv1.MetaTokenKey from event metadata
eventv1.MetaTokenKey is required to be considered in rate limiting but
it is only for internal use by flux components and should not be sent to
the alert provider. Remove eventv1.MetaTokenKey from the metadata of
event before processing the event for various matching alerts.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-12-13 23:13:38 +05:30
Matheus Pimenta 143a0b3ee0 Remove URL syntax validation for provider address entirely
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-12-12 19:01:31 +00:00
Max Jonas Werner 52d8945284
Cap provider address at 2048 bytes
The provider address is already capped at 2048 bytes in the CRD and
this commit adds the same upper limit when reading the address from a
Secret.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-11-28 12:31:20 +01:00
Sunny 6df2c74b2a event_handler: Use proper ctx for post fail log
Use the context containing proper information about the event for
logging. Previously, the logged error didn't contain any information
about the event, alert or the involved object.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 19a60e98ea event handler: Add k8s events for Alerts
Emit events in the event handler along with logs on the respective alert
to make the message visible on the alert it belongs to.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 80f7237673 Refactor event handler
- Break down the EventServer.handleEvent() implementation into multiple
  smaller functions which are extensively tested on their own.
  - New implementation of filter Alerts for Event
  - New implementation of Event matches Alert
- Remove any readiness check on Alert or Provider.
- Add kubebuilder marker for generating RBAC permissions to create and
  patch events, and query Alert and Provider objects.
- Convert the event handler test from controllers/ dir to work with
  just EventServer without any reconciler, keeping all the test cases
  and slightly modified test set up code.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Hidde Beydals 3dce75a07e
misc: fix hypothetical implicit memory aliasing
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-11 15:02:56 +02:00
Somtochi Onyekwere 23e733b9c7 use kubernetes tls style secret in provider
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2023-08-23 14:06:15 +01:00
Matheus Pimenta ae6cc4b4f6 Reduce logging repeated code in event server
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-06-12 14:26:59 +01:00
Matheus Pimenta 8c11d8a19b Fix Alert .spec.eventMetadata behavior
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-24 11:27:27 +01:00
Hidde Beydals 49122b90b1
Merge pull request #517 from matheuscscp/fix-rate-limit
Fix revision discarded on event rate limiting key calculation
2023-05-17 09:33:50 +02:00
Matheus Pimenta a8af5647e8 Fix revision discarded on event rate limiting key calculation
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-11 20:10:38 +01:00
Matheus Pimenta e9d1fb3d86 Add event metadata field to Alert spec
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-11 18:14:49 +01:00
Matheus Pimenta 9b7a80942f Add InclusionList to Alert CRD
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Co-authored-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-05-02 10:05:16 +01:00
Max Jonas Werner ec03bd20a3
Introduce v1 API and bump Receiver version to v1
This commit bumps the Receiver API version to v1 in preparation of
the Flux GitOps GA milestone
(https://fluxcd.io/roadmap/#flux-gitops-ga-q1-2023).

We are now actively maintaining two versions of the notification API
group in parallel: v1 which currently only holds the Receiver kind and
v1beta2 for all other kinds.

Since we haven't run into this situation before, I had to change the
way we expose the API docs in ./docs/api: The directory now has
sub-directories for each active API version. Therefore we need to
change our scripts in the website repository to take this change into
account so that we expose both API group version at
https://fluxcd.io/flux/components/notification/api/. This change is
implemented in https://github.com/fluxcd/website/pull/1427.

refs #436

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-03-30 15:40:54 +02:00
Hidde Beydals fd86289062 Add digest metadata event key to ignore list
Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-02-13 10:28:34 +01:00
Stefan Prodan 9f2d0e1a6c Generate unique commit status updates
Use the Provider cluster assigned UID to compose a unique commit status
ID to avoid name collisions when multiple clusters write to the same
repository.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-12-09 12:05:51 +00:00
Stefan Prodan 974a77da00 Refactor reconcilers and introduce v1beta2 API
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-12-09 11:03:53 +00:00
Stefan Prodan 224b12a2b8 Refactor notifiers to use Event API v1beta1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-11-22 11:00:25 +00:00
Somtochi Onyekwere 25eeaf46dd Add .spec.timeout to Provider
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-31 11:25:09 +01:00
Philip Laine 82253a9558 Fix context cancel defer
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2022-08-26 18:02:47 +02:00
Philip Laine 2c69c847d3 Add context to Post function
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2022-07-27 18:26:28 +02:00
Somtochi Onyekwere 9b8586e35d remove line overriding err
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-07-04 16:31:50 +01:00
Somtochi Onyekwere b5f67d4f59 use masktoken pkg for redacting token
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-07-04 16:15:10 +01:00
Paulo Gomes a0dc84e36a
Small fixes
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-05-24 07:20:15 +01:00
Somtochi Onyekwere b30e2458d8 return actual error when regex.Compile fails
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-04-08 16:26:52 +01:00
Somtochi Onyekwere 6477e1500e return error on invalid UTF-8
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-04-08 15:09:18 +01:00
Stefan Prodan 89008fb775 Filter event metadata based on the object group
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-03-23 20:37:46 +01:00
Stefan Prodan 08182712b6
Cleanup metadata fields before alerting
Remove the checksum field from alerts metadata

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-03-21 12:38:06 +02:00
Filipe Sequeira c9040611e5 Add basic auth support to grafana provider
Signed-off-by: Filipe Sequeira <filipe@weave.works>
2022-02-21 12:37:38 +00:00
Filipe Sequeira 95cf1a699d add Proxy to SecretRef
Signed-off-by: Filipe Sequeira <filipe@weave.works>
Co-authored-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-18 11:41:01 +00:00
Somtochi Onyekwere 100e928546 Use metdataclient for getting labels for events
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-02-16 12:58:52 +01:00
Somtochi Onyekwere 519b6a5c5c Add LabelSelectors for Event Sources
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-02-10 11:09:39 +01:00
Stefan Prodan 44c08a2659
Allow disabling cross-namespace event sources
Introduce the flag `--no-cross-namespace-refs` (defaults to false) for allowing cluster admins to disable cross-namespace event sources for alerts.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-28 10:30:31 +02:00
Somtochi Onyekwere 1b0afc2c88 pass pointer to yaml.Unmarshal
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-01-26 14:59:32 +01:00
Moritz Schmitz von Hülst 3c7363234a Pass headers to generic provider through secretRef
Co-authored-by: Moritz Schmitz von H<C3><BC>lst <moritz@hauptstadtoffice.com>
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-01-26 12:39:02 +01:00
Somtochi Onyekwere 19a0daa906 Use conditions helper in reconciler
Co-authored-by: Piaras Hoban <piaras@weave.works>
Co-authored-by: Hidde Beydals <hiddeco@users.noreply.github.com>
Co-authored-by: souleb <bah.soule@gmail.com>
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-11-01 14:20:12 +01:00
Ali AKCA 7ded18f850
chore: Drop deprecated io/ioutil
Signed-off-by: Ali AKCA <ali@akca.io>
2021-10-27 09:44:51 +02:00
Somtochi Onyekwere 996ee365c5 Create function for redacting logs
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-21 16:37:33 +01:00
Somtochi Onyekwere f5d4328cbe Use regex to find and replace token
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-21 11:51:49 +01:00
Somtochi Onyekwere df8150d47b Return an error when request status code is not 200
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-06-07 12:20:57 +01:00
Philip Laine 717a4422b7 Redact token from error log
Signed-off-by: Philip Laine <philip.laine@xenit.se>
2021-05-10 14:43:45 +02:00
Philip Laine 8f3b685f17 Add self signed cert to provider
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2021-04-15 00:08:59 +02:00
Somtochi Onyekwere a99a0bc50d Use deepcopy method for event
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-03-22 09:40:16 +01:00
Stefan Prodan 78fa2d103a
Use controller-runtime structured logging
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-15 14:06:04 +02:00
Michael Bridgen 3e7e99531b Use continue with label rather than a local
`continue` with a label is for exactly this situation.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-02-23 12:39:20 +00:00
Stefan Prodan c640ea8e36
Fix alerts regex filtering
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-23 12:55:57 +02:00
Stefan Prodan 5c9e95ca02
Implement regex exclusions for alerts
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-02-08 15:45:11 +02:00
Stefan Prodan f9fc5db2d4
Add alert summary to notification metadata
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2020-12-06 11:38:28 +02:00