{"action":"created","issue":{"url":"https://api.github.com/repos/docker/machine/issues/3656","repository_url":"https://api.github.com/repos/docker/machine","labels_url":"https://api.github.com/repos/docker/machine/issues/3656/labels{/name}","comments_url":"https://api.github.com/repos/docker/machine/issues/3656/comments","events_url":"https://api.github.com/repos/docker/machine/issues/3656/events","html_url":"https://github.com/docker/machine/issues/3656","id":170274987,"number":3656,"title":"docker-machine with Azure driver cannot create a VM with the same vnet under different resource groups","user":{"login":"groyee","id":194016,"avatar_url":"https://avatars.githubusercontent.com/u/194016?v=3","gravatar_id":"","url":"https://api.github.com/users/groyee","html_url":"https://github.com/groyee","followers_url":"https://api.github.com/users/groyee/followers","following_url":"https://api.github.com/users/groyee/following{/other_user}","gists_url":"https://api.github.com/users/groyee/gists{/gist_id}","starred_url":"https://api.github.com/users/groyee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/groyee/subscriptions","organizations_url":"https://api.github.com/users/groyee/orgs","repos_url":"https://api.github.com/users/groyee/repos","events_url":"https://api.github.com/users/groyee/events{/privacy}","received_events_url":"https://api.github.com/users/groyee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-09T21:26:12Z","updated_at":"2016-08-15T21:06:40Z","closed_at":null,"body":"<!--\r\nIf you are reporting a new issue, make sure that we do not have any duplicates\r\nalready open. You can ensure this by searching the issue list for this\r\nrepository. If there is a duplicate, please close your issue and add a comment\r\nto the existing issue instead.\r\n\r\nIf you suspect your issue is a bug, please edit your issue description to\r\ninclude the BUG REPORT INFORMATION shown below. If you fail to provide this\r\ninformation within 7 days, we cannot debug your issue and will close it. We\r\nwill, however, reopen it if you later provide the information.\r\n\r\nFor more information about reporting issues, see\r\nhttps://github.com/docker/docker/blob/master/CONTRIBUTING.md#reporting-other-issues\r\n\r\n---------------------------------------------------\r\nBUG REPORT INFORMATION\r\n---------------------------------------------------\r\nUse the commands below to provide key information from your environment:\r\nYou do NOT have to include this information if this is a FEATURE REQUEST\r\n-->\r\n\r\n```\r\n**Output of `docker version`:**\r\nClient:\r\n Version:      1.11.2\r\n API version:  1.23\r\n Go version:   go1.5.4\r\n Git commit:   b9f10c9\r\n Built:        Wed Jun  1 21:20:08 2016\r\n OS/Arch:      darwin/amd64\r\n\r\nServer:\r\n Version:      1.11.2\r\n API version:  1.23\r\n Go version:   go1.5.4\r\n Git commit:   b9f10c9\r\n Built:        Wed Jun  1 21:20:08 2016\r\n OS/Arch:      linux/amd64\r\n```\r\n\r\n\r\n\r\n**Output of `docker info`:**\r\n\r\n```\r\nContainers: 5\r\n Running: 4\r\n Paused: 0\r\n Stopped: 1\r\nImages: 16\r\nServer Version: 1.11.2\r\nStorage Driver: aufs\r\n Root Dir: /mnt/sda1/var/lib/docker/aufs\r\n Backing Filesystem: extfs\r\n Dirs: 67\r\n Dirperm1 Supported: true\r\nLogging Driver: json-file\r\nCgroup Driver: cgroupfs\r\nPlugins:\r\n Volume: local\r\n Network: bridge null host\r\nKernel Version: 4.4.12-boot2docker\r\nOperating System: Boot2Docker 1.11.2 (TCL 7.1); HEAD : a6645c3 - Wed Jun  1 22:59:51 UTC 2016\r\nOSType: linux\r\nArchitecture: x86_64\r\nCPUs: 1\r\nTotal Memory: 1.955 GiB\r\nName: default\r\nID: YFTU:TCWM:Q7C5:QOKR:6IZE:ARRL:XEX3:C4FL:EXMI:WAC3:TY42:N4KV\r\nDocker Root Dir: /mnt/sda1/var/lib/docker\r\nDebug mode (client): false\r\nDebug mode (server): true\r\n File Descriptors: 52\r\n Goroutines: 104\r\n System Time: 2016-08-09T20:17:22.466086489Z\r\n EventsListeners: 0\r\nUsername: groyee\r\nRegistry: https://index.docker.io/v1/\r\nLabels:\r\n provider=virtualbox\r\n```\r\n\r\n**Additional environment details (AWS, VirtualBox, physical, etc.):**\r\n\r\n\r\n\r\n**Steps to reproduce the issue:**\r\n//Create VM in Azure using docker-machine. Specify --azure-resource-group\r\n1. docker-machine create -d azure  --azure-use-private-ip --azure-resource-group \"**resourcegroupA**\" --azure-subscription-id [_you subscription_] A\r\n\r\n2.This will create VM 'A' in azure under resource group 'resourcegroupA'. This will also create **virtual network with the name docker-machine-vnet**\r\n\r\n//Create another machine in a different resource group but with the same vent so these machine will be able to communicate with each other\r\n3.docker-machine create -d azure  --azure-use-private-ip --azure-resource-group \"**resourcegroupB**\" **--azure-vnet \"docker-machine-vent\"** --azure-subscription-id [_you subscription_] B\r\n\r\n\r\n**Describe the results you received:**\r\nVM 'B' will be created with a new vnet (not the one I specified) and as a result the 2 machines can't communicate with each other. It is easily possible to create 2 machines in Azure in different resource groups using the same vnet.\r\n\r\n**Describe the results you expected:**\r\nI would expect docker will use the same vnet that I specified in the --azure-vnet.\r\n\r\n**Additional information you deem important (e.g. issue happens only occasionally):**\r\n\r\nThe faulting code is:\r\n\r\nfunc (a AzureClient) CreateVirtualNetworkIfNotExists(resourceGroup, name, location string) error {\r\n    f := logutil.Fields{\r\n        \"name\":     name,\r\n        \"location\": location}\r\n\r\n    log.Info(\"Querying if virtual network already exists.\", f)\r\n\r\n    if exists, err := **a.virtualNetworkExists(resourceGroup, name)**; err != nil {\r\n        return err\r\n    } else if exists {\r\n        log.Info(\"Virtual network already exists.\", f)\r\n        return nil\r\n    }\r\n\r\n    log.Debug(\"Creating virtual network.\", f)\r\n    _, err := a.virtualNetworksClient().CreateOrUpdate(resourceGroup, name,\r\n        network.VirtualNetwork{\r\n            Location: to.StringPtr(location),\r\n            Properties: &network.VirtualNetworkPropertiesFormat{\r\n                AddressSpace: &network.AddressSpace{\r\n                    AddressPrefixes: to.StringSlicePtr(defaultVnetAddressPrefixes),\r\n                },\r\n            },\r\n        }, nil)\r\n    return err\r\n}\r\n\r\nThe problem is that docker checks if the specified vnet already exist in the same resource group where this container is about to be created. Since it is not created there it creates a new vnet with the same name under the new resource group.\r\n\r\na simple fix would be to provide resource group with the vnet name to the --azure-vnet parameter. for example: \r\n\r\n--azure-vnet = \"resource-groupname:vnet-name\"\r\nAs a result, the machines can't communicate with private ip.\r\n\r\n\r\nThis is a major issue which makes docker-machine unusable with azure driver. currently there is no workaround and the only options are:\r\n\r\n1. Create all VMs with the same resource group. BAD IDEA\r\n\r\n2. Force communication with public ip between the machines. BAD IDEA.\r\n\r\n:-("},"comment":{"url":"https://api.github.com/repos/docker/machine/issues/comments/239929320","html_url":"https://github.com/docker/machine/issues/3656#issuecomment-239929320","issue_url":"https://api.github.com/repos/docker/machine/issues/3656","id":239929320,"user":{"login":"ahmetalpbalkan","id":159209,"avatar_url":"https://avatars.githubusercontent.com/u/159209?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmetalpbalkan","html_url":"https://github.com/ahmetalpbalkan","followers_url":"https://api.github.com/users/ahmetalpbalkan/followers","following_url":"https://api.github.com/users/ahmetalpbalkan/following{/other_user}","gists_url":"https://api.github.com/users/ahmetalpbalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmetalpbalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmetalpbalkan/subscriptions","organizations_url":"https://api.github.com/users/ahmetalpbalkan/orgs","repos_url":"https://api.github.com/users/ahmetalpbalkan/repos","events_url":"https://api.github.com/users/ahmetalpbalkan/events{/privacy}","received_events_url":"https://api.github.com/users/ahmetalpbalkan/received_events","type":"User","site_admin":false},"created_at":"2016-08-15T21:06:40Z","updated_at":"2016-08-15T21:06:40Z","body":"@groyee Also please note\r\n\r\n- It will create the VNet if it is missing (even though it is in an another resource group)\r\n- If your machine is in an Availability Set and there are other machines in it that are not in the same VNet&Subnet you will get the following error:\r\n\r\n```\r\nCode=\"SubnetsNotInSameVnet\" Message=\"Subnet docker-machine referenced by resource [...] is not in the same Virtual Network as the subnets of other VMs in the availability set.\r\n```"}}
{"actor":{"display_login":"ahmetalpbalkan"}}