mirror of https://github.com/linkerd/linkerd2.git
cli: reduce timeouts on API check requests (#586)
Applies timeout of 5s to check request contexts. This overrides 30s timeout applied at client transport level, and stops the conduit check command from taking > 90s to complete. Fixes #553 Signed-off-by: Andy Hume <andyhume@gmail.com>
This commit is contained in:
parent
b82f89f4d9
commit
1a66e7f8f1
|
|
@ -3,6 +3,7 @@ package healthcheck
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
healthcheckPb "github.com/runconduit/conduit/controller/gen/common/healthcheck"
|
||||
"google.golang.org/grpc"
|
||||
|
|
@ -24,7 +25,10 @@ func (proxy *statusCheckerProxy) SelfCheck() []*healthcheckPb.CheckResult {
|
|||
CheckDescription: "can query the Conduit API",
|
||||
}
|
||||
|
||||
selfCheckResponse, err := proxy.delegate.SelfCheck(context.Background(), &healthcheckPb.SelfCheckRequest{})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
selfCheckResponse, err := proxy.delegate.SelfCheck(ctx, &healthcheckPb.SelfCheckRequest{})
|
||||
if err != nil {
|
||||
canConnectViaGrpcCheck.Status = healthcheckPb.CheckStatus_ERROR
|
||||
canConnectViaGrpcCheck.FriendlyMessageToUser = err.Error()
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package k8s
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
healthcheckPb "github.com/runconduit/conduit/controller/gen/common/healthcheck"
|
||||
"github.com/runconduit/conduit/pkg/healthcheck"
|
||||
|
|
@ -93,7 +95,11 @@ func (kubeapi *kubernetesApi) checkApiAccess(client *http.Client) (*healthcheckP
|
|||
return checkResult, ""
|
||||
}
|
||||
|
||||
resp, err := client.Get(endpointToCheck.String())
|
||||
req, _ := http.NewRequest("GET", endpointToCheck.String(), nil)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
resp, err := client.Do(req.WithContext(ctx))
|
||||
if err != nil {
|
||||
checkResult.Status = healthcheckPb.CheckStatus_ERROR
|
||||
checkResult.FriendlyMessageToUser = fmt.Sprintf("HTTP GET request to endpoint [%s] resulted in error: [%s]", endpointToCheck, err.Error())
|
||||
|
|
|
|||
|
|
@ -90,7 +90,10 @@ func (v versionStatusChecker) SelfCheck() []*healthcheckPb.CheckResult {
|
|||
}
|
||||
|
||||
func (v versionStatusChecker) getServerVersion() (string, error) {
|
||||
resp, err := v.publicApiClient.Version(context.Background(), &pb.Empty{})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
resp, err := v.publicApiClient.Version(ctx, &pb.Empty{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue