Commit Graph

265 Commits

Author SHA1 Message Date
Stefan Prodan 3aba5bbd39
Update Helm APIs to v1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-05-02 21:00:30 +03:00
Timur Demin 531c5873e7 Alertmanager: Change timestamp label to .StartsAt
notification-controller posted all outgoing Alertmanager alerts with
"timestamp" label, effectively preventing grouping alerts related to the
same resource and forcing users to configure a separate alert receiver
with `send_resolved: false`.

This changes it to instead set "startsAt", which was previously set
(automatically by Alertmanager) to alert posting time. "endsAt" remains
unset, as we have no way of figuring that out but the reconciliation
interval of the resource that generated the alert, which can currently
only be found out by making a Kubernetes API round-trip.

Note that this requires users to adapt alert templates that relied on
.Labels.Timestamp.

Signed-off-by: Timur Demin <me@tdem.in>
2024-04-27 16:20:12 +05:00
Gaurav Dasson 633e33bf4b Add support for Bitbucket Context path - Fix issue #742
Signed-off-by: Gaurav Dasson <gaurav.dasson@gmail.com>
2024-04-20 23:56:03 -05:00
al-lac 94ce6da0f2 Add severity to opsgenie Details payload
Co-authored-by: souleb <bah.soule@gmail.com>
Signed-off-by: al-lac <lackner.alex@gmail.com>
2024-04-19 14:36:35 +02:00
Soule BA e3ae7c2d48
refactor notifier factory
Signed-off-by: Soule BA <bah.soule@gmail.com>
2024-04-09 22:21:11 +02:00
Stefan Prodan 952ccd000f
User the password as fallback for Git provider token auth
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-04-09 18:59:04 +03:00
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
adam b4949b6e05 Implement CDEvents Receiver
Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Added CDEvents Receiver

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Added CDEvent Validation + Tests

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Small changes to CDEvent Receiver

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

More CDEvents Tests and Docs added

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Adding imports to go.mod

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

small changes + manifests and formatting

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Changing string compare to EqualFold

Signed-off-by: adamkenihan <adam.kenihan@est.tech>
2024-03-27 10:36:51 +00:00
Anatoly Medvedkov bf918b9b3c Fix Telegram MarkdownV2 escaping
Current implementation was missing '*' symbol.

Signed-off-by: Anatoly Medvedkov <32126+coding4food@users.noreply.github.com>
2024-03-21 13:41:04 +03:00
Stefan Prodan aef940033c
Fix timout propagation for alerts
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-03-07 16:30:39 +02:00
Stefan Prodan 32c59b2474
Fix BitBucket status update panic
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-01-30 15:23:38 +02:00
Stefan Prodan 5ed66321a9
Update API to Kubernetes v1.28.6
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-01-29 15:39:57 +02:00
Arthur ANDRIEU 5371d8a79d fix(grafana-provider): replace ":" character in eventMetadata
Signed-off-by: Arthur Andrieu  <arthur.andrieu@gmail.com>
2024-01-11 19:16:00 +01: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
Hector Fernandez 39a3853c5c replace whilp/git-urls module by chainguard-dev/git-urls
Signed-off-by: Hector Fernandez <hector@chainguard.dev>
2023-12-06 09:38:59 +01:00
Toby Watson 427d20046e
Add NATS provider to v1beta3
Signed-off-by: Toby Watson <SkullKidCode@users.noreply.github.com>
2023-11-30 23:19:21 +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 84e1d74e32 Add alert and provider reconcilers for migration
Add new Alert and Provider reconcilers to perform migration to static
objects. The new Alert and Provider APIs don't contain any status. When
the existing Alerts and Providers are queries using the new API client,
the status would be dropped. A subsequent write of the object to update
the object in api-server will migrate the objects to the new version and
drop the status.
For the stale finalizers on the objects, the new reconcilers ensure that
the finalizers get removed.

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
Sunny 36bc6529ae Remove Alert and Provider reconcilers
In v1beta3 API, Alert and Provider are static objects and don't need
reconcilers.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 4bf469e61b Add Alert and Provider v1beta3 API
v1beta3 API for Alert and Provider makes them static objects, removing
the status subresource and spec fields that are relevant to dynamic
objects with reconcilers.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Stefan Prodan 49d510de81
Update dependencies to Kubernetes v1.28
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-11-21 13:41:08 +02:00
gdasson 504dc991cc Adding bitbucketserver provider for git commit status
Signed-off-by: gdasson <gaurav.dasson@gmail.com>
2023-11-20 23:17:04 -06:00
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
Hidde Beydals edb6a54e23
misc: take errs into account
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-11 15:01:35 +02:00
Hidde Beydals bdda58062f
misc: handle `strings.Title` deprecation
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-11 15:01:29 +02:00
Hidde Beydals 16fb90ed84
misc: remove redundant `break` statements
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-10 12:07:32 +02:00
Hidde Beydals 23d57eb9d3
misc: use `strings.EqualFold`
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-10 12:07:31 +02:00
Hidde Beydals 30db06d0df
misc: do not capitalize err strings
Except for where names are being used (e.g. `Authorization` header,
Nexus, etc.)

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-10 12:07:30 +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
Gerard Krupa f8cba731d2 Remove checks for user/channel in Rocket notifier
For issue #594. RocketChat webhook integrations have a channel and
username configured against them so an explicit username and channel
name are not required.

Signed-off-by: Gerard Krupa <github@krupa.me.uk>
2023-08-23 11:44:55 +02:00
Michael Parker 71ed90ee8c
feat: create datadog notification provider
Signed-off-by: Michael Parker <michael@parker.gg>
2023-08-15 11:36:54 +03:00
Sunny 72c5b1fc6e Delete stale metrics on object delete
The metrics helper now accepts owned finalizers to determine if an
object is no longer managed by the controller and is being deleted, and
deletes the metrics associated with the object.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-08-15 02:37:58 +05:30
Somtochi Onyekwere 4f5d2dfdb8 use TrimPrefix instead of TrimLeft
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2023-08-01 16:31:15 +01:00
Sunny 937da68766
Handle delete before adding finalizer
In Reconcile() methods, move the object deletion above add finalizer.
Finalizers can't be set when an object is being deleted.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-07-26 00:24:13 +05:30
Martin Kemp dbdc4dee73
Add support for PagerDuty
Signed-off-by: Martin Kemp <me@martinke.mp>
2023-06-27 10:52:24 +02:00
Stefan Prodan 749a6c4cb7
Update dependencies
- k8s.io/* v0.27.3
- cloud.google.com/go/pubsub v1.31.0
- github.com/Azure/azure-event-hubs-go/v3 v3.6.0
- github.com/getsentry/sentry-go v0.22.0
- github.com/google/go-github/v53 v53.2.0
- github.com/ktrysmt/go-bitbucket v0.9.60
- github.com/xanzy/go-gitlab v0.86.0
- github.com/fluxcd/pkg/runtime v0.39.0

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-06-27 11:16:42 +03:00
Max Jonas Werner 61cd4d0365
Improve error messages in Gitea notifier
This change makes identifying the source of certain errors easier,
e.g. in test failures or container logs.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-06-21 08:42:57 +02:00
Max Jonas Werner 1e851d47fa
Make Gitea tests independent of 3rd-party service
try.gitea.io, used before this change for testing the Gitea notifier,
has been provisioned with a bug that broke the tests. Now, the tests
are run against a mock HTTP server mimicking parts of Gitea's API so
that the tests don't rely on that 3rd-pary service, anymore.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-06-20 15:10:20 +02:00
Matheus Pimenta 04cea9d51e Add Provider for Google Pub/Sub Topic
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Co-authored-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
Co-authored-by: Max Jonas Werner <makkes@users.noreply.github.com>
Co-authored-by: Sunny <darkowlzz@protonmail.com>
2023-06-16 17:08:11 +01:00
Matheus Pimenta bd1c659ffb Fix TestProviderReconciler_Reconcile/finalizes_suspended_object to use patch instead of update
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-06-16 13:25:19 +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
Hidde Beydals b7cccbee81 Prefix event key attributes with identifier
This to prevent collisions between different event attributes.

For example when first an event with revision `foo` is received
without a token, after which a token `foo` is received without a
revision.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-05-24 15:52:46 +02: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
Matheus Pimenta 4e05bc8ee2 Include eventv1.MetaTokenKey on event rate limiting key calculation
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-24 11:30:14 +02:00
Stefan Prodan 963b3da8a7
Rename controllers to controller
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-05-24 10:58:18 +03:00
Sanskar Jaiswal 24b84e29b6
update deps and Kubernetes to 1.27.2
* github.com/fluxcd/pkg/apis/event => v0.5.0
* github.com/fluxcd/pkg/apis/meta => v1.1.0
* github.com/fluxcd/pkg/git => v0.12.1
* github.com/fluxcd/pkg/runtime => v0.37.0
* github.com/fluxcd/pkg/ssa => v0.28.0
* github.com/getsentry/sentry-go => v0.21.0
* github.com/ktrysmt/go-bitbucket => v0.9.58
* github.com/onsi/gomega => v1.27.7
* github.com/stretchr/testify => v1.8.3
* golang.org/x/oauth2 => v0.8.0
* k8s.io/api => v0.27.2
* k8s.io/apimachinery => v0.27.2
* k8s.io/client-go => v0.27.2
* sigs.k8s.io/controller-runtime => v0.15.0-beta.0

Changes made due to breaking changes in controller-runtime v0.15:

* Watches requires a plain `client.Object` instead of a `source.Kind` object.
* `handler.MapFunc` requires a Go context.
* `ctrl.Options.Namespace` was moved to `ctrlcache.Options.Namespaces`.
* `ctrl.Options.ClientDisableCacheFor` was moved to `ctrlclient.CacheOptions.DisableFor`.
* `ctrl.Options.Port` has been deprecated and removed.
* Use `MaxConcurrentReconciles` and `RecoverPanice` in `config.Controller` instead of `controller.Options`.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-05-24 10:36:20 +03:00