-
Steve Xuereb authored
`GetIP` gets called every time docker-machine wants to send an ssh command. For the amazonec2 driver it is not using the saved IPAddress but calling the aws API every time which leads to an excessive amount of IP calls which exhaust the API limit. Before sending a request for the IP check if it's populated, the IPAddress is being populated for the first time when the machine starts in [instanceIpAvailable](https://gitlab.com/gitlab-org/ci-cd/docker-machine/blob/8bf0b23c8e88e14ed6cf9221b747e1ce062fc6ba/drivers/amazonec2/amazonec2.go#L543) Reading [amazon documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts-public-addresses) on weather a public IP can change during the lifecycle of a machine it does not seem like it will effect docker-machine in any way. This seems to effect other drivers like the `google` driver, but drivers like `digitalocean` are not effected since the use the [`baseDriver.GetIP`](https://gitlab.com/gitlab-org/ci-cd/docker-machine/blob/8bf0b23c8e88e14ed6cf9221b747e1ce062fc6ba/libmachine/drivers/base.go#L39-44) which does not call the API. Also on drivers like [softlayer](https://gitlab.com/gitlab-org/ci-cd/docker-machine/blob/8bf0b23c8e88e14ed6cf9221b747e1ce062fc6ba/drivers/softlayer/driver.go#L285-302) it is doing the same check before calling the API. We can see significant reduction of API calls: **Before Patch:** Number of DescribeInstances: 34 Number of GetSSHHostname: 17 **After Patch:** Number of DescribeInstances: 13 Number of GetSSHHostname: 17 More investigation of this issue can be found in gitlab-org/gitlab-runner#3424 (comment 231357594) reference gitlab-org/gitlab-runner#3424