Skip to content

Conversation

@nutmos
Copy link
Contributor

@nutmos nutmos commented Jun 23, 2025

Description

Add global config support in the alert manager for WeChat.

Type of change

What type of changes does your code introduce to the Prometheus operator? Put an x in the box that apply.

  • CHANGE (fix or feature that would cause existing functionality to not work as expected)
  • FEATURE (non-breaking change which adds functionality)
  • BUGFIX (non-breaking change which fixes an issue)
  • ENHANCEMENT (non-breaking change which improves existing functionality)
  • NONE (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)

Verification

Using the unit test for validation.

Changelog entry

- Add support for API URLs in the global configuration for the alert manager for WeChat

Relate #7622

@nutmos nutmos requested a review from a team as a code owner June 23, 2025 14:07
@nutmos nutmos force-pushed the feat/add-wechat-global-config branch from 0fd106d to 0f61c4e Compare June 28, 2025 01:40
Copy link
Member

@AshwinSriram11 AshwinSriram11 left a comment

Choose a reason for hiding this comment

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

LGTM for the most part, just a few suggestions. Maybe @simonpasquier could also take a look

wantErr: true,
},
{
name: "valid global config telegram api url",
Copy link
Member

Choose a reason for hiding this comment

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

It might be better to add Telegram test cases in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AshwinSriram11 Both Telegram and Jira are duplicated from the existing config that was already merged. I removed all of them in the latest comment already.

wantErr: true,
},
{
name: "valid global config jira api url",
Copy link
Member

Choose a reason for hiding this comment

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

Same for the jira ones

wantErr: true,
},
{
name: "invalid global config wechat config missing secret",
Copy link
Member

Choose a reason for hiding this comment

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

We can also have a test case for an empty APICorpID

Copy link
Contributor Author

@nutmos nutmos Jun 28, 2025

Choose a reason for hiding this comment

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

@AshwinSriram11 I tried writing some test cases but it seems not to produce error as expected. Is it expected to be tested in E2e?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so, maybe we need to validate this manually in the convertGlobalWeChatConfig

Let's wait for @simonpasquier or @slashpai to confirm this

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we could test in the e2e tests but the validation rules are simple enough that I wouldn't mandate it. It's required for more complex validations like regex.

Copy link
Member

@AshwinSriram11 AshwinSriram11 left a comment

Choose a reason for hiding this comment

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

Other than the one test case we discussed, everything looks great 👍

out.WeChatAPISecret = apiSecret
}

if in.APICorpID != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Like I mentioned, maybe we need to do the check here but let's wait

@nutmos nutmos marked this pull request as draft June 30, 2025 12:13
@nutmos nutmos force-pushed the feat/add-wechat-global-config branch from 427c2ae to bf00bd4 Compare July 1, 2025 12:39
@pull-request-size pull-request-size bot removed the size/L label Jul 1, 2025
@pull-request-size pull-request-size bot added size/L and removed size/XL labels Jul 1, 2025
}

if in.APICorpID != nil {
if *in.APICorpID == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be prevented by the kubebuilder validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to do so but @AshwinSriram11 mentioned before to have a check logic implemented here as well. I'm not sure what is the practice I should follow.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry if I misguided you. I was not sure what would be the correct method and asked for @simonpasquier's advice. I would suggest proceeding with the original method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AshwinSriram11 No problem. I will proceed with the original way.

@nutmos nutmos marked this pull request as ready for review July 3, 2025 13:54
@nutmos
Copy link
Contributor Author

nutmos commented Jul 3, 2025

@slashpai @simonpasquier This is ready to review now.

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

Thanks!

@simonpasquier simonpasquier enabled auto-merge (squash) July 3, 2025 14:22
@simonpasquier simonpasquier merged commit ad08c6c into prometheus-operator:main Jul 3, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants