stakater / IngressMonitorController

A Kubernetes controller to watch ingresses and create liveness alerts for your apps/microservices in UptimeRobot, StatusCake, Pingdom, etc. – [✩Star] if you're using it!
https://stakater.com
Apache License 2.0
590 stars 103 forks source link

Pingdom duplicate checks creation #293

Open artemlive opened 3 years ago

artemlive commented 3 years ago

Hello, the community! I have found one major issue with Pingdom API integration. At some point, I discovered that my Pingdom monitoring slots have been significantly reduced. I checked my Pingdom account and found so many checks with the same name. Here is the screenshot with a duplicated check example from Pingdom UI: https://prnt.sc/vbyhjm During the investigation, I found such lines in the IMC log:

time="2020-11-01T23:40:07Z" level=info msg="Error received while listing checks: invalid character '<' looking for beginning of value" time="2020-11-01T23:40:07Z" level=info msg="Creating Monitor: mycompany-software-master-xxx.com"

It means that the API call has been failed and IMC re-created existed monitor, because of some API error (it may be either an API service problem or transport problem, etc) One more important thing that Pingdom allows us to create multiple checks with the same name. Here is the method which returns all existing checks from Pingdom without error checking because of MonitorService interface implementation doesn't have an error in the returning parameters: https://github.com/stakater/IngressMonitorController/blob/221927f05e945a0b08c8c20438a116012c505fad/pkg/monitors/pingdom/pingdom-monitor.go#L65-L83 Then during processing the response from the previous method, IMC generates the error if monitor wasn't found: https://github.com/stakater/IngressMonitorController/blob/221927f05e945a0b08c8c20438a116012c505fad/pkg/monitors/pingdom/pingdom-monitor.go#L62

But in the ReconcileEndpointMonitor we don't check the error itself, so we are able to create a duplicated monitor: https://github.com/stakater/IngressMonitorController/blob/84c61fb87c4c0d7690aca312a9f512b92ba731bc/pkg/controller/endpointmonitor/endpointmonitor_controller.go#L120

I decided to implement the method findMonitorByName without ignoring an error. It may help us to avoid duplicate checks creation. I've refactored error raising algorithm, so it will track only real errors with API calls. If monitor didn't exist, it won't be marked as an error.

As I mentioned before, there is one more big issue, which blocks me to correctly implement the GetAll with an error returning. GetAll is the part of MonitorService that has the method prototype without the error in return parameters. Of course, I could change the interface, but then I won't be able to guarantee that all of my changes to other monitors would be fine, because I don't have enough expertise with other solutions than Pingdom and I found the same way avoiding of GetAll function usage in the uptimerobot monitor. Here is my PR #294 (Which is still in work for that moment)

ahmedwaleedmalik commented 3 years ago

As far as i understand the issue:

Let me know if we can further discuss this or if you have any more queries regarding this.

artemlive commented 3 years ago

@ahmedwaleedmalik hello, thanks for your reply.

  • You need to create a compactor for pingdom to avoid creation of multiple monitors because i think in each reconcile loop it's creating a new monitor in your case probably.

It won't create new monitors every reconciles iteration if there weren't errors during an API call. With the current algorithm, reconcile doesn't check any errors during API calls, it just marks monitor as non-exist and doesn't handle API error itself. Our main issue is if there was a problem with the API request (e.g. some service issue and it responds with 500 HTTP code), which checks whether a monitor exists or it has to be created: https://github.com/stakater/IngressMonitorController/blob/84c61fb87c4c0d7690aca312a9f512b92ba731bc/pkg/controller/endpointmonitor/endpointmonitor_controller.go#L120-L124 So it would create a new monitor even if it does exist because Pingdom allows creating monitors with the same names.

findMonitorByName should not ignore the error and thank you for fixing that. But still in your case the method to retrieve a monitor should ensure that the correct monitor is being retrieved.

I think GetByName method is responsible for that If I got it right. We should check only if it's not null, if not we have to update exist monitor. Сorrect me if I'm wrong.

tomjohnburton commented 3 years ago

I'm getting this error too. Any updates to be had?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 30 days since being marked as stale.

Dadavan commented 1 year ago

Hey guys, this is still happening, are you willing to accept a PR for this?

devopstagon commented 1 year ago

This is still broken :'(

karl-johan-grahn commented 12 months ago

Reopening issues that inadvertently were closed as stale

davidgibbons commented 11 months ago

This is basically unusable as is for pingdom or statuscake. It just makes a giant mess.

ThommyH commented 8 months ago

is this ever getting fixed?

ShawnUCD commented 7 months ago

I can confirm this is still happening with chart version 2.1.49. I can scale up the ingressmonitorcontroller deployment and watch the checks in Statuscake tick upward until we hit our limit (300).

abhishek-annigeri-brainbits commented 3 months ago

@karl-johan-grahn @rasheedamir - Can someone please look into this? This is pending from long time.

cwells commented 2 months ago

From my own experience writing a Puppet Pingdom module a few years ago, this is a flaw (one of many) in the Pingdom API. There's no supported way to uniquely identify a check as they allow duplicate names. IIRC I ended up tagging my checks with a unique hash so I could search for them.

Best bet: don't use Pingdom. I'm fairly confident their web UI doesn't even use their own API.

sidick commented 2 months ago

https://developers.statuscake.com/guides/api/ratelimiting may be useful for StatusCake, as I'm seeing the duplicate checks when it gets an HTTP 429 error