Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ A [fleeting](https://docs.gitlab.com/runner/fleet_scaling/fleeting/) plugin for

### Caveats

- 🔒 Private networks are not yet supported.
- ⬇️ Stopped runner instances are automatically removed and recycled.

## 🏎️ Demo and Ansible Playbook
Expand Down Expand Up @@ -141,6 +140,7 @@ The following parameters are supported:
| `image` | string | Image (slug) of virtual machine, [more information](https://www.cloudscale.ch/en/api/v1#images) |
| `volume_size_gb` | number | The size of the root volume in GiB. Must be at least `10`. |
| `user_data` | string | Depending on the image choice is either in the format of cloud-init (YAML) or Ignition (JSON). |
| `interfaces` | object | Describes the interfaces to attach to the instances. Check the config template for some examples. |

### Default connector config

Expand Down
17 changes: 17 additions & 0 deletions config/config.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ concurrent = 40
# The root disk size of each instance.
volume_size_gb = 25

# Networking configuration for the instances
# The Network that is listed first will be used for the communication with the runner controller.
# This direcly mirrors the go sdk types (https://github.com/cloudscale-ch/cloudscale-go-sdk/blob/1baae3ab99a83a25221c77a8c6f4c69838979312/servers.go#L116-L124)
# interfaces = [
# { network = "UUID3"},
# { network = "UUID3"},
# ]
#
# Only one interface in the public network.
# This is also the default if nothing is set
interfaces = [{ network = "public" }]
# Two interfaces, one in a private network
# interfaces = [
# { network = "public" },
# { network = "uuid of private net"},
# ]

# The cloud-config applied to each instance. Note that GitLab expects these
# instances to have a running docker daemon.
user_data = """#cloud-config
Expand Down
16 changes: 13 additions & 3 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
Image string `json:"image"`
UserData string `json:"user_data"`

Interfaces []cloudscale.InterfaceRequest `json:"interfaces,omitempty"`

VolumeSizeGB int `json:"volume_size_gb,omitempty"`

log hclog.Logger
Expand Down Expand Up @@ -116,6 +118,14 @@
err("plugin_config: zone %s should be rma1 or lpg1", g.Zone)
}

if g.Interfaces == nil {
g.Interfaces = []cloudscale.InterfaceRequest{
cloudscale.InterfaceRequest{
Network: "public",
},
}
}

if g.VolumeSizeGB < 10 {
err("plugin_config: volume_size_gb must be >= 10")
}
Expand Down Expand Up @@ -287,9 +297,6 @@
ctx context.Context,
delta int,
) (succeeded int, err error) {
servers := make([]*cloudscale.Server, 0, delta)
errs := make([]error, 0)

publicKey, err := g.publicKey()
if err != nil {
return 0, err
Expand All @@ -309,13 +316,16 @@
SSHKeys: []string{string(publicKey)},
VolumeSizeGB: g.VolumeSizeGB,
UserData: g.UserData,
Interfaces: &[]cloudscale.InterfaceRequest{
cloudscale.InterfaceRequest{Network: g.Network},

Check failure on line 320 in provider.go

View workflow job for this annotation

GitHub Actions / Build and Test

g.Network undefined (type *InstanceGroup has no field or method Network)
},
TaggedResourceRequest: cloudscale.TaggedResourceRequest{
Tags: &tagMap,
},
})

if err != nil {
errs = append(errs, fmt.Errorf(

Check failure on line 328 in provider.go

View workflow job for this annotation

GitHub Actions / Build and Test

undefined: errs
"failed to create %s: %w", serverName, err))
continue
}
Expand All @@ -324,16 +334,16 @@
ctx, server.UUID, cloudscale.ServerIsRunning)

if err != nil {
errs = append(errs, fmt.Errorf(

Check failure on line 337 in provider.go

View workflow job for this annotation

GitHub Actions / Build and Test

undefined: errs
"failed to wait for %s: %w", serverName, err))
continue
}

g.log.Info("created server", "name", serverName, "uuid", server.UUID)
servers = append(servers, server)

Check failure on line 343 in provider.go

View workflow job for this annotation

GitHub Actions / Build and Test

undefined: servers
}

return len(servers), errors.Join(errs...)

Check failure on line 346 in provider.go

View workflow job for this annotation

GitHub Actions / Build and Test

undefined: errs

Check failure on line 346 in provider.go

View workflow job for this annotation

GitHub Actions / Build and Test

undefined: servers

}

Expand Down
Loading