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
resources.GroupClient methods fail due to invalid, hard-coded API version #741
Comments
Howdy @axw, This is a known issue. To get you unblocked immediately, you can hack your way through by creating a custom Preparer method to wrap the call with an adjustment to an API Version that you choose. For context, you can find a GroupClient PreparerMethod here:
However, the underlying problem you're hitting is insidious, and something we've been working to fix for quite some time now. Basically, the trouble is that each API Version of a service in Azure is independent from the others. This means that between API Versions there is no guarantee that models generated to target one API Version will match the ones need to call another. I've created an experimental branch that exposes models for all API Versions here: azure-sdk-for-go/service/resources/management in 8150bd The majority of the time, things should just work if you tweak the API Version parameter, but we want to expose a better more static way of doing things. Hence the proliferation of packages. I hope this is helpful! -Martin |
@marstr thanks for the suggestion. I should have said to start with, and saved you some time, that I worked around it. I did something similar: I just called the Preparer/Sender/Responder in sequence, changing the URL after the Preparer. Re your branch: I'm glad to see per-version code generation, but I don't think that helps with the problem I'm dealing with, does it? In case we're talking about different things, I'll restate in a bit more detail. In my case, what I'm doing is:
In the GetByID and CreateOrUpdateByID calls, we must specify resource-type specific API versions. We pick the most recent API version returned in the provider listing for each type. (If you have any alternative suggestions on ways to update tag values for all resources in a resource group, I'd be happy to hear them.) |
Thanks for getting back to me, @axw. I see what you're saying now. I'll go chase down what the service teams suggest in terms of dispatching on API Version based on resource type and get back to you. |
@axw can you please share your solution implementation? when I try to call |
@itaysk sure. It's got all of our project's foibles woven in, so ask questions if anything's unclear. updateResourceControllerTag is the method that calls GetByID and CreateOrUpdateByID: https://github.com/juju/juju/blob/5c90f6bd8c80efbff53d616e591105b074423eea/provider/azure/environ.go#L1312. updateResourceControllerTag is called by AdoptResources: https://github.com/juju/juju/blob/5c90f6bd8c80efbff53d616e591105b074423eea/provider/azure/environ.go#L1242. In AdoptResources we construct a resources.GroupClient from a resources.ManagementClient we prepared earlier. The ManagementClient is contructed here: https://github.com/juju/juju/blob/5c90f6bd8c80efbff53d616e591105b074423eea/provider/azure/environ.go#L174. The code to fetch resource provider IDs, called by AdoptResources: https://github.com/juju/juju/blob/5c90f6bd8c80efbff53d616e591105b074423eea/provider/azure/utils.go#L64 |
@axw Thanks! |
@axw your |
@itaysk I'm happy for you to take a copy, but I just realised I put the wrong license on the code. It should be licensed the same as the azure-sdk-for-go code, as it was derived from it; instead it is licensed AGPLv3, like the rest of Juju. I'll fix that. |
juju/juju#7819 - just needs someone to sign off |
Ping @marstr |
I'm in the process of updating Juju to use to the latest Azure SDK for Go. One of our code paths uses resources.GroupClient to update the tags for all resources in a resource group.
The clients previously stored
APIVersion
as a field, which we could override, and used that as the value of theapi-version
query parameter in requests. Now, the API version is hard-coded inside client methods and cannot be overridden. That's fine when dealing with a specific resource type, but when dealing with generic resources, the caller must be able to specify the API version of the resource type.The text was updated successfully, but these errors were encountered: