GoogleCloudPlatform / deploymentmanager-samples

Deployment Manager samples and templates.
Apache License 2.0
940 stars 717 forks source link

Cloud Deployment manager error #621

Closed chinpark closed 3 years ago

chinpark commented 3 years ago

Problem: Following the readme and instructions of https://github.com/tieto-pc/gcp-intro-dm-demo produces an error where reference to non-existent config file

When I try to run the cloud deployment command it throws this error

chinmay.parkar$ gcloud deployment-manager deployments create cparkar-project-deployment --template deployment.py --project cparkar-project The fingerprint of the deployment is b'gs2fUJthaczGrQLE2sa4Kw==' Waiting for create [operation-1614195862251-5bc1a42f7a685-192adad5-4fccd052]...failed.
ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1614195862251-5bc1a42f7a685-192adad5-4fccd052]: errors:

common.py is in the same working directory as deployment.py

I have tried importing common.py using various method but I am getting the same error.

Please check and advice.

ocsig commented 3 years ago

TL;DR: use the following syntax to create your deployment: gcloud deployment-manager deployments create cparkar-project-deployment --config deployment.yaml --project cparkar-project

Longer answer:

There are different ways in DM to create deployments with gcloud. You are giving a template parameter pointing to your root template. The other option is to use a config parameter, point it to a config yaml file which will call your root template with some (optionally) parameters. The issue here is, when you create a deployment, gcloud collects all the necessary files from your filesystem and sends it to the backend. The question is, how gcloud finds the files you want to use? It shall be listed in the config YAML. If you look at the repo you linked it contains the appropriate config file with the needed imports. If you look at your deployment which failed, you will see the deployment.py on the UI, but no other file. When you run the gcloud command with --config deployment.yaml you will see other files, such as common.py, vpc.py, vm.py.

chinpark commented 3 years ago

Hey, Thanks for the reply! @ocsig

I tried as you suggested but it does not work :(

chinmay.parkar$ gcloud deployment-manager deployments create cparkar-project-deployment --config deployment.py --project cparkar-project ERROR: (gcloud.deployment-manager.deployments.create) Creating deployments from templates with the --config flag is not supported. Please use the --template flag.

Please suggest!

ocsig commented 3 years ago

Please use the config yaml as a starting point/parameter for DM, not the deployment.py: --config deployment.py >> --config deployment.yaml

chinpark commented 3 years ago

Thank you so much!!! @ocsig The issue is fixed!