mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 15:33:12 +09:00
Address review of host pairing
Revoking a host now unassigns its instances instead of being refused while it has any, and removes its system metrics. Approving and revoking no longer force a save. Hosts are saved by autosave and on exit like everything else, which also removes the approving state from pairing requests. The approval code and link are logged as warnings so they show up in the systemd service, which only prints warnings and above. The pairing limits are now the controller.host_pairing_timeout and controller.host_pairing_max_pending config values, 0 removes the limit. Subscribers take an optional permitted function, used for the pairing requests instead of overrides in a subclass.
This commit is contained in:
29 files changed
+356
-418
No files matched your search
+18
-1
@@ -48,6 +48,23 @@ Must be greater than 0.
|
||||
Defaults to 60.
|
||||
|
||||
|
||||
### controller.host_pairing_timeout
|
||||
|
||||
Time in seconds a host can wait for approval before its request expires, after which the host requests again with a new code.
|
||||
Set to 0 for no limit.
|
||||
|
||||
Defaults to 3600.
|
||||
|
||||
|
||||
### controller.host_pairing_max_pending
|
||||
|
||||
Maximum number of hosts that can wait for approval at the same time.
|
||||
Hosts over the limit keep trying until there is room.
|
||||
Set to 0 for no limit.
|
||||
|
||||
Defaults to 50.
|
||||
|
||||
|
||||
### controller.http_port
|
||||
|
||||
Port to host HTTP server on.
|
||||
@@ -369,7 +386,7 @@ Defaults to "http://localhost:8080/".
|
||||
Access token used for authenticating with the controller.
|
||||
The host saves it together with host.id when it is approved, see [Setting up remote hosts](/README.md#setting-up-remote-hosts).
|
||||
The token only works while the host exists on the controller, if the host is revoked it asks to be approved again the next time it starts.
|
||||
Set it to `enter token here` to make the host ask to join again, for example after changing host.controller_url to another controller.
|
||||
Set it to `enter token here` to make the host ask to join again.
|
||||
The value can only be read and changed from the host itself.
|
||||
|
||||
Defaults to "enter token here".
|
||||
|
||||
@@ -69,7 +69,7 @@ A host joins the cluster by having the code it shows when it first starts approv
|
||||
- `HostGenerateTokenRequest` and `HostConfigCreateRequest` are removed.
|
||||
Pending requests are listed with `HostPairingListRequest`, approved with `HostPairingApproveRequest` and rejected with `HostPairingRejectRequest`, and changes to them are sent to subscribers of `HostPairingUpdatesEvent`.
|
||||
- `HostRevokeTokensRequest` is replaced by `HostRevokeRequest`, which deletes the host instead of only invalidating its tokens.
|
||||
It throws `ConflictError` while instances are assigned to the host.
|
||||
Instances assigned to the host become unassigned.
|
||||
- The permissions `core.host.generate_token`, `core.host.revoke_token` and `core.host.create_config` are removed.
|
||||
Check `core.host.approve` and `core.host.revoke` instead.
|
||||
- `clusteriocontroller bootstrap generate-host-token` is removed, scripts that set up hosts can start the host with `--user-token` to approve it with a user token.
|
||||
@@ -78,4 +78,4 @@ Host records are no longer created when a host connects, only by approving it, a
|
||||
Revoking a host deletes its record and note.
|
||||
Plugins that keep data per host should remove it when the host is deleted.
|
||||
On the controller the `update` event of `controller.hosts` gives the record with `isDeleted` set to true, and subscribers of `HostUpdatesEvent` receive the host with `isDeleted` set to true.
|
||||
A host that is revoked and installed again gets a new id.
|
||||
A host that is revoked and approved again gets a new id.
|
||||
@@ -61,7 +61,7 @@ If a user token is sent and the user has the `core.host.approve` permission the
|
||||
An invalid token gives 401 and a user without the permission gives 403, a token is never ignored to create a pending request instead.
|
||||
|
||||
A missing or too long name gives 400.
|
||||
Too many pending requests from the same address or in total gives 429 with a `Retry-After` header in seconds.
|
||||
Too many pending requests from the same address, or in total as set by [controller.host_pairing_max_pending](/docs/configuration.md#controllerhost_pairing_max_pending), gives 429 with a `Retry-After` header in seconds.
|
||||
|
||||
### `POST /api/host-pairing/poll`
|
||||
|
||||
@@ -72,7 +72,7 @@ Once approved it responds with 200 and `{"hostId": integer, "token": string, "na
|
||||
Rejected requests give 403, and unknown or expired requests give 404.
|
||||
The result of an approved or rejected request is only returned once, after which the request is gone.
|
||||
|
||||
A pending request expires 30 seconds after it was last polled, and after an hour of waiting.
|
||||
A pending request expires 30 seconds after it was last polled, and after waiting for the time set by [controller.host_pairing_timeout](/docs/configuration.md#controllerhost_pairing_timeout).
|
||||
The host polls every 2 seconds, and makes a new request when the previous one has expired.
|
||||
|
||||
### `POST /api/host-pairing/cancel`
|
||||
@@ -177,8 +177,8 @@ Host handshake for establishing a new connection session.
|
||||
Object mapping plugin names to plugin version for plugins that are available on the host.
|
||||
|
||||
The controller closes the connection with code 3000 (Unauthorized) if the token is invalid, was issued for another id, or if there is no host with this id, see [Host pairing](#host-pairing).
|
||||
If this happens when the host starts it exits with code 8, and the run scripts created by the installer do not restart it.
|
||||
A host that has been rejected also exits with code 8.
|
||||
The host checks its token before connecting and requests to join again if it is not accepted, so this normally only happens to a host that is already running.
|
||||
A host that has been rejected exits with code 8, and the run scripts created by the installer do not restart it.
|
||||
A host that is revoked while connected is disconnected, is rejected when it tries to connect again, and shuts down.
|
||||
|
||||
#### `registerControl`
|
||||
|
||||
@@ -17,14 +17,14 @@ The easiest way to do this is to run `npx clusteriocontroller bootstrap create-c
|
||||
Lists all hosts.
|
||||
|
||||
Hosts are added to the cluster by running the installer on the computer the host runs on and approving the code it shows, see [Setting up remote hosts](/README.md#setting-up-remote-hosts).
|
||||
Listing, approving and rejecting installers waiting for approval needs the `core.host.approve` permission.
|
||||
Listing, approving and rejecting hosts waiting for approval needs the `core.host.approve` permission.
|
||||
|
||||
### List pending hosts
|
||||
|
||||
ctl> host pending
|
||||
|
||||
Lists hosts waiting for approval with the code they show, the name they asked for, the address they connected from and how long they have been waiting.
|
||||
A request goes away when its host stops waiting, and after waiting for an hour, after which the host asks again with a new code.
|
||||
A request goes away when its host stops waiting, and after the time set by `controller.host_pairing_timeout`, an hour by default, after which the host asks again with a new code.
|
||||
|
||||
### Approve host
|
||||
|
||||
@@ -47,7 +47,7 @@ Rejects the host showing the code, the host then exits with an error.
|
||||
|
||||
Specify the host by name or ID.
|
||||
Removes the host from the cluster, disconnects it and makes its token stop working.
|
||||
Instances assigned to the host have to be unassigned first.
|
||||
Instances assigned to the host become unassigned, their files stay on the computer.
|
||||
Requires the `core.host.revoke` permission.
|
||||
To add the computer back to the cluster, start the host again and approve it.
|
||||
|
||||
|
||||
Reference in new issue
Block a user