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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>