gardener / machine-controller-manager-provider-gcp

Gardener machine controller manager provider for GCP
Apache License 2.0
3 stars 26 forks source link

`ResourceExhausted` error code mapping introduced for `GCP` #92

Closed himanshu-kun closed 10 months ago

himanshu-kun commented 11 months ago

What this PR does / why we need it: Utilizes ResourceExhausted error status code. Only the errors which happen in a particular zone and are relating to insufficiency of resources are mapped to ResourceExhausted The intention is to enable CA to identify such errors , so that it could try another zone quicker https://github.com/gardener/autoscaler/issues/154

Which issue(s) this PR fixes: Fixes # Partially fixes https://github.com/gardener/machine-controller-manager/issues/590

Special notes for your reviewer: Testing results below:

Case: unsupported machine type in zone (checking message using regex, as it was also given in google docs https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-vm-creation#zone_availability)

I0825 17:54:51.934985   94199 machine_controller_util.go:385] Create machine "shoot--i544024--gcp2-worker-testing-z1-79596-snffh" failed: googleapi: Error 400: Invalid value for field 'resource.machineType': 'zones/europe-west1-c/machineTypes/m1-ultramem-40'. Machine type with name 'm1-ultramem-40' does not exist in zone 'europe-west1-c'., invalid
E0825 17:54:51.935016   94199 machine.go:359] Error while creating machine shoot--i544024--gcp2-worker-testing-z1-79596-snffh: machine codes error: code = [ResourceExhausted] message = [Create machine "shoot--i544024--gcp2-worker-testing-z1-79596-snffh" failed: googleapi: Error 400: Invalid value for field 'resource.machineType': 'zones/europe-west1-c/machineTypes/m1-ultramem-40'. Machine type with name 'm1-ultramem-40' does not exist in zone 'europe-west1-c'., invalid]
I0825 17:54:51.935525   94199 machine_util.go:525] Not updating the status of the machine object "shoot--i544024--gcp2-worker-testing-z1-79596-snffh", as the content is similar

Case: Quota exceeded

I0825 19:26:12.424990    3893 machine.go:354] Creating a VM for machine "shoot--i544024--gcp3-worker-testing-z1-d45fc-lvt2c", please wait!
I0825 19:26:12.424998    3893 machine.go:355] The machine creation is triggered with timeout of 20m0s
I0825 19:26:12.425004    3893 machine_controller.go:70] Create machine request has been received for "shoot--i544024--gcp3-worker-testing-z1-d45fc-lvt2c"
I0825 19:26:21.671318    3893 machine_controller_util.go:409] Waiting for operation to be completed... (status: RUNNING)
I0825 19:26:26.672580    3893 machine_controller_util.go:409] Waiting for operation to be completed... (status: DONE)
I0825 19:26:26.672693    3893 machine_controller_util.go:385] Create machine "shoot--i544024--gcp3-worker-testing-z1-d45fc-lvt2c" failed: The following errors occurred: [{QUOTA_EXCEEDED [%!!(MISSING)s(*compute.OperationErrorErrorsErrorDetails=&{<nil> <nil> <nil> 0xc000a38980 [] []})]  Quota 'M2_CPUS' exceeded.  Limit: 0.0 in region asia-south1. [] []}]
E0825 19:26:26.672726    3893 machine.go:359] Error while creating machine shoot--i544024--gcp3-worker-testing-z1-d45fc-lvt2c: machine codes error: code = [ResourceExhausted] message = [Create machine "shoot--i544024--gcp3-worker-testing-z1-d45fc-lvt2c" failed: The following errors occurred: [{QUOTA_EXCEEDED [%!s(*compute.OperationErrorErrorsErrorDetails=&{<nil> <nil> <nil> 0xc000a38980 [] []})]  Quota 'M2_CPUS' exceeded.  Limit: 0.0 in region asia-south1. [] []}]]

Release note:

MCM status code `ResourceExhausted` is now utilized in mcm-provider-gcp. Currently the `compute API` errors covered are:
- quota exceeded in zone
- insufficient resource in zone
- unavailable machinetype in zone
himanshu-kun commented 11 months ago

/assign @rishabh-11 for review

gitguardian[bot] commented 10 months ago

