Azure / azure-quickstart-templates

Azure Quickstart Templates
https://aka.ms/azqst
MIT License
14.07k stars 16.13k forks source link

101-container-registry-geo-replication deployment hangs with ARM deployment in Complete mode #5485

Open axis7818 opened 5 years ago

axis7818 commented 5 years ago

101-container-registry-geo-replication

Issue Details

I am working on an infrastructure-as-code project that requires the automatic provisioning of ACR with geo-replication. And, I found an issue with ACR and ARM interactions that causes deployment to hang.

I used this template to provision ACR with geo-replication enabled and one additional replication. The goal being to setup a CI pipeline that will provision and apply updates to these resources through a resource group deployment. In order for these automatic updates to happen, I have been trying to use ARM deployments with the Complete mode.

When ACR is provisioned with geo-replication, it automatically creates a home replication resource that is not specified in the ARM template. But, when an ARM deployment uses the Complete mode, it attempts to delete all resources that are not specified in the template. The result is a deployment that hangs with repeated HomeReplicationCannotBeDeleted errors shown, which is a problem when setting up CI pipelines.

Repro steps

  1. Create a new resource group
  2. Deploy this ARM template with Complete mode: az group deployment create . . . --mode Complete
  3. View the deployment in the Azure portal and see that it never finishes, but repeatedly shows an error event: HomeReplicationCannotBeDeleted

Work-Around

The one work-around that I discovered is to include the automatically created home-replication as a resource in an ARM template, but to set its condition field to always be false. This seems to let ARM know that the resource exists and to not attempt to delete it.

axis7818 commented 5 years ago

tagging @bmoore-msft @JulienFloris

brusMX commented 5 years ago

@jsturtevant Could you please fix this issue?

jsturtevant commented 5 years ago

@jcorioland how did you work around this issue for the terraform module?

mnltejaswini commented 5 years ago

Currently ACR doesn't support home replication deletion by the users. The workaround is to include the home replication in the template but skip its creation by using the condition : false as shown below

{ "name": "[concat(parameters('acrName'), '/', parameters('location'))]", "condition": false, "type": "Microsoft.ContainerRegistry/registries/replications", "apiVersion": "2017-10-01", "location": "[parameters('location')]", "properties": {}, "dependsOn": [ "[concat('Microsoft.ContainerRegistry/registries/', parameters('acrName'))]" ] },

axis7818 commented 5 years ago

I just put up a PR including the workaround. #5801

ankurkhemani commented 4 years ago

This issue has been fixed. Home replication can now be deleted if it's the only replication.

jamiemccrindle commented 4 years ago

I'm still getting this issue. ARM deployment appears to be in an infinite loop. Also can't cancel the deployment.

ankurkhemani commented 4 years ago

@jamiemccrindle Are you getting the same error message HomeReplicationCannotBeDeleted? Does the deployment succeed without Complete mode?

jamiemccrindle commented 4 years ago

Yes, it did succeed when I switched to Incremental. This is the only thing in the resource group, so Incremental will work.

ankurkhemani commented 4 years ago

@jamiemccrindle Great! Although, the complete mode deployment should work as well.