From e0dc7f2f8108ea55241e0392ab0383c1747a4dd4 Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Thu, 20 Feb 2020 22:20:43 +0800 Subject: [PATCH] Retry querying package info when "not found" (#1540) In some cases, creating a package and querying the package info immediately the Kubernetes API server will return "not found" error. So retry the query again after some time. --- pkg/fetcher/fetcher.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/fetcher/fetcher.go b/pkg/fetcher/fetcher.go index da041dc8..98a06955 100644 --- a/pkg/fetcher/fetcher.go +++ b/pkg/fetcher/fetcher.go @@ -555,6 +555,15 @@ func (fetcher *Fetcher) getPkgInformation(req FunctionFetchRequest) (pkg *fv1.Pa return pkg, nil } if i < maxRetries-1 { + // In some cases, creating a package and querying the package info + // immediately, the Kubernetes API server will return "not found" + // error. So retry the query again after some time. + + if k8serr.IsNotFound(err) { + time.Sleep(50 * time.Duration(i+1) * time.Millisecond) + continue + } + // All outbound requests are blocked if istio is enabled at the first seconds. // So if an error is a "connection refused" or "dial" error, wait for a while // before retrying so that envoy proxy will start to serve requests.