Skip to content

Commit

Permalink
Merge pull request #1144 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1135-to-release-4.13

[release-4.13] OCPBUGS-22783: relax readiness to local serializable requests
  • Loading branch information
openshift-merge-bot[bot] committed Nov 10, 2023
2 parents 300feab + 5821b72 commit 44b4cad
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions pkg/cmd/readyz/readyz.go
Expand Up @@ -197,7 +197,6 @@ func (r *readyzOpts) Run() error {
return err
}

// TODO: Add timeout to handler
func (r *readyzOpts) getReadyzHandlerFunc(ctx context.Context) http.HandlerFunc {
return func(w http.ResponseWriter, _ *http.Request) {
etcdClient, err := r.clientPool.Get()
Expand All @@ -209,22 +208,12 @@ func (r *readyzOpts) getReadyzHandlerFunc(ctx context.Context) http.HandlerFunc

defer r.clientPool.Return(etcdClient)

// Learner and voting members both support the endpoint status call
resp, err := etcdClient.Status(ctx, r.targetEndpoint)
if err != nil {
klog.V(2).Infof("failed to get member endpoint status: %v", err)
http.Error(w, fmt.Sprintf("failed to get member endpoint status: %v", err), http.StatusServiceUnavailable)
return
}
timeout, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()

if resp.IsLearner {
// Serializable (local) read request for learner members
// since learners don't support linearized reads
_, err = etcdClient.Get(ctx, "health", clientv3.WithSerializable())
} else {
// Linearized read request to verify health of voting members
_, err = etcdClient.Get(ctx, "health")
}
// we solely do serializable requests to the local instance, as we don't want the readiness of individual
// etcd members to rely on an existing quorum to do linearized requests.
_, err = etcdClient.Get(timeout, "health", clientv3.WithSerializable())
if err != nil {
klog.V(2).Infof("failed to get member health key: %v", err)
http.Error(w, fmt.Sprintf("failed to get member health key: %v", err), http.StatusServiceUnavailable)
Expand Down

0 comments on commit 44b4cad

Please sign in to comment.