Skip to main content

Drain a node with the earlier Center

Before work on a node in window A of the move, you move its pools to a neighboring node, and after the work you return them. This page is for a cluster that still runs the earlier Center — the management VM has the vStack-control-pane package (how to check). Here you stop and start virtual machines (VMs) through the API, and move a pool with the cluster manager utility on the node. Once Center is upgraded to 3.2.0, you drain a node in the web interface — Drain a node before maintenance.

Move pools only with the steps below: not from the web interface and not with the vstack-cluster service move command. Never move the pool with the management VM — the VM that runs Center — from the web interface.

Before you begin​

  • You do step 1 during preparation, in step 9 of the "Steps" page; steps 1–8 are done before it: the script kit is downloaded, the Center account and the variables are set — step 2, and the Internal Fabric pre-configuration is done — step 7.
  • You do steps 2–9 in window A, when all the preparation is done — steps 1–14 of the Steps page.
  • You have key-based SSH access with root privileges to all nodes and to the management VM.

How to read the steps​

How to read the steps and what "stop" means — Upgrade a 3.0, 3.1 or 3.2.0 node to 3.2.6, "How to read the steps". Run the workstation commands from the directory where you unpacked the script kit.

NotationWhat it is
<node>the management address of the node that you use to connect over SSH
<N>the node number in the cluster — Node ID in the ccrd_cli output
<zNN>a storage pool, for example z01
<OWN>the node that currently runs the pool with the management VM: on it, zfs list | grep '/.vm_V4/000000000$' outputs something
<neighbor id>, <neighbor N>the node that takes the pools for the duration of the work: its number in Center and its number in the cluster — step 1
<buffers>memory for SPDK on the node, in gigabytes — Enable Internal Fabric, step 5

1. Choose where to move the pools​

  • Where: management VM; workstation.

The memory budget of each node in Center — the node number in Center, the name, the budget in GiB. On the management VM:

cd /tmp; su -m postgres -c "psql -At -d vstack -c 'select id, hostname, round(ram/1073741824.0) from node.node order by id'"

How much memory is used on each node and how much the running VMs of each pool need. On the workstation:

sh tools/vapi.sh vm-list '{}' | jq -r '.result.data
| (group_by(.node)[] | "node \(.[0].node): used \(([.[]|select(.oper_status==3)|.memory_count]|add // 0)/1073741824) GiB"),
(group_by(.pool)[] | "pool \(.[0].pool): needed \(([.[]|select(.oper_status==3)|.memory_count]|add // 0)/1073741824) GiB")'

The output identifies a pool by its guid. To get the pool name by guid, run on the node: zpool get -H -o value guid <zNN>.

Choose the neighbor so that "budget − used − <buffers>" is not less than the "needed" value of the node's pools, and the VMs physically fit. The neighbor of the <OWN> node also needs the memory of the management VM, in GiB — on the workstation: ssh root@<OWN> cat /pools/<zNN>/.vm_V4/000000000/vm.json | jq '.ram/1073741824'. The id from the first query is <neighbor id>; find <neighbor N> in the ccrd_cli output by the node name.

Expected result: a plan — <neighbor id> and <neighbor N> are recorded for each node.

If not: the pools do not fit — some VMs of the pool stay stopped until the pool returns; agree on this with the VM owners.

2. Check that the cluster is healthy​

  • Where: any node; workstation.
ccrd_cli | grep -c ONLINE # on any node: the number of nodes

Pools on all nodes and duplicates — on the workstation:

for h in $NODES; do echo "== $h"; ssh -n root@$h 'zpool status -x; zpool status | grep -E "pool:|scan:"'; done
sh tools/dupcheck.sh # DUPLICATES: none

Expected result: the number of ONLINE lines equals the number of nodes; each node shows all pools are healthy or no pools available; no scan: line contains in progress; DUPLICATES: none.

If not: data recovery (resilver) is in progress — wait for it to finish and repeat the step. A node is not ONLINE or a pool is faulty — stop. A duplicate — Reference, "Troubleshooting".

3. Stop the VMs of the pool​

  • Where: node; workstation.

The pools of the node — on the node:

ccrd_cli --service --command status | grep zpool_ | grep "node: *<N>;"

Do steps 3–5 for each pool in turn. The pool with the management VM on the <OWN> node goes last, at the end of step 5.

VMs of other pools that run on this node — on the workstation:

sh tools/vapi.sh vm-list '{}' | jq -r '.result.data[] | select(.node==<node id in Center> and .rstart==1) | .vm_id'

Move each of them off the node: vms-stop, then vms-start without node_id.

Stop the running VMs of the pool through Center — on the workstation (P is the pool name, G is its guid):

P=<zNN>; G=$(ssh root@<node> "zpool get -H -o value guid $P"); echo $G
sh tools/vapi.sh vm-list '{}' | jq -r --arg g "$G" '.result.data[] | select(.pool==$g and .oper_status==3) | .vm_id' > running-$P.txt
wc -l running-$P.txt
for id in $(cat running-$P.txt); do sh tools/vapi.sh vms-stop "{\"id\":$id,\"hard_timeout\":90}" >/dev/null; done
for id in $(cat running-$P.txt); do sh tools/vapi.sh wait $id 1 >/dev/null || echo "$id NOT STOPPED"; done

