gardener / gardener-extension-provider-aws

Gardener extension controller for the AWS cloud provider (https://aws.amazon.com).
https://gardener.cloud
Apache License 2.0
19 stars 97 forks source link

Fix VPC NotFoundError classification #837

Closed dimitar-kostadinov closed 7 months ago

dimitar-kostadinov commented 11 months ago

How to categorize this issue?

/area ops-productivity /kind bug /platform aws

What happened:

The error should be classified as user configuration error, as configured VPC doesn't exist.

Last Error
task "Waiting until shoot infrastructure has been reconciled" failed: Error while waiting for Infrastructure shoot--foo--bar to become ready: error during reconciliation: Error checking infrastructure config: [networks.vpc.id: Invalid value: "vpc-id": VPC attribute enableDnsSupport must be set to true, networks.vpc.id: Invalid value: "vpc-id": VPC attribute enableDnsHostnames must be set to true, networks.vpc.id: Invalid value: "vpc-id": no attached internet gateway found, networks.vpc.id: Internal error: could not get DHCP options for VPC vpc-id: could not find VPC vpc-id]

It seems that awsclient.IsNotFoundError doesn't handle properly VPC NotFoundError:

https://github.com/gardener/gardener-extension-provider-aws/blob/46ba344f81c37d08e1c98acb64f396dd318ba3bf/pkg/controller/infrastructure/configvalidator.go#L107-L109

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

Kostov6 commented 7 months ago

From here we can see that GetVPCAttribute could never return NotFoundError https://github.com/gardener/gardener-extension-provider-aws/blob/160de6858446e762a013b4f7ab982b8903c616ab/pkg/aws/client/client.go#L209-L223 And here we expect to receive and even have a special handling if we receive such an error https://github.com/gardener/gardener-extension-provider-aws/blob/160de6858446e762a013b4f7ab982b8903c616ab/pkg/controller/infrastructure/configvalidator.go#L95-L99 Even we have dedicated test cases for NotFoundError https://github.com/gardener/gardener-extension-provider-aws/blob/160de6858446e762a013b4f7ab982b8903c616ab/pkg/controller/infrastructure/configvalidator_test.go#L142-L150 And any other error https://github.com/gardener/gardener-extension-provider-aws/blob/160de6858446e762a013b4f7ab982b8903c616ab/pkg/controller/infrastructure/configvalidator_test.go#L184-L193 https://github.com/gardener/gardener-extension-provider-aws/blob/160de6858446e762a013b4f7ab982b8903c616ab/pkg/aws/client/client.go#L211-L213 In conclusion I think that the code above should be changed to:

 if err != nil { 
    return false, err 
 }