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

Delete AKS cluster failed #226

Open
serbrech opened this issue Mar 5, 2020 · 6 comments
Open

Delete AKS cluster failed #226

serbrech opened this issue Mar 5, 2020 · 6 comments
Labels
bug Something isn't working no-stale

Comments

@serbrech
Copy link

serbrech commented Mar 5, 2020

I first thought we have a bug in AKS for old clusters, but I could delete it just fine in the portal or CLI.

I think you're just not including an api-version in the delete command for some reason.

{
  "error": {
    "code": "NoRegisteredProviderFound",
    "message": "No registered resource provider found for location 'westus2' and API version 'MISSING' for type 'managedClusters'. The supported api-versions are '2017-08-31, 2018-03-31, 2018-08-01-preview, 2019-02-01, 2019-04-01, 2019-06-01, 2019-08-01, 2019-10-01, 2019-11-01, 2020-01-01, 2020-02-01'. The supported locations are 'eastus, westeurope, francecentral, centralus, canadacentral, canadaeast, uksouth, westus, westus2, australiaeast, northeurope, japaneast, japanwest, eastus2, southcentralus, northcentralus, southeastasia, australiasoutheast, ukwest, southindia, centralindia, eastasia, koreasouth, koreacentral, southafricanorth, brazilsouth, germanynorth, switzerlandnorth, switzerlandwest, germanywestcentral, uaenorth, norwayeast, norwaywest'."
  }
}
@serbrech
Copy link
Author

serbrech commented Mar 5, 2020

tried to figure out where I could track this issue, but I'll wait for you to see this and point me in the right direction.
A drawback of generated codebase, it's hard to figure things out ;)

@lawrencegripper lawrencegripper added the bug Something isn't working label Mar 6, 2020
@lawrencegripper
Copy link
Owner

lawrencegripper commented Mar 6, 2020

Interesting! thanks for raising this

@stuartleeks I you have a good starter for 10 on this one?

@github-actions
Copy link

github-actions bot commented Apr 5, 2020

Flagging stale issue. Actions will close this issue in the next 5 days unless action is taken.

@lawrencegripper
Copy link
Owner

Still need to look into this one. Things a bit hectic without childcare at the moment so behind on stuff.

@lawrencegripper
Copy link
Owner

So looks like this isn't directly related to the auto-gen code. Have a working theory I'm looking at.

Currently the ARMClient uses the Providers API call to get back all the supported API versions. It then rather simplistically builds up a map of RP->Version or if it can't adds Missing as the API Version. My guess is something went wrong with populating the provider dictionary or a race occurred and the provider dictionary was still being populated while the delete was called.

func GetAPIVersion(armType string) (string, error) {
value, exists := resourceAPIVersionLookup[armType]
if !exists {
return "MISSING", fmt.Errorf("API not found for the resource: %s", armType)
}
return value, nil
}

resourceAPIVersionLookup = make(map[string]string)
for _, provider := range providerResponse.Providers {
for _, resourceType := range provider.ResourceTypes {
for _, apiVersion := range resourceType.APIVersions {
if !strings.Contains(apiVersion, "preview") {
resourceAPIVersionLookup[provider.Namespace+"/"+resourceType.ResourceType] = apiVersion
break
}
}
}
}

Few things we could do better here:

  1. Better error handling when an API version is missing. Showing a status message, returning "MISSING" is the wrong thing to do here.
  2. Check that the API Version is available in the location of the resource. It's possible that an API version may be picked which isn't available in a region as the cache is built up simplistically.
  3. Check that population of the Provider dictionary has been completed before allowing calls.

@lawrencegripper
Copy link
Owner

Had a quick test and with current version I can delete an aks cluster successfully. This likely points to the race condition with the provider call taking too long meaning the version lookup fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-stale
Projects
None yet
Development

No branches or pull requests

2 participants