⚠️ GitGuardian has uncovered 8 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
| GitGuardian id | Secret | Commit | Filename | | | -------------- | ------------------------- | ---------------- | --------------- | -------------------- | | [-](https://dashboard.gitguardian.com/incidents/secrets) | RSA Private Key | edba94d64c3b8d5ae88378d7be865408d38f4940 | vendor/github.com/google/s2a-go/internal/v2/testdata/server_key.pem | [View secret](https://github.com/gardener/machine-controller-manager-provider-gcp/commit/edba94d64c3b8d5ae88378d7be865408d38f4940#diff-b2fc9be65bd69572280949a6e1840058L1) | | [-](https://dashboard.gitguardian.com/incidents/secrets) | RSA Private Key | edba94d64c3b8d5ae88378d7be865408d38f4940 | vendor/github.com/google/s2a-go/internal/v2/tlsconfigstore/testdata/server_key.pem | [View secret](https://github.com/gardener/machine-controller-manager-provider-gcp/commit/edba94d64c3b8d5ae88378d7be865408d38f4940#diff-2d696bf9e965137c4f36e93baf32349bL1) | | [-](https://dashboard.gitguardian.com/incidents/secrets) | RSA Private Key | edba94d64c3b8d5ae88378d7be865408d38f4940 | vendor/github.com/google/s2a-go/testdata/server_key.pem | [View secret](https://github.com/gardener/machine-controller-manager-provider-gcp/commit/edba94d64c3b8d5ae88378d7be865408d38f4940#diff-09fc38d5b4b56df9ded402e008158968L1) | | [-](https://dashboard.gitguardian.com/incidents/secrets) | RSA Private Key | edba94d64c3b8d5ae88378d7be865408d38f4940 | vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/server_key.pem | [View secret](https://github.com/gardener/machine-controller-manager-provider-gcp/commit/edba94d64c3b8d5ae88378d7be865408d38f4940#diff-91cc6d74d02e57879a0ccfcd7b76ea8eL1) | | [-](https://dashboard.gitguardian.com/incidents/secrets) | RSA Private Key | edba94d64c3b8d5ae88378d7be865408d38f4940 | vendor/github.com/google/s2a-go/testdata/client_key.pem | [View secret](https://github.com/gardener/machine-controller-manager-provider-gcp/commit/edba94d64c3b8d5ae88378d7be865408d38f4940#diff-2271333f384b7415dd0f21fe83aa33daL1) | | [-](https://dashboard.gitguardian.com/incidents/secrets) | RSA Private Key | edba94d64c3b8d5ae88378d7be865408d38f4940 | vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_key.pem | [View secret](https://github.com/gardener/machine-controller-manager-provider-gcp/commit/edba94d64c3b8d5ae88378d7be865408d38f4940#diff-efecf1c638a55652c2d3d70c60316a20L1) | | [-](https://dashboard.gitguardian.com/incidents/secrets) | RSA Private Key | edba94d64c3b8d5ae88378d7be865408d38f4940 | vendor/github.com/google/s2a-go/internal/v2/tlsconfigstore/testdata/client_key.pem | [View secret](https://github.com/gardener/machine-controller-manager-provider-gcp/commit/edba94d64c3b8d5ae88378d7be865408d38f4940#diff-95ff072089ba7d271fb551f962f007beL1) | | [-](https://dashboard.gitguardian.com/incidents/secrets) | RSA Private Key | edba94d64c3b8d5ae88378d7be865408d38f4940 | vendor/github.com/google/s2a-go/internal/v2/testdata/client_key.pem | [View secret](https://github.com/gardener/machine-controller-manager-provider-gcp/commit/edba94d64c3b8d5ae88378d7be865408d38f4940#diff-b97d1a36a62371705aa25d2add2e0a0bL1) |
🛠 Guidelines to remediate hardcoded secrets
1. Understand the implications of revoking this secret by investigating where it is used in your code. 2. Replace and store your secrets safely. [Learn here](https://blog.gitguardian.com/secrets-api-management?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) the best practices. 3. Revoke and [rotate these secrets](https://docs.gitguardian.com/secrets-detection/detectors/specifics/private_key_rsa#revoke-the-secret?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). 4. If possible, [rewrite git history](https://blog.gitguardian.com/rewriting-git-history-cheatsheet?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data. To avoid such incidents in the future consider - following these [best practices](https://blog.gitguardian.com/secrets-api-management/?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) for managing and storing secrets including API keys and other credentials - install [secret detection on pre-commit](https://docs.gitguardian.com/ggshield-docs/integrations/git-hooks/pre-commit?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) to catch secret before it leaves your machine and ease remediation.

🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

rishabh-11 commented 10 months ago

/lgtm thanks for the changes