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
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## [Unreleased]

### Changed
- Turning in-band authentication or two-way on no longer needs a maintenance cycle per host.
At each connect of an in-band pool, a path that does not hold the host's current key (or,
for two-way, its current controller key) is replaced in place: the agent makes a second path
to the same port with the keys, then disconnects the old one, and I/O continues on the other
paths. A reconnect of each host after turning the option on is enough, and an attach, VM
start or migration onto a host not yet reconnected moves its paths first. If the new path
cannot be made, the old one is kept and the next connect tries again (the agent log says why).
The move needs native NVMe multipath (`nvme_core.multipath=Y`, the EL default).
- A pool registration that fails at the first API call now says why: no API endpoint answered
(check the addresses, the network and the TLS fingerprint; the token was not checked), the
connection broke or timed out after the request was sent, the cluster refused the token, the cluster has no such project, or the cluster answered with an
error. It no longer says "with the supplied credentials" when the cluster could not be reached.
connection broke or timed out after the request was sent, the cluster refused the token, the
cluster has no such project, or the cluster answered with an error. It no longer says "with the supplied credentials" when the cluster could not be reached.
- When a VM starts, each of its volumes' NQN ACL is set to the VM's host alone; NQNs of other
hosts, including any added by hand on the cluster, are removed (with `ipAcl=true`, the IP ACL
follows). Attach to a running VM and live migration still add the host and keep the others,
and so does a start for which the plugin cannot read the VM (it logs "granting without removing
other hosts").

### Known limitations
- Paths are moved in place only on hosts with native NVMe multipath; a host with
`nvme_core.multipath=N` is moved in maintenance, as before.
- Attaches and live migrations take longer while a Lightbits node is down (in the lab, up to
about 15 seconds more per attach); none fails. See
[docs/known-limitations-and-issues.md](docs/known-limitations-and-issues.md).
Expand Down
81 changes: 45 additions & 36 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,8 @@ the host side:
readiness line as needing a key rotation (see [Rotating the keys](#rotating-the-keys))
until it rotates. Key or configuration files not owned by root, or symbolic links, are
deleted instead and new keys are made (the agent log says so); the host is not listed, but
must be reconnected (`cmk reconnect host id=<host-id>`) to register the new key, and its
paths that still hold the old key keep it until they reconnect, so move it onto keyed paths
as in the rollout below before enforcement is on.
must be reconnected (`cmk reconnect host id=<host-id>`) to register the new key; that
connect also moves its paths onto the new key (see [Moving paths in place](#moving-paths-in-place)).
- On every host connect the agent sends the key to the management server over the agent
channel. The management server registers the host as a trusted host of the pool's project
(named `cs-<environment>-host-<host uuid>`, label `cloudstack-host`) with the key as its
Expand Down Expand Up @@ -411,30 +410,44 @@ the host side:
below). Without the option the authentication is one-way: the cluster checks the host, the host does not check the
cluster. A trusted host is shared by every pool of its project on the cluster, so a one-way
pool keeps a target secret a two-way pool set. Make every pool of a cluster two-way, or
none: a one-way pool's paths hold the host key only, and its paths to the cluster's
subsystem also carry the two-way pool's volumes. Such a path stays until
it is disconnected by hand (`nvme disconnect -d <controller>`, as the refusal message says);
until then new handoffs of the two-way pool's volumes on that host are refused and the
readiness line lists the host. Readiness for a two-way pool also needs the
current controller key registered and on every path; move hosts onto new paths as in step
4 after turning the option on. **Until a host is moved, new attaches, VM starts and
migrations onto it fail for this pool's volumes:** the agent refuses to hand a volume to a VM
while any path of the pool's subsystem lacks the host's current controller key, with a
message saying how to move the host; VMs already running keep working. **A VM that
maintenance cannot migrate is stopped by CloudStack**, so move the hosts in this order:
1. Before turning two-way on, put one host of the pool in maintenance (its VMs migrate as
usual, the pool is still one-way). Wait until it is in Maintenance and runs no VMs, and
until nothing outside CloudStack on the host uses the cluster's volumes, then disconnect
it from the cluster's subsystem (`nvme disconnect -n <subsystem NQN>`).
2. Turn two-way on (`cmk update storagepool id=<pool-id> details[0].inbandAuthTwoWay=true`)
and reconnect the hosts that are not in maintenance (`cmk reconnect host id=<host-id>`),
which registers their controller keys.
3. Cancel maintenance on the first host and reconnect it: it is moved, and the readiness line
no longer lists it.
4. For each further host, one at a time: first migrate its VMs to moved hosts
(`cmk migrate virtualmachine virtualmachineid=<vm-id> hostid=<moved-host-id>`), since
CloudStack may otherwise pick a host that is not moved yet, then put it in maintenance,
wait as in 1, disconnect it from the subsystem, cancel maintenance and reconnect it.
none: a one-way pool's new paths hold the host key only, and its paths to the cluster's
subsystem also carry the two-way pool's volumes. The two-way pool's next connect moves such
a path onto both keys; until then new handoffs of the two-way pool's volumes on that host
are refused and the readiness line lists the host. Readiness for a two-way pool also needs
the current controller key registered and on every path.
To turn two-way on, with VMs running:
1. Turn it on (`cmk update storagepool id=<pool-id> details[0].inbandAuthTwoWay=true`).
2. Reconnect every host (`cmk reconnect host id=<host-id>`): each registers its controller
key, and its connect moves its paths onto both keys (see
[Moving paths in place](#moving-paths-in-place)). No maintenance is needed, and VMs keep
running.
3. Check the readiness line (step 4 of the rollout below): it no longer lists the hosts.
An attach, VM start or migration onto a host that was not reconnected yet moves its paths
first. If a path cannot be moved, the agent refuses to hand the pool's volumes to a VM on
that host, with a message, and VMs already running keep working; the agent log says why the
path was not moved.

#### Moving paths in place

At each connect of a pool with in-band authentication, and at each host connect, the agent
checks the host's paths to the pool's cluster (a host connect checks the paths the host already
has, and makes no new one). A path that does not hold the host's current key (and, for two-way,
its current controller key) is replaced without a pause in I/O: the agent first makes a second
path to the same port with the keys, waits until the new path carries every volume the old
one does, then disconnects the old one; the kernel's NVMe multipath keeps the volumes on the
other paths meanwhile. An old path the agent could not drop within the connect's time is
kept, and the next connect retries the move (the agent log says so each time). If the new path cannot be made (for
example, enforcement is on and the cluster does not have the new key yet), the old path is
kept and the next connect tries again; the agent log says so. A path on a kernel without
in-band authentication support cannot be checked and is left as it is.

The move needs the kernel's native NVMe multipath (`nvme_core.multipath=Y`, the default on
EL8 and later). Without it, a volume's device hangs below a single path, and disconnecting
that path would remove the device a VM uses, so nothing is moved: the agent log says so, and
such a host is moved in maintenance (disconnect its Lightbits paths while it runs no VMs,
then reconnect it). A host connect also moves nothing while the management server does not
know the pool's cluster (its subsystem NQN could not be read); the pool's next connect on the
host moves the paths instead.

#### What two-way checks

Expand All @@ -451,8 +464,6 @@ authentication enforcement on, so:
keep the NVMe/TCP network isolated to the KVM hosts and the cluster (a dedicated VLAN or
fabric), so no other machine can answer at the cluster's addresses.

The moved hosts need room for the VMs of the next host, as for any maintenance.

**Warning: turning enforcement on too early can freeze a host.** Once the cluster admin runs
`lbcli enable in-band-auth`, any NVMe/TCP path that does not hold the host's current key
(made before `inbandAuth=true`, or before the key was replaced) fails at its next reconnect,
Expand All @@ -464,7 +475,7 @@ enforcement. In the lab this happened to a host that still had paths with an old
recover, turn enforcement off (`lbcli disable in-band-auth`) and, on that host, reconnect
the missing paths by hand (`nvme connect -t tcp -a <node data IP> -s 4420 -n <subsystem
NQN>` for each node without a live path); the stuck I/O resumes and the host comes back Up.
Then move it onto keyed paths as in step 4.
Then reconnect the host (`cmk reconnect host id=<host-id>`), which moves its paths onto the key.

Turning in-band authentication on is a cluster-wide switch that only a cluster admin can
flip, and a host without a registered key loses each path at its next reconnect. Follow
Expand All @@ -481,12 +492,10 @@ this order:
`the <n> host(s) of pool <id> are ready for in-band authentication` or `the hosts of pool
<id> are NOT ready`, with the hosts that are not registered and those with NVMe/TCP paths
that do not hold the host's current key: paths made before the option was on hold none,
and paths made before a key was replaced hold an old one. Move each of those hosts onto keyed
paths: put it in maintenance (its VMs migrate away), wait until it is in Maintenance and
runs no VMs, and until nothing outside CloudStack on the host uses the cluster's volumes,
disconnect it from the cluster's subsystem (`nvme disconnect -n <subsystem NQN>`, the
`nqn.2016-01.com.lightbitslabs:` entry of `nvme list-subsys`), and cancel maintenance; its
next connects use the key.
and paths made before a key was replaced hold an old one. A host's connect moves such paths
onto its current key (see [Moving paths in place](#moving-paths-in-place)), so the reconnect
of step 3 normally clears them; for a host still listed, the agent log says why a path was
not moved. Reconnect it again once the cause is fixed.
5. Enforcement is cluster-wide, and the readiness line covers only the hosts of one pool.
Before the cluster admin turns it on, every host and client that uses the cluster must be
ready: the hosts of every CloudStack pool on the cluster (each pool logs its own line,
Expand Down
7 changes: 2 additions & 5 deletions docs/known-limitations-and-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ Read INSTALL.md ("In-band authentication") before turning on enforcement on the
host also accepts a target that does not ask for authentication, so two-way complements an
isolated storage network rather than replacing it (INSTALL.md, "What two-way checks").
- **Two-way for all pools of a cluster, or none.** A one-way pool of the same cluster connects
with the host key only, and its paths also carry the two-way pool's volumes; the host is then
reported not ready for the two-way pool.
- **Turning two-way on with running VMs needs a host order.** A migration onto a host whose
paths do not yet hold its controller key is refused, so follow the host order in INSTALL.md:
empty one host before turning the option on, and migrate VMs by hand onto moved hosts.
new paths with the host key only, and its paths also carry the two-way pool's volumes; the
host is reported not ready for the two-way pool until that pool's next connect moves them.

## Known issues

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ public Answer execute(LightbitsGetHostNqnCommand command, LibvirtComputingResour
answer.withRotation(false, e.getMessage());
}
}
if (!command.isRotateKeys() && command.isMovePaths()) {
try {
movePaths(command.getKeyScope(), command.isMoveTwoWay());
} catch (RuntimeException e) {
// the count below reports the paths that are left; the next connect tries again
LOG.warn("Lightbits: could not move this host's paths onto its current in-band authentication key(s): {}",
e.getMessage());
}
}
inbandAuth(answer, command.getKeyScope());
if (command.isTwoWay() && answer.getDhchapKey() != null) {
ctrlKey(answer, command.getKeyScope());
Expand Down Expand Up @@ -184,6 +193,11 @@ protected int pathsWithoutCtrlKey(String currentCtrlKey, String scope) {
: com.cloud.hypervisor.kvm.storage.LightbitsHostKey.pathsWithoutCtrlKey(currentCtrlKey, scope);
}

/** Move this host's paths of the cluster that lack its current keys (see LightbitsStorageAdaptor#movePathsInPlace). */
protected void movePaths(String scope, boolean twoWay) {
com.cloud.hypervisor.kvm.storage.LightbitsStorageAdaptor.movePathsInPlace(scope, twoWay);
}

/** Rotate this host's keys for one cluster (null: the host-wide keys). */
protected void rotateKeys(String scope) {
if (scope == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ public java.util.List<LightbitsNvmeHost.Target> targets(String poolUuid, java.ut
String ctrl = twoWay ? ensureCtrlKey() : null;
synchronized (LOCK) {
try {
Files.deleteIfExists(twoWayConfigFile(poolUuid));
if (poolUuid != null) {
Files.deleteIfExists(twoWayConfigFile(poolUuid));
}
String nqn = read(nvmeDir.resolve("hostnqn"));
if (nqn == null || !HOST_NQN.matcher(nqn).matches()) {
throw new CloudRuntimeException("Lightbits: this host's NQN (" + nvmeDir.resolve("hostnqn") + ") is missing or not an NQN");
Expand Down
Loading
Loading