Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add initial support for alertmanager external-url #622

Merged
merged 4 commits into from
Oct 25, 2023

Conversation

pintohutch
Copy link
Collaborator

Resolves #352

@pintohutch
Copy link
Collaborator Author

Just making sure the test fails properly before fixing.

@pintohutch
Copy link
Collaborator Author

Hey @bwplotka PTAL

@pintohutch
Copy link
Collaborator Author

cc @bernot-dev as this may be relevant to default-off alertmanager/rule-evaluator

Copy link
Collaborator

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Epic, thanks! Some nits, otherwise LGTM. Sorry for review lag.

}))
t.Run("config set", t.subtest(func(ctx context.Context, t *OperatorContext) {
t.Parallel()
testAlertmanagerConfig(ctx, t, secret, key)
}))
}

func testAlertmanagerDeployed(ctx context.Context, t *OperatorContext) {
func testAlertmanagerDeployed(ctx context.Context, t *OperatorContext, spec *monitoringv1.ManagedAlertmanagerSpec) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func testAlertmanagerDeployed(ctx context.Context, t *OperatorContext, spec *monitoringv1.ManagedAlertmanagerSpec) {
func testAlertmanagerDeployed(ctx context.Context, t *OperatorContext, config *monitoringv1.ManagedAlertmanagerSpec) {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super small nit, but I was quite confused thinking initially this variable as used down there is Alertmanager spec not alertmanager configuration spec (kind of) - a bit more explicitness might help

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure no prob. Changed it to config.

}
// We're mainly interested in the dynamic flags but checking the entire set including
// the static ones is ultimately simpler.
if externalURL := spec.ExternalURL; externalURL != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit confused again - can't we prepare wantArgs before looping through Alertmanager statetful set containers? It feel like you do it inside this loop for a reason, but I can't find any 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was honestly just following convention elsewhere 1, 2 in our e2e tests without thinking too much about it.

I'm tempted to leave it this way for convention, where a separate PR can concisely and atomically do a cleanup (added TODOs). WDYT?

@@ -986,6 +986,9 @@ spec:
required:
- key
x-kubernetes-map-type: atomic
externalURL:
type: string
description: ExternalURL is the external URL the managed Alertmanager will be available under. This is used for generating links back to the Alertmanager itself in fired alerts.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it wouldn't be easier to put exact flag description. It's essentially more than just alert link, it also fixes UI when reverse proxies are used. WDYT?

Suggested change
description: ExternalURL is the external URL the managed Alertmanager will be available under. This is used for generating links back to the Alertmanager itself in fired alerts.
description: The URL under which Alertmanager is externally reachable (for example, if Alertmanager is served via a reverse proxy). Used for generating relative and absolute links back to Alertmanager itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Alertmanager. If omitted, relevant URL components will be derived automatically.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. Done.

Copy link
Collaborator Author

@pintohutch pintohutch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! Pushed up some fixes

}))
t.Run("config set", t.subtest(func(ctx context.Context, t *OperatorContext) {
t.Parallel()
testAlertmanagerConfig(ctx, t, secret, key)
}))
}

func testAlertmanagerDeployed(ctx context.Context, t *OperatorContext) {
func testAlertmanagerDeployed(ctx context.Context, t *OperatorContext, spec *monitoringv1.ManagedAlertmanagerSpec) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure no prob. Changed it to config.

}
// We're mainly interested in the dynamic flags but checking the entire set including
// the static ones is ultimately simpler.
if externalURL := spec.ExternalURL; externalURL != "" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was honestly just following convention elsewhere 1, 2 in our e2e tests without thinking too much about it.

I'm tempted to leave it this way for convention, where a separate PR can concisely and atomically do a cleanup (added TODOs). WDYT?

@@ -986,6 +986,9 @@ spec:
required:
- key
x-kubernetes-map-type: atomic
externalURL:
type: string
description: ExternalURL is the external URL the managed Alertmanager will be available under. This is used for generating links back to the Alertmanager itself in fired alerts.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. Done.

@pintohutch pintohutch merged commit 9fcee3d into main Oct 25, 2023
@pintohutch pintohutch deleted the pintohutch/ext-url branch October 25, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no way to set web.external-url on Managed Alertmanager
2 participants