GoogleCloudPlatform / deploymentmanager-samples

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

Ref in Instance Template errors with CYCLIC_REFERENCES #670

Open alexapplebaum opened 2 years ago

alexapplebaum commented 2 years ago

When 'updating' a deployment that contains an instant template similar to your:

https://github.com/GoogleCloudPlatform/deploymentmanager-samples/tree/master/examples/v2/igm-updater

If the instance template contains references:

ex. https://github.com/alexapplebaum/deploymentmanager-samples/tree/cyclic/community/full-stack-autoscale-vm

https://github.com/alexapplebaum/deploymentmanager-samples/blob/cyclic/community/full-stack-autoscale-vm/parent/parent.py#L56

Rendered Config:

      networkInterfaces:
      - accessConfigs:
        - name: Management NAT
          type: ONE_TO_ONE_NAT
        network: $(ref.mycyclic-network0.selfLink)
        subnetwork: $(ref.mycyclic-mgmt1.selfLink)

It errors out with:

$ gcloud  deployment-manager deployments update myparent --config parent-2.yaml
The fingerprint of the deployment is b'OrC90UgOl7yY-lGlOMt_yA=='
Waiting for update [operation-1628281354059-5c8e9cbb3fd70-4ceff8f4-ae04ad50]...failed.                                                                        
ERROR: (gcloud.deployment-manager.deployments.update) Error in Operation [operation-1628281354059-5c8e9cbb3fd70-4ceff8f4-ae04ad50]: errors:
- code: CYCLIC_REFERENCES
  message: |
    A cycle was found during reference analysis:
    Detected cycle:
    mycyclic-network0 <- myparent-it-v-1 <- myparent-igm <- myparent-it-v-2

NOTE: The igm-updater example mentioned has networks hardcoded. If you hardcode the networks as strings instead, the deployment manager can update the deployment just fine. However, we would obviously like to leverage references for benefits mentioned here:

https://cloud.google.com/deployment-manager/docs/configuration/use-references

1) To avoid parallel deployments and create the dependency graph. 2) Make dynamic per inputs 3) etc.

NOTE: First deployment works fine with the references. It is only the Update process (in order to toggle the instance template to trigger a rolling update as per the igm updater example) but updating is required lifecycle functionality.