8.5 KiB
Replica Eviction Support for Disks and Nodes
Summary
This enhancement is to simplify and automatically evict the replicas on the selected disabled disks or nodes to other suitable disks and nodes per user's request. Meanwhile keep the same level of fault tolerance during this eviction period of time.
Related Issues
https://github.com/longhorn/longhorn/issues/292 https://github.com/longhorn/longhorn/issues/298
Motivation
Goals
- Allow user easily evict the replicas on the selected disks or nodes to other disks or nodes without impact the user defined
Volume.Spec.numberOfReplicas
and keep the same level of fault tolerance. This means we don't change the user defined replica number. - Report any error to user during the eviction time.
- Allow user to cancel the eviction at any time.
Proposal
- Add
Eviction Requested
withtrue
andfalse
selection buttons for disks and nodes. This is for user to evict or cancel the eviction of the disks or the nodes. - Add new
evictionRequested
field toNode.Spec
,Node.Spec.disks
Spec andReplica.Status
. These will help tracking the request from user and trigger replica controller to updateReplica.Status
and volume controller to do the eviction. And this will reconcile withscheduledReplica
of selected disks on the nodes. - Display
fail to evict
error message toDashboard
and any other eviction errors to theEvent log
.
User Stories
Disks and Nodes Eviction
For disk replacement or node replacement, the eviction needs to be done successfully in order to guarantee Longhorn volume function properly.
Before, when user wants to evict a disk or a node they need to do the following steps:
- User needs to disable the disk or the node.
- User needs to scale up the replica count for the volume which has replica on disabled disks or nodes, and wait for the rebuild complete, scale down the replica count, then delete the replicas on this disk or node.
After this enhancement, user can click true
to the Eviction Requested
on scheduling disabled disks or nodes. Or select Disable
for scheduling and true
to the Eviction Requested
at the same time then save this change. The backend will take care of the eviction for the disks or nodes and cleanup for all the replicas on disks or nodes.
User Experience In Detail
Disks and Nodes Eviction
- User can select
true
to theEviction Requested
fromLonghorn UI
for disks or nodes. And user has to make sure the selected disks or nodes have been disabled, or select theDisable
Scheduling at the same time oftrue
to theEviction Requested
. - Once
Eviction Requested
has been set totrue
on the disks or nodes, they can not be enabled forScheduling
. - If the disks or the nodes haven't been disabled for
Scheduling
, there will be error message showed inDashboard
immediately to indicate that user need to disable the disk or node for eviction. - And user will wait for the replica number for the disks or nodes to be 0.
- If there is any error e.g. no space or couldn't find other schedulable disk, the error message will be logged in the
Event log
. And the eviction will be suspended until either user sets theEviction Requested
tofalse
or cleanup more disk spaces for the new replicas. - If user cancel the eviction by setting the
Eviction Requested
tofalse
, the remaining replicas on the selected disks or nodes will remain on the disks or nodes.
API changes
From an API perspective, the call to set Eviction Requested
to true
or false
on the Node
or Disk
eviction should look the same. The logic for handling the new field Eviction Requested
true
or false
should to be in the Node Controller
and Volume Controller
.
Design
Implementation Overview
- On
Longhorn UI
Node
page, for nodes eviction, addingEviction Requested
true
andfalse
options in theEdit Node
sub-selection, next toNode Scheduling
. For disks eviction, addingEviction Requested
true
andfalse
options inEdit node and disks
sub-selection underOperation
column next to each diskScheduling
options. This is for user to evict or cancel the eviction of the disks or the nodes. - Add new
evictionRequested
field toNode.Spec
,Node.Spec.disks
Spec andReplica.Status
. These will help tracking the request from user and trigger replica controller to updateReplica.Status
and volume controller to do the eviction. And this will reconcile withscheduledReplica
of selected disks on the nodes. - Add a informer in
Replica Controller
to get these information and updateevictionRequested
field inReplica.Status
. - Once
Eviction Requested
has been set totrue
for disks or nodes, theevictionRequested
fields for the disks and nodes will be set totrue
(default isfalse
). Replica Controller
will updateevictionRequested
field inReplica.Status
andVolume Controller
to get these information from it's replicas.- During reconcile the engine replica, based on
Replica.Status.EvictionRequested
of the volume replicas to trigger rebuild for different volumes' replicas. And remove one replica withevictionRequested
true
. - Logged the errors to
Event log
during the reconcile process. - By the end from
Longhorn UI
, the replica number on the eviction disks or nodes should be 0, this mean eviction is success. - If the volume is 'Detached', Longhorn will 'Automatically Attach' the volume and do the eviction, after eviction success, the volume will be 'Automatically detach'. If there is any error during the eviction, it will get suspended, until user solve the problem, the 'Auto Detach' will be triggered at the end.
Test plan
Manual Test Plan For Disks and Nodes Eviction
Positive Case:
For both Replica Node Level Soft Anti-Affinity
has been enabled and disabled. Also the volume can be 'Attached' or 'Detached'.
- User can select one or more disks or nodes for eviction. Select
Eviction Requested
totrue
on the disabled disks or nodes, Longhorn should start rebuild replicas for the volumes which have replicas on the eviction disks or nodes, and after rebuild success, the replica number on the evicted disks or nodes should be 0. E.g. When there are 3 nodes in the cluster, and withReplica Node Level Soft Anti-Affinity
is set tofalse
, disable one node, and create a volume with replica count 2. And then evict one of them, the eviction should get stuck, then setReplica Node Level Soft Anti-Affinity
totrue
, the eviction should go through.
Negative Cases:
- If user selects the disks or nodes have not been disabled scheduling, Longhorn should display the error message on
Dashboard
immediately. Or during the eviction, the disabled disk or node can not be re-enabled again. - If there is no enough disk spaces or nodes for disks or nodes eviction, Longhorn should log the error message in the
Event Log
. And once the disk spaces or nodes resources are good enough, the eviction should continue. Or if the user selectsEviction Requested
tofalse
, Longhorn should stop eviction and clear theevictionRequested
fields for nodes, disks and volumes crd objects. E.g. When there are 3 nodes in the cluster, and the volume replica count is 3, the eviction should get stuck when theReplica Node Level Soft Anti-Affinity
isfalse
.
Integration Test Plan
For Replica Node Level Soft Anti-Affinity
is enabled, create 2 replicas on the same disk or node, and then evict this disk or node, the 2 replicas should goto another disk of node.
For Replica Node Level Soft Anti-Affinity
is disabled, create 1 replica on a disk, and evict this disk or node, the replica should goto the other disk of node.
For node eviction, Longhorn will process the eviction based on the disks for the node, this is like disk eviction. After eviction success, the replica number on the evicted node should be 0.
Error Indication
During the eviction, user can click the Replicas Number
on the Node
page, and set which replicas are left from eviction, and click the Replica Name
will redirect user to the Volume
page to set if there is any error for this volume. If there is any error during the rebuild, Longhorn should display the error message from UI. The error could be failed to schedule a replica
due to disk space or based on schedule policy, can not find a valid disk to put the replica.
Upgrade strategy
No special upgrade strategy is necessary. Once the user upgrades to the new version of Longhorn
, these new capabilities will be accessible from the longhorn-ui
without any special work.