gantree-io / gantree-lib-nodejs

Javascript lib for gantree-cli
Apache License 2.0
12 stars 3 forks source link

Execution fails if quota is exceeded in GCP region #37

Open lovelaced opened 4 years ago

lovelaced commented 4 years ago

Thanks for this great tool!

I'm using the cli in docker built from the latest https://github.com/flex-dapps/gantree-cli-docker.

I believe the following issue is occurring due to:

TASK [infra-gcp-node : gcp compute instance] ***********************************
fatal: [gantree-infra-project-1 -> localhost]: FAILED! => {"changed": false, "msg": [{"code": "QUOTA_EXCEEDED", "message": "Quota 'N2_CPUS' exceeded.  Limit: 24.0 in region europe-west1."}]}

but the play continues on and then js throws an error:

PLAY RECAP *********************************************************************
gantree-infra-project-0 : ok=7    changed=3    unreachable=0    failed=0    skipped=4    rescued=0    ignored=0   
gantree-infra-project-1 : ok=5    changed=2    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

2020-06-06T14:46:47.280Z [Gantree] (cmd) error: Execution failed with code 2: ansible-playbook -i /gantree/inventory/project/gantree -i /gantree/inventory/project/active /usr/local/lib/node_modules/gantree-cli/node_modules/gantree-lib/ansible/infra.yml
(node:12) UnhandledPromiseRejectionWarning: Error: 2
    at childCloseCallback (/usr/local/lib/node_modules/gantree-cli/node_modules/gantree-lib/src/lib/cmd.js:117:18)
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/gantree-cli/node_modules/gantree-lib/src/lib/cmd.js:55:5)
    at ChildProcess.emit (events.js:327:22)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
(node:12) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Expected behavior would be printing a normal error message about the quota being exceeded and maybe a link to where to raise the quota (https://console.cloud.google.com/iam-admin/quotas), then exiting. This is reproducible and either fixed by raising the quota or downsizing the machines.

rozifus commented 4 years ago

Thanks @lovelaced

I've avoided implementing any provider specific error management up to this point because there's so many things that can go wrong across all the platforms. That said, I think most users will hit this exact issue at some point and it can often be confusing.

I think at a minimum we can work towards failing the play quicker and returning the provider error as clearly as possible.

Possibly down the track we could parse the error for common issues and output some helpful information like you've suggested

We're in the process of bootstrapping a community support channel on riot, feel free to drop in and say hello https://matrix.to/#/!XEdKYiNBUqLpbZgOqy:matrix.org?via=matrix.org

Would also be very keen to connect and hear about what you're currently building and if there's any features we could add to Gantree to better support your projects

lovelaced commented 4 years ago

I think just catching "fatal" level ansible errors and printing them as a normal error and exiting would be fine, that would be a reasonable catchall.