Zum Hauptinhalt springen

DatastoreHostPreflight

Namespace: Meshmakers.Octo.Sdk.Common.Adapters

Refuses to start an adapter whose configured datastore hostnames do not resolve (AB#5303 item 4).

public class DatastoreHostPreflight : IHostedService

Inheritance Object → DatastoreHostPreflight
Implements IHostedService

Remarks:

🔴 The misconfiguration this exists for is invisible until a lease is granted. A pool member has no tenant of its own, so nothing in its startup path touches MongoDB: it comes up, registers with its pool, reports healthy, and dies inside CkModelCacheLeaseParticipant.EnterLeaseAsync on a DNS failure the first time it is leased — minutes or hours later, in a stack trace that names neither the setting nor the value. Observed on a local kind cluster, where a workload had been handed …mongodb.svc.cluster.local while the services in that cluster live in octo-infra.

🔴 It resolves, it does not connect — and that distinction is the whole design. A Kubernetes Service's DNS name resolves while its pods are down, restarting or not yet scheduled, so resolution tests the configuration and not the liveness of the database. A connectivity probe here would turn every database restart into a crash loop of every adapter in the cluster, which is a worse failure than the one being fixed.

Why and not a background service. A throwing StartAsync aborts host startup, which is exactly what is wanted: the pod exits with the reason in its log and Kubernetes shows CrashLoopBackOff. That is not the hazard AB#5080 guarded against — there, an exception out of a long-running ExecuteAsync tore down a host that was already serving work.

Constructors​

DatastoreHostPreflight(IConfiguration, ILogger<DatastoreHostPreflight>)​

Constructor.

public DatastoreHostPreflight(IConfiguration configuration, ILogger<DatastoreHostPreflight> logger)

Parameters​

configuration IConfiguration

logger ILogger<DatastoreHostPreflight>

Methods​

StartAsync(CancellationToken)​

public Task StartAsync(CancellationToken cancellationToken)

Parameters​

cancellationToken CancellationToken

Returns​

Task

StopAsync(CancellationToken)​

public Task StopAsync(CancellationToken cancellationToken)

Parameters​

cancellationToken CancellationToken

Returns​

Task