Skip to content
Commits on Source (3)
......@@ -15,8 +15,8 @@ You can find sources and pre-compiled binaries [here](https://github.com/JonasPr
```bash
# Download the binary (this example downloads the binary for linux amd64)
$ wget https://github.com/JonasProgrammer/docker-machine-driver-hetzner/releases/download/3.10.0/docker-machine-driver-hetzner_3.10.0_linux_amd64.tar.gz
$ tar -xvf docker-machine-driver-hetzner_3.10.0_linux_amd64.tar.gz
$ wget https://github.com/JonasProgrammer/docker-machine-driver-hetzner/releases/download/3.11.0/docker-machine-driver-hetzner_3.11.0_linux_amd64.tar.gz
$ tar -xvf docker-machine-driver-hetzner_3.11.0_linux_amd64.tar.gz
# Make it executable and copy the binary in a directory accessible with your $PATH
$ chmod +x docker-machine-driver-hetzner
......@@ -112,6 +112,7 @@ $ docker-machine create \
- `--hetzner-ssh-user`: Change the default SSH-User
- `--hetzner-ssh-port`: Change the default SSH-Port
- `--hetzner-primary-ipv4/6`: Sets an existing primary IP (v4 or v6 respectively) for the server, as documented in [Networking](#networking)
- `--wait-on-error`: Amount of seconds to wait on server creation failure (0/no wait by default)
#### Existing SSH keys
......@@ -156,6 +157,7 @@ was used during creation.
| `--hetzner-ssh-port` | `HETZNER_SSH_PORT` | 22 |
| `--hetzner-primary-ipv4` | `HETZNER_PRIMARY_IPV4` | |
| `--hetzner-primary-ipv6` | `HETZNER_PRIMARY_IPV6` | |
| `--wait-on-error` | `WAIT_ON_ERROR` | 0 |
#### Networking
......
......@@ -58,6 +58,8 @@ type Driver struct {
AdditionalKeys []string
AdditionalKeyIDs []int
cachedAdditionalKeys []*hcloud.SSHKey
WaitOnError int
}
const (
......@@ -99,6 +101,9 @@ const (
defaultSSHPort = 22
defaultSSHUser = "root"
flagWaitOnError = "wait-on-error"
defaultWaitOnError = 0
)
// NewDriver initializes a new driver instance; see [drivers.Driver.NewDriver]
......@@ -261,6 +266,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Usage: "SSH port",
Value: defaultSSHPort,
},
mcnflag.IntFlag{
EnvVar: "WAIT_ON_ERROR",
Name: flagWaitOnError,
Usage: "Wait if an error happens while creating the server",
Value: defaultWaitOnError,
},
}
}
......@@ -295,6 +306,8 @@ func (d *Driver) setConfigFromFlagsImpl(opts drivers.DriverOptions) error {
d.SSHUser = opts.String(flagSshUser)
d.SSHPort = opts.Int(flagSshPort)
d.WaitOnError = opts.Int(flagWaitOnError)
d.placementGroup = opts.String(flagPlacementGroup)
if opts.Bool(flagAutoSpread) {
if d.placementGroup != "" {
......@@ -450,6 +463,7 @@ func (d *Driver) Create() error {
srv, _, err := d.getClient().Server.Create(context.Background(), instrumented(*srvopts))
if err != nil {
time.Sleep(time.Duration(d.WaitOnError) * time.Second)
return errors.Wrap(err, "could not create server")
}
......