Support both both serializable and linearizable health checks #479
If eh.Health is false, then eh.Status is always nil. So the unhealthyMembers cannot be successfully collected.
Maybe we should drop health.Status != nil condition.
If any member is unhealthy, the aggregated error will be non-nil. This prevents the reconcile workflow from reaching r.dispatch(), meaning unhealthy pods won't be repaired.
This is probably neccesary. When there is an active alarm in the cluster, epStatus.Errors will be non-empty. Without this check, eh.Health would incorrectly evaluate to true even if all members have active alarms.
good catch, updated
This PR only collects the health check result, and I was planning to handle such case in followup PR.
Updated anyway.
alarms are handled separately. For each member's health, we only depend on the serializable read request.
Pls also read the https://github.com/etcd-io/etcd-operator/blob/main/docs/design/reconcile_loop_v0.3.0.png, the alarms are handled first before fixing any unhealthy members
Got it. Thanks for the explaination.
Do we need to validate that cfg.Names is non-nil (and has the same length as cfg.Endpoints) in MemberHealth?
https://github.com/etcd-io/etcd-operator/blob/981731bdc7fb4177a1a8ffd19812007d6c9d0058/internal/etcdutils/etcdutils.go#L31-L33
The comment on ClientConfig.Names says "optional, callers that don't need EpHealth.Name populated may leave it nil", but the this line indexes cfg.Names[i] unconditionally, so a caller following the documented contract would hit an index-out-of-range panic.
https://github.com/etcd-io/etcd-operator/blob/981731bdc7fb4177a1a8ffd19812007d6c9d0058/internal/controller/pods.go#L205
I know the current callers are fine — healthCheck builds Names from the same pods slice, so the lengths always match. My concern is future callers trusting the "optional" contract.
Do we need to validate thatcfg.Namesis non-nil (and has the same length ascfg.Endpoints) in MemberHealth?
Each name will never be nil, as we get the value from POD name. We can consider how to refactor the implementation to make it more readable if needed in future.
The comment on ClientConfig.Names says "optional,
It's because the ClientConfig is used in multiple places. When calling MemberHealth, each name in ClientConfig.Names will never be nil.
When callingMemberHealth, each name inClientConfig.Nameswill never be nil.
So it is caller's responsibility to guarantee ClientConfig.Names is not a nil string slice. Could we add this to comment of MemberHealth?
Added.
LGTM. Thanks.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/etcd-io/etcd-operator/pull/479#" title="Author self-approved">ahrtr</a>, <a href="https://github.com/etcd-io/etcd-operator/pull/479#pullrequestreview-5017037428" title="Approved">silentred</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described here
<details >
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
</details>
<!-- META={"approvers":[]} -->
silentred
ahrtr
Fix https://github.com/etcd-io/etcd-operator/issues/468
@ArkaSaha30 @GunaKKIBM @ivanvc @nwnt @silentred