Skip to content

Commit

Permalink
vmalertmanager: ignore content of configSecret if name clashes with d…
Browse files Browse the repository at this point in the history
…efault

Ignores any content from secret define at cr.spec.configSecret, if it name clashes with name of the secret created by operator.

#954
  • Loading branch information
f41gh7 committed May 16, 2024
1 parent 0829591 commit 74889ef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/victoriametrics/v1beta1/vmalertmanager_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func (r *VMAlertmanager) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &VMAlertmanager{}

func (r *VMAlertmanager) sanityCheck() error {
if r.Spec.ConfigSecret == r.ConfigSecretName() {
return fmt.Errorf("cr.spec.configSecret=%q cannot have the same secret name as secret created by operator for storing config. Please change it", r.ConfigSecretName())
}
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions controllers/factory/alertmanager/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ func createDefaultAMConfig(ctx context.Context, cr *victoriametricsv1beta1.VMAle
switch {
// fetch content from user defined secret
case cr.Spec.ConfigSecret != "":
if cr.Spec.ConfigSecret != cr.ConfigSecretName() {
l.Info("ignoring content of ConfigSecret, since it has the same name as secreted created by operator for config", "secretName", cr.Spec.ConfigSecret)
break
}
// retrieve content
secretContent, err := getSecretContentForAlertmanager(ctx, rclient, cr.Spec.ConfigSecret, cr.Namespace)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ aliases:

## Next release

- [vmalertmanager](./api.md#vmalertmanager): ignores content of `cr.spec.configSecret` if it's name clashes with secret used by operator for storing alertmanager config. See this [issue](https://github.com/VictoriaMetrics/operator/issues/954) for details.

## [v0.44.0](https://github.com/VictoriaMetrics/operator/releases/tag/v0.44.0) - 9 May 2024

- [vmagent](./api.md#vmagent): adds new fields into `streamAggrConfig`: `dedup_interval`, `ignore_old_samples`, `keep_metric_names`, `no_align_flush_to_interval`. It's only possible to use it with v1.100+ version of `vmagent`. See this [issue](https://github.com/VictoriaMetrics/operator/issues/936) for details.
Expand Down

0 comments on commit 74889ef

Please sign in to comment.