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
Azure Service Discovery resource group filter #10365
Azure Service Discovery resource group filter #10365
Conversation
Signed-off-by: David N Perkins <David.N.Perkins@ibm.com>
Signed-off-by: David N Perkins <David.N.Perkins@ibm.com>
|
@roidelapluie I implemented this using a new config value. Let me know if there's another preferred method to get the resource group. I also don't have access to an Azure account, so not sure how to test these changes. There's not many existing unit tests. |
Signed-off-by: David N Perkins <David.N.Perkins@ibm.com>
|
Thanks for this! It seems like we would need azure users to test this. |
|
@David-N-Perkins Thanks for implementing this. A new optional config value seems to be the best solution for this topic. It's backwards compatible and provide a way to reduce the amount of ARM calls massively if it's a subscription containing a lot of VMs. I'll try out you code changes and give you feedback. But maybe there are other Azure users who can also give feedback. Especially the MSI auth change will be hard to test locally. |
|
@David-N-Perkins Sorry for the late response. I've now tested your branch for ~24h within an AKS cluster. TL;DR: LGTM! @roidelapluie Please merge 😄
I had previously accidentally built a container image from the main branch and was wondering why the parameter shouldn't exist in Before using the right branch there was the following log output: After using the right branch everything worked as expected. Good job! 🚀 |
|
But is this a beaking change for users? Do they need to change their credentials ? |
|
No, it's not a breaking change. I've just tested if the MSI authentication still works with the changes made in this PR. Service Principal and OAuth authentication were not touched and should work as before: prometheus/discovery/azure/azure.go Line 196 in 10b6d00
prometheus/discovery/azure/azure.go Line 201 in 10b6d00
Just the MSI authentication was replaced, as the current methods are deprecated: Furthermore one can omit the |
| var err error | ||
| if len(resourceGroup) == 0 { | ||
| var rtn compute.VirtualMachineScaleSetListWithLinkResultPage | ||
| rtn, err = client.vmss.ListAll(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check the error here to avoid deferring a nil pointer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| result = &rtn | ||
| } else { | ||
| var rtn compute.VirtualMachineScaleSetListResultPage | ||
| rtn, err = client.vmss.List(ctx, resourceGroup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
thanks. I have spin up azure vm's to test this, it indeed works. Added a comment. |
Signed-off-by: David N Perkins <David.N.Perkins@ibm.com>
|
Thanks! |
Added an optional
resource_groupconfiguration for Azure service discovery, which limits the discovery when specified. See issue 10253.Also updated a deprecated azure auth call.