GoogleCloudPlatform / deploymentmanager-samples

Deployment Manager samples and templates.
Apache License 2.0
949 stars 716 forks source link

Error when templates are retrieved from cloud storage #364

Open abdennebi opened 5 years ago

abdennebi commented 5 years ago

Hi,

I'am storing the templates into cloud storage. For exemple to create a bucket, my config looks like this : resources:

  - name: my-bucket
    type: gs://MY TEMPLATES BUCKET/templates/gcs_bucket/gcs_bucket.py
    properties:
      name: my-bucket
      location: us-east1

When running the deployment manager, I'm geeting the following error:

ERROR: (gcloud.deployment-manager.deployments.update) Error in Operation [operation-XXX]: errors:
- code: MANIFEST_EXPANSION_USER_ERROR
  location: /deployments/resources/manifests/manifest-XXXX
  message: |-
    Manifest expansion encountered the following errors: Invalid properties for 'gs://gto-deployment-manager-templates/templates/gcs_bucket/gcs_bucket.py':
    File 'gcs_bucket.py' requested in schema 'gs://gto-deployment-manager-templates/templates/gcs_bucket/gcs_bucket.py.schema' but not included with imports.
     Resource: gto-deployment-manager-templates Resource: config

In fact, the schema is referencing gcs_bucket.py which the deployment likely cannot find (I presume because it's not stored localy):

imports:
  - path: gcs_bucket.py

A workaround for this is to simply remove the import.

Is this import mandatory? Can we get rid of it ? (This import is not present in all templates)

Thanks for your help,

ocsig commented 5 years ago

Hi,

I'm not sure if I understand completely your setup. You using type: gs://MY TEMPLATES BUCKET/templates/gcs_bucket/gcs_bucket.py in your config.yaml. This makes DM use type: gs://MY TEMPLATES BUCKET/templates/gcs_bucket/gcs_bucket.py and type: gs://MY TEMPLATES BUCKET/templates/gcs_bucket/gcs_bucket.py.schema.

And above this, you have

imports:
  - path: gcs_bucket.py

in your .schema file?

If that is your setup, the Schema doesn't need to reference (import) the template which it is defining. it COULD reference further dependencies, however I never tested chained references in case the templates are stored in GCS.

Think about the config.yaml and schema imports this way: They need to reference all files, which DM collects before it executes the python/jinja run. And in you case, yes: if you use - path: gcs_bucket.py that's referencing for a local file.

ocsig commented 5 years ago

@Abdennebi Can you please provide more info?