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

Webex Feature/API #5305

Merged
merged 49 commits into from
Aug 2, 2023
Merged

Webex Feature/API #5305

merged 49 commits into from
Aug 2, 2023

Conversation

eumel8
Copy link
Contributor

@eumel8 eumel8 commented Jan 26, 2023

Signed-off-by: Frank Kloeker f.kloeker@telekom.de

Description

Prometheus Alertmanager brings the functionality of Webex Notification. Start of Operator implementation was here
This is the part of API/CRD extension

Type of change

  • 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.)

ref:#5295

Changelog entry

Add Webex configs to AlertmanagerConfig CRD

Signed-off-by: Frank Kloeker <f.kloeker@telekom.de>
@eumel8 eumel8 requested a review from a team as a code owner January 26, 2023 09:05
@eumel8
Copy link
Contributor Author

eumel8 commented Jan 26, 2023

the bundle version needs to bump up

@xiu
Copy link
Contributor

xiu commented Jan 26, 2023

Great!

@eumel8 you can generate the bundle by using make generate. To help with formatting as well, make format and to check the formatting of the docs, make check-docs (https://github.com/prometheus-operator/prometheus-operator#contributing).

I see your tests are not passing, make test-unit can help there (https://github.com/prometheus-operator/prometheus-operator#testing).

@simonpasquier
Copy link
Contributor

pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go Outdated Show resolved Hide resolved
// WebexConfig configures notification via Cisco Webex
// See https://prometheus.io/docs/alerting/latest/configuration/#webex_config
type WebexConfig struct {
SendResolved *bool `json:"sendResolved,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SendResolved *bool `json:"sendResolved,omitempty"`
// Whether to notify about resolved alerts.
SendResolved *bool `json:"sendResolved,omitempty"`

// See https://prometheus.io/docs/alerting/latest/configuration/#webex_config
type WebexConfig struct {
SendResolved *bool `json:"sendResolved,omitempty"`
APIURL string `json:"apiURL,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
APIURL string `json:"apiURL,omitempty"`
// The Webex Teams API URL if different from the default API URL.
APIURL string `json:"apiURL,omitempty"`

APIURL string `json:"apiURL,omitempty"`
RoomID string `json:"roomID,omitempty"`
Message string `json:"message,omitempty"`
HTTPConfig *HTTPConfig `json:"httpConfig,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
HTTPConfig *HTTPConfig `json:"httpConfig,omitempty"`
// HTTP client configuration.
HTTPConfig *HTTPConfig `json:"httpConfig,omitempty"`

Signed-off-by: Frank Kloeker <f.kloeker@telekom.de>
Signed-off-by: Frank Kloeker <f.kloeker@telekom.de>
@eumel8
Copy link
Contributor Author

eumel8 commented Jan 26, 2023

thx for starting review, @xiu @simonpasquier

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.

Can you add comments for each field? Next step is to wire the webex integration in

func (cb *configBuilder) convertReceiver(ctx context.Context, in *monitoringv1alpha1.Receiver, crKey types.NamespacedName) (*receiver, error) {

pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go Outdated Show resolved Hide resolved
pkg/apis/monitoring/v1beta1/alertmanager_config_types.go Outdated Show resolved Hide resolved
Signed-off-by: Frank Kloeker <f.kloeker@telekom.de>
@eumel8
Copy link
Contributor Author

eumel8 commented Feb 3, 2023

just wondering, make generate fails on Ubuntu:

mv github.com/prometheus-operator/prometheus-operator/pkg/client/{versioned,informers,listers} pkg/client
mv: cannot stat 'github.com/prometheus-operator/prometheus-operator/pkg/client/informers': No such file or directory
mv: cannot stat 'github.com/prometheus-operator/prometheus-operator/pkg/client/listers': No such file or directory
make: *** [Makefile:142: k8s-client-gen] Error 1

@xiu
Copy link
Contributor

xiu commented Feb 4, 2023

just wondering, make generate fails on Ubuntu:

mv github.com/prometheus-operator/prometheus-operator/pkg/client/{versioned,informers,listers} pkg/client
mv: cannot stat 'github.com/prometheus-operator/prometheus-operator/pkg/client/informers': No such file or directory
mv: cannot stat 'github.com/prometheus-operator/prometheus-operator/pkg/client/listers': No such file or directory
make: *** [Makefile:142: k8s-client-gen] Error 1

This is not the issue as I see it. Check https://github.com/prometheus-operator/prometheus-operator/actions/runs/4088515306/jobs/7050273000, the step is checking whether all generated content has been committed. It thus runs make generate and does a global diff. In this case, it found changes.

Can you run make generate and commit the changes to your branch and try again?

eumel8 and others added 2 commits February 4, 2023 18:46
Signed-off-by: Frank Kloeker <f.kloeker@telekom.de>
@eumel8
Copy link
Contributor Author

eumel8 commented Feb 4, 2023

@xiu This was the error on my local Ubuntu WSL. I couldn't found out the cause and made make generate on another machine. Maybe there are some hints for build requirements beside make and Go.

@xiu
Copy link
Contributor

xiu commented Feb 4, 2023

@xiu This was the error on my local Ubuntu WSL. I couldn't found out the cause and made make generate on another machine. Maybe there are some hints for build requirements beside make and Go.

Oh, I don't have a Windows machine to try that out unfortunately. Glad you made it work!

@eumel8
Copy link
Contributor Author

eumel8 commented Feb 14, 2023

@simonpasquier I'm not sure, anything else to change here?

@simonpasquier
Copy link
Contributor

@simonpasquier I'm not sure, anything else to change here?

You need to update the convertReceiver() method to convert the Webex configuration from the CRD to the native Alertmanager configuration.

You can take a look at #4726 which did the same thing but for the Telegram integration. Does it make sense?

@fctb
Copy link

fctb commented Mar 17, 2023

any time when it will get unblocked?

@eumel8
Copy link
Contributor Author

eumel8 commented Mar 19, 2023

@fctb It's progressing slowly. I'm a bit overwhelmed with the feature. Any help is appreciated, hopefully it will be over soon.

puffitos and others added 4 commits June 23, 2023 22:06
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@simonpasquier
Copy link
Contributor

@eumel8 I've added a few commits on top of your PR to address my comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

is this change necessary for this PR? Otherwise I'd prefer to revert :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I've reverted the change - if the E2E suite passes, it is indeed not necessary. I'd only changed it, as it didn't work when I ran the E2E tests locally and after debugging I'd found out the issue were the missing fields in the AM Config 🤷

Copy link
Contributor

@puffitos puffitos Jul 6, 2023

Choose a reason for hiding this comment

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

Tests passed, so thanks for reviewing this change as well. Reverted as requested.

@@ -216,7 +216,7 @@ func testPromOperatorStartsWithoutScrapeConfigCRD(t *testing.T) {

restarts, err := framework.GetPodRestartCount(context.Background(), ns, pl.Items[0].GetName())
require.NoError(t, err)
require.Lenf(t, restarts, 1, "expected to get 1 container but got %d", len(restarts))
require.Emptyf(t, restarts, "expected to get 1 container but got %d", len(restarts))
Copy link
Contributor

@puffitos puffitos Jul 6, 2023

Choose a reason for hiding this comment

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

This test was failing on my machine with the message "expected to get 1 container but got 1". On line 213 one Pod is explicitly expected. The GetPodRestartCount will therefore always return a map with at least one container, which should have 0 restarts. The restarts map has therefore a length of at least 1.

Emptyf checks whether the map is empty, which it shouldn't. The error msg is even more cryptic, as it refers to the length of the map, which should be one according to the message. But here we're checking whether the map's nil / empty?

I can't get my head around as to how this tests works 😄 I just wanted to explain, why I made this change and why I didn't consider it unnecessary.

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.

very good! One last nit...

pkg/alertmanager/operator.go Outdated Show resolved Hide resolved
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

Oof, I approved and forgot to merge this one after 3 weeks... sorry! 😅

Approving again and I'll let simon take another look if he wants to :)

I'm putting a reminder to merge it this week if there is no more change requests

@ArthurSens ArthurSens merged commit bfb0d07 into prometheus-operator:main Aug 2, 2023
16 checks passed
@eumel8 eumel8 deleted the feat/webex branch September 28, 2023 13:47
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.

None yet

6 participants