docker / machine

Machine management for a container-centric world
https://docs.docker.com/machine/
Apache License 2.0
6.63k stars 1.97k forks source link

Container Name check against Azure Driver is not validated First hand #3668

Open UsmanUrRehmanAhmed opened 8 years ago

UsmanUrRehmanAhmed commented 8 years ago

The docker-machine command against Azure driver ultimately fails due to a conflict in container name (uppercase in this case). Now despite that the command fails, on Azure following resources are created,

•An Availability set •A Network Interface •A Network Security Group •A Public IP address •A Virtual Network •A Storage Account

Why can't the container name check be done locally or first-hand prior creation of all these resources? Also why can't the entire process be atomic in nature, a rollback resulting in deletion of all created resources in case of an error?

docker-machine create -d azure --azure-subscription-id xxx-xxx-xxx QuizVM Running pre-create checks... (QuizVM) Completed machine pre-create checks. Creating machine... (QuizVM) Querying existing resource group. name="docker-machine" (QuizVM) Creating resource group. name="docker-machine" location="westus" (QuizVM) Configuring availability set. name="docker-machine" (QuizVM) Configuring network security group. name="QuizVM-firewall" location="westus" (QuizVM) Querying if virtual network already exists. name="docker-machine-vnet" location="westus" (QuizVM) Configuring subnet. name="docker-machine" vnet="docker-machine-vnet" cidr="192.168.0.0/16" (QuizVM) Creating public IP address. name="QuizVM-ip" static=false (QuizVM) Creating network interface. name="QuizVM-nic" (QuizVM) Creating storage account. name="xxx" location="westus" (QuizVM) Creating virtual machine. name="QuizVM" location="westus" size="Standard_A2" username="docker-user" osImage="canonical:UbuntuServer:15.10:latest" Error creating machine: Error in driver during machine creation: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Long running operation terminated with status 'Failed': Code="InvalidParameter" Message="Container name vhd-QuizVM in URL https://xxx.blob.core.windows.net/vhd-QuizVM/QuizVM-os-disk.vhd is invalid. Container names must be 3-63 characters in length and may contain only lower-case alphanumeric characters and hyphen. Hyphen must be preceeded and followed by an alphanumeric character."

ahmetb commented 8 years ago

@nathanleclaire We have this came up before. the container names in Azure (in this case vhd-QuizVM) do not allow uppercase.

Problem is, docker-machine allows uppercase as well as lowercase machine names. On Windows, it can't (because the files system is case-insensitive). So theoretically, I can lowercase the machine name and use it as container name if docker-machine is running on Windows; if not; that'd be a name collision issue.

Perhaps I should put vhds under a container calld vhds-docker-machine but I wish docker-machine only accepted lowercase machine names for consistency on POSIX vs Windows systems.

ahmetb commented 8 years ago

@UsmanUrRehmanAhmed to give you context here's the problem.

When you create the VM1 your OS disk is at:

https://xxx.blob.core.windows.net/vhd-VM1/VM1-os-disk.vhd

in this URL container name is vhd-VM1 and uppercase is not supported there. So let's say we lowercase the VM name for container and save it to:

https://xxx.blob.core.windows.net/vhd-vm1/VM1-os-disk.vhd

now let's say you wanna also create a VM named vm1, which will go to

https://xxx.blob.core.windows.net/vhd-vm1/vm1-os-disk.vhd

these two are different disks living in the same container, which is fine ––until you delete one of the machines. The deletion path determines the container name of the disk and deletes that. So if you try to delete machine VM1 we'll try to delete container vhd-vm1, which contains the disk of vm1 as well (which is still running).

Therefore the vm1 container wouldn't be cleaned up and machine deletion will fail. Until we solve this issue, please stick to lowercase machine names in Azure driver.

Hope this explanation clears things up a bit.