private static bool IsHealthyReplica(ReplicaWrapper replica) { // TODO: Should we only consider replicas that Service Fabric reports as healthy (`replica.HealthState != HealthState.Error`)? // That is precisely what Traefik does, see: https://github.com/containous/traefik-extra-service-fabric/blob/a5c54b8d5409be7aa21b06d55cf186ee4cc25a13/servicefabric.go#L219 // It seems misguided in our case, however, since we have an active health probing model // that can determine endpoint health more reliably. In particular because Service Fabric "Error" states does not necessarily mean // that the replica is unavailable, rather only that something in the cluster issued an "Error" report against it. // Skipping the replica here because we *suspect* it might be unavailable could lead to snowball cascading failures. return(replica.ReplicaStatus == ServiceReplicaStatus.Ready); }
private static bool IsReplicaEligible(ReplicaWrapper replica, StatefulReplicaSelectionMode statefulReplicaSelectionMode) { if (replica.ServiceKind != ServiceKind.Stateful) { // Stateless service replicas are always eligible return(true); } return(statefulReplicaSelectionMode switch { StatefulReplicaSelectionMode.Primary => replica.Role == ReplicaRole.Primary, StatefulReplicaSelectionMode.ActiveSecondary => replica.Role == ReplicaRole.ActiveSecondary, _ => true, });