Deployment Manager update error: Deployment in preview must not have a target with UPDATE

Viewed 1607

Every time I try to run an update through deployment manager to an existing deployment in preview, I get the error:

$ gcloud deployment-manager deployments update abc --config abc.yaml
ERROR: (gcloud.deployment-manager.deployments.update) ResponseError: code=400, message=Invalid value for field 'resource.target': ''.  Deployment in preview must not have a target with UPDATE

However, if I don't use the update on the gcloud command line and go to the console and click 'deploy' the update goes through fine.

What can be causing this?

4 Answers

Cancel the preview and then run the deployment update again.

gcloud deployment-manager deployments cancel-preview DEPLOYMENT

This is an issue on our end. We are currently working on a fix; I cannot provide an ETA for the fix at the moment. I strongly suggest continuing to use the work around you’ve found by deploying through the console.

For me the issue was that I was calling the update API for applying the preview with the full body parameter that I passed when first creating the preview.

The fix was to pass only the fingerprint and name properties in the body parameter for the preview-apply call.

project_name = '...'
deployment_name = '...'

existing_deployment = service.deployments().get(
    project=project_name,
    deployment=deployment_name).execute()

service.deployments().update(
    project=project_name,
    deployment=deployment_name,
    body={
        'name': deployment_name,
        'fingerprint': existing_deployment["fingerprint"],
    },
    preview=False).execute()
Related