Skip to main content

AdapterHubRecoveryService

Namespace: Meshmakers.Octo.Sdk.Common.Adapters

Last line of defence for AB#5409: if a dedicated adapter that was registered at the communication controller's adapter hub stays unregistered for longer than AdapterOptions.HubRegistrationRecoveryTimeout, this service stops the host so the container restarts.

public class AdapterHubRecoveryService : HubRegistrationRecoveryService, IHostedService, IDisposable

Inheritance Object → BackgroundService → HubRegistrationRecoveryService → AdapterHubRecoveryService
Implements IHostedService, IDisposable

Remarks:

Why a restart at all: on prod-1 a pod restart repaired the deaf adapters every single time, with no configuration change — the process had simply lost the one thing it cannot rebuild from the outside. A failing readiness probe cannot do this: Kubernetes never restarts a container for readiness, only for liveness, and liveness must stay independent of the hub (a controller outage must not take every adapter down with it). So the self-heal is done here, deliberately and loudly, instead of by mis-wiring the liveness probe.

The decision, its guards and its configuration are shared with the pool member's counterpart, AdapterPoolHubRecoveryService; see HubRegistrationRecoveryService.

Properties​

ExecuteTask​

public Task ExecuteTask { get; }

Property Value​

Task

Constructors​

AdapterHubRecoveryService(IAdapterHubClient, IAdapterHubRegistrationState, IOptions<AdapterOptions>, AdapterLifetimeManagement)​

Last line of defence for AB#5409: if a dedicated adapter that was registered at the communication controller's adapter hub stays unregistered for longer than AdapterOptions.HubRegistrationRecoveryTimeout, this service stops the host so the container restarts.

public AdapterHubRecoveryService(IAdapterHubClient adapterHubClient, IAdapterHubRegistrationState registrationState, IOptions<AdapterOptions> adapterOptions, AdapterLifetimeManagement lifetimeManagement)

Parameters​

adapterHubClient IAdapterHubClient

registrationState IAdapterHubRegistrationState

adapterOptions IOptions<AdapterOptions>

lifetimeManagement AdapterLifetimeManagement

Remarks:

Why a restart at all: on prod-1 a pod restart repaired the deaf adapters every single time, with no configuration change — the process had simply lost the one thing it cannot rebuild from the outside. A failing readiness probe cannot do this: Kubernetes never restarts a container for readiness, only for liveness, and liveness must stay independent of the hub (a controller outage must not take every adapter down with it). So the self-heal is done here, deliberately and loudly, instead of by mis-wiring the liveness probe.

The decision, its guards and its configuration are shared with the pool member's counterpart, AdapterPoolHubRecoveryService; see HubRegistrationRecoveryService.