AdapterPoolMemberDrainExitService
Namespace: Meshmakers.Octo.Sdk.Common.Adapters
Stops a pool member's process once it is draining and idle, so the pool workload restarts it as a fresh, clean process (AB#5864).
public sealed class AdapterPoolMemberDrainExitService : BackgroundService, IHostedService, IDisposable
Inheritance Object โ BackgroundService โ AdapterPoolMemberDrainExitService
Implements IHostedService, IDisposable
Remarks:
The drain contract always said "it finishes what it holds, takes no further lease and
exits" (ILeaseService.DrainMemberAsync in the controller, concept ยง6) โ and no
member ever exited. A drained member sat 1/1 Running for the rest of its life: on
test-2-dev a lease participant that failed to leave drained the only member of a pool,
and every later execution of every borrower failed until somebody deleted the pod.
Exiting is the recovery, not a punishment. A member drains because its cleanliness is unproven (a participant failed to leave, its lease expired server-side) or because the pool is giving it up; in neither case can the process be made trustworthy again from the inside. A container restart can: the new process starts with no tenant state at all, registers as available, and the controller's registry drops the old registration as superseded (same member id, new connection).
๐ด It waits for AdapterPoolClient.IsDrainedAndIdle, never only for the drain flag. A drain that arrives during a lease lets the lease finish; stopping earlier would lose the release report, and the controller would then interrupt and re-run work that had already completed.
Stopping the host is a graceful shutdown โ the management connection is closed cleanly by
AdapterPoolMemberService.StopAsync(CancellationToken), which the controller sees as a
disconnect of a member that holds no lease, so nothing is re-queued. Disabled with
AdapterPool:ExitWhenDrained=false (AdapterPoolMemberOptions.ExitWhenDrained);
the member then only drops out of readiness and stays until something else restarts it.
Propertiesโ
ExecuteTaskโ
public Task ExecuteTask { get; }
Property Valueโ
Constructorsโ
AdapterPoolMemberDrainExitService(AdapterPoolClient, IOptions<AdapterPoolMemberOptions>, AdapterLifetimeManagement)โ
Constructor.
public AdapterPoolMemberDrainExitService(AdapterPoolClient poolClient, IOptions<AdapterPoolMemberOptions> options, AdapterLifetimeManagement lifetimeManagement)
Parametersโ
poolClient AdapterPoolClient
The member's half of the lease protocol, which knows whether it drains.
options IOptions<AdapterPoolMemberOptions>
The pool member configuration (AdapterPoolMemberOptions.ExitWhenDrained).
lifetimeManagement AdapterLifetimeManagement
Stops the host.
Methodsโ
ExecuteAsync(CancellationToken)โ
protected Task ExecuteAsync(CancellationToken stoppingToken)
Parametersโ
stoppingToken CancellationToken
Returnsโ
Evaluate()โ
One sample: stops the host when the member is drained and idle and reports whether it did. Internal so the decision can be tested without the timer.
internal bool Evaluate()