Stop VMs only through Center, not on the node. A Windows VM that does not shut down by itself is powered off hard — ask the owners in advance to shut it down from inside. Do not stop a Windows VM that is on the installation screen.

Expected result: wc -l showed how many VMs of the pool were running; there are no NOT STOPPED lines.

If not: NOT STOPPED — investigate before you move the pool.

4. Move the pool to the neighbor​

  • Where: node.
ccrd_cli --service --service_name zpool_<zNN> --command stop
ccrd_cli --service --command status | grep zpool_<zNN> # repeat until STOPPED
ccrd_cli --service --service_name zpool_<zNN> --node_id <neighbor N> --command start
ccrd_cli --service --command status | grep zpool_<zNN> # STARTED at node: <neighbor N>

Expected result: STARTED at node: <neighbor N>.

If not: ZMQ socket error, service is already running, STOPPED at node: 1024 or pool is busy — Reference, "Troubleshooting". If the pool is already stopped, the VMs of the pool are down — do not delay.

5. Start the VMs of the pool on the neighbor​

  • Where: neighbor node; workstation.

The earlier Center starts a VM on the node that currently has its pool by itself: do not pass node_id. On the workstation:

xargs -n 4 < running-$P.txt | while read batch; do
for id in $batch; do sh tools/vapi.sh vms-start "{\"id\":$id}" | jq -c '.error // empty'; done
for id in $batch; do sh tools/vapi.sh wait $id 3 >/dev/null || echo "$id NOT STARTED"; done
done
sh tools/dupcheck.sh

Expected result: there are no NOT STARTED lines, DUPLICATES: none.

If not: the error code is in the {"code":…} line before NOT STARTED. -440 — these VMs wait for the pool to return, step 9. Other errors (-452, -5, a duplicate) — Reference, "Troubleshooting".

Moving a pool with the VMs suspended, without rebooting the guests, is done only with vStack support.

The pool with the management VM​

Move the pool with the management VM on the <OWN> node only with steps 3–5, not from the web interface.

  1. Stop the other VMs of the pool — step 3.

  2. On the <OWN> node, stop the management VM: vstack-vm vm --stop --id=0. Wait until pgrep -f '^bhyve: 0$' outputs nothing.

  3. Take snapshots of the management VM volumes — on the workstation:

    ssh root@<OWN> 'sh -s' <<'EOF'
    V=$(zfs list -H -o name -t filesystem,volume | grep '/.vm_V4/000000000$')
    for t in $(zfs list -H -o name -r $V | grep -v "^$V\$"); do zfs snapshot $t@pre_move_$(date +%Y%m%d) || echo "FAIL $t"; done
    EOF
  4. Move the pool with the commands of step 4. The management VM starts on the neighbor by itself. If the web interface does not open within a few minutes, check pgrep -f '^bhyve: 0$' on the neighbor; if the output is empty, start the VM: vstack-vm vm --start --id=0.

  5. Before you start the VMs of the pool, check where the earlier Center sees the pool — on the management VM:

    cd /tmp; su -m postgres -c "psql -At -d vstack -c \"select name, current_node from storage.pool\"" # the management VM pool shows the neighbor's number

    If the output is empty or shows the previous node, start the VMs of the pool one at a time and run dupcheck.sh after each one. If a VM does not start, wait for the pool to return (step 9) or for window B.

  6. When the web interface opens, start the VMs of the pool from running-<pool>.txt, as in step 5.

6. Close the node​

  • Where: node.
ccrd_cli --node --node_id <N> --command disable
pgrep -lf '^bhyve: [0-9]' # empty
zpool list # no pools available

Expected result: pgrep outputs nothing, zpool list prints no pools available.

If not: stop: the node still has a VM or a pool.

7. Do the work on the node​

Upgrade the node — step 16 of the Steps page. Do not start or move VMs to the closed node. Keep no more than one node closed at a time.

8. Return the node to the cluster​

  • Where: node; workstation.
ccrd_cli --node --node_id <N> --command enable

If a disk of the node in another node's pool is FAULTED, run zpool online <zNN> <disk name from the FAULTED line> on the node that runs that pool. A disk in the REMOVED state returns by itself.

Then check the pools on all nodes and the duplicates — with the commands of step 2.

Expected result: the pools of all nodes are healthy, no data recovery is in progress, DUPLICATES: none.

If not: recovery is in progress — wait for it to finish. A pool is faulty after recovery ends — stop.

9. Return the pools and VMs​

  • Where: node; workstation.

Return the pools to the node in the same way as in steps 3–5. For <OWN>, do not take new snapshots.

Expected result:

  • all VMs from running-<pool>.txt are running, and within a few minutes their guests have booted — you can see this in the VM console. A Windows VM occasionally hangs at the first start — stop it and start it again;
  • the pool check on all nodes (step 2): the pools are healthy, no recovery is in progress; DUPLICATES: none.

If not: Reference, "Troubleshooting".

Next​

  • Steps — step 18: fabric addresses of the pools after the return.
  • Reference