Skip to content

[backport v2.14.2] AlertmanagerConfigs can't be created through the UI #17356

@rancher-ui-project-bot

Description

@rancher-ui-project-bot

This is a backport issue for #17347, automatically created via GitHub Actions workflow initiated by @codyrancher

Original issue body:

Setup

  • Rancher version: 2.14.0 or newer
  • Rancher Monitoring version: 109.0.0+up80.9.1-rancher.5 or newer
  • Rancher UI Extensions: none?
  • Browser type & version: irrelevant

Describe the bug
Using Rancher 2.14 and the Rancher Monitoring chart 109.0.0, AlertmanagerConfigs can't be created through the UI. This is because the Rancher Monitoring chart now includes a ValidatingWebhook to validate AlertmanagerConfigs and the YAML generated by the UI is not valid.

To Reproduce

  1. Install Rancher Monitoring version 109.0.0 or newer
  2. Go to Monitoring > Alerting > AlertmanagerConfigs and click Create
  3. Set a name and click Create

Result
You will get the following error:

admission webhook "alertmanagerconfigsvalidate.monitoring.coreos.com" denied the request: AlertmanagerConfig is invalid

Expected Result
The AlertmanagerConfig should be created.

Screenshots
Image

Additional context
As mentioned before, this is now an issue because AlertmanagerConfigs are now validated by a ValidatingWebhook.

There's two issues with the YAML that the UI generates:

apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
  name: test
  namespace: cattle-monitoring-system
spec:
  receivers:
  route:
    groupInterval: 5m
    groupWait: 30s
    repeatInterval: 4h
    match:
      {}
    matchRe:
      {}
  1. spec.route.match and spec.route.matchRe do not exist in the CRD and should not be there
  2. The route must define a receiver under spec.route.receiver and it must exist in spec.receivers, but the UI does not allow you to create a Receiver until the AlertmanagerConfig is created (the button to create a Receiver is disabled).

Both can be checked by applying the YAML manually via the console:

Error from server (BadRequest): error when creating "amc.yaml": AlertmanagerConfig in version "v1alpha1" cannot be handled as a AlertmanagerConfig: strict decoding error: unknown field "spec.route.match", unknown field "spec.route.matchRe"

Then if you remove those fields:

The "alertmanagerconfigs" is invalid: : root route must define a receiver

And after setting spec.route.receiver:

The "alertmanagerconfigs" is invalid: : receiver "test" not found

Example of a silly but valid YAML. spec.route.match and spec.route.matchRe are not present and the route references (spec.route.receiver) an existing receiver in spec.receivers.

apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
  name: test
  namespace: cattle-monitoring-system
spec:
  receivers:
    - name: test
  route:
    groupInterval: 5m
    groupWait: 30s
    repeatInterval: 4h
    receiver: test

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions