Add more meaningful error messages to executor when getServiceForFunction (#752)
This commit is contained in:
+20
-4
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package executor
|
package executor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
@@ -25,6 +26,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/dchest/uniuri"
|
"github.com/dchest/uniuri"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
@@ -113,6 +115,12 @@ func (executor *Executor) serveCreateFuncServices() {
|
|||||||
|
|
||||||
// get the function service from the cache
|
// get the function service from the cache
|
||||||
fsvc, err := executor.fsCache.GetByFunction(m)
|
fsvc, err := executor.fsCache.GetByFunction(m)
|
||||||
|
|
||||||
|
// fsCache return error when the entry does not exist/expire.
|
||||||
|
// It normally happened if there are multiple requests are
|
||||||
|
// waiting for the same function and executor failed to cre-
|
||||||
|
// ate service for function.
|
||||||
|
err = errors.Wrap(err, fmt.Sprintf("Error getting service for function %v in namespace %v", m.Name, m.Namespace))
|
||||||
req.respChan <- &createFuncServiceResponse{
|
req.respChan <- &createFuncServiceResponse{
|
||||||
funcSvc: fsvc,
|
funcSvc: fsvc,
|
||||||
err: err,
|
err: err,
|
||||||
@@ -145,10 +153,12 @@ func (executor *Executor) createServiceForFunction(meta *metav1.ObjectMeta) (*fs
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var fsvc *fscache.FuncSvc
|
||||||
|
var fsvcErr error
|
||||||
|
|
||||||
switch executorType {
|
switch executorType {
|
||||||
case fission.ExecutorTypeNewdeploy:
|
case fission.ExecutorTypeNewdeploy:
|
||||||
fs, err := executor.ndm.GetFuncSvc(meta)
|
fsvc, fsvcErr = executor.ndm.GetFuncSvc(meta)
|
||||||
return fs, err
|
|
||||||
default:
|
default:
|
||||||
pool, err := executor.gpm.GetPool(env)
|
pool, err := executor.gpm.GetPool(env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -157,9 +167,15 @@ func (executor *Executor) createServiceForFunction(meta *metav1.ObjectMeta) (*fs
|
|||||||
// from GenericPool -> get one function container
|
// from GenericPool -> get one function container
|
||||||
// (this also adds to the cache)
|
// (this also adds to the cache)
|
||||||
log.Printf("[%v] getting function service from pool", meta.Name)
|
log.Printf("[%v] getting function service from pool", meta.Name)
|
||||||
fsvc, err := pool.GetFuncSvc(meta)
|
fsvc, fsvcErr = pool.GetFuncSvc(meta)
|
||||||
return fsvc, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fsvcErr != nil {
|
||||||
|
fsvcErr = errors.Wrap(fsvcErr, fmt.Sprintf("[%v] Error creating service for function", meta.Name))
|
||||||
|
log.Print(fsvcErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fsvc, fsvcErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (executor *Executor) getFunctionEnv(m *metav1.ObjectMeta) (*crd.Environment, error) {
|
func (executor *Executor) getFunctionEnv(m *metav1.ObjectMeta) (*crd.Environment, error) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package poolmgr
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@@ -32,7 +31,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/dchest/uniuri"
|
"github.com/dchest/uniuri"
|
||||||
|
"github.com/pkg/errors"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/api/extensions/v1beta1"
|
"k8s.io/api/extensions/v1beta1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -662,16 +661,22 @@ func (gp *GenericPool) waitForReadyPod() error {
|
|||||||
depl, err := gp.kubernetesClient.ExtensionsV1beta1().Deployments(gp.namespace).Get(
|
depl, err := gp.kubernetesClient.ExtensionsV1beta1().Deployments(gp.namespace).Get(
|
||||||
gp.deployment.ObjectMeta.Name, metav1.GetOptions{})
|
gp.deployment.ObjectMeta.Name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("err: %v", err)
|
err = errors.Wrap(err, fmt.Sprintf(
|
||||||
|
"Error waiting for ready pod of deployment %v in namespace %v",
|
||||||
|
gp.deployment.ObjectMeta.Name, gp.namespace))
|
||||||
|
log.Print(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
gp.deployment = depl
|
gp.deployment = depl
|
||||||
if gp.deployment.Status.AvailableReplicas > 0 {
|
if gp.deployment.Status.AvailableReplicas > 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if time.Since(startTime) > gp.podReadyTimeout {
|
if time.Since(startTime) > gp.podReadyTimeout {
|
||||||
return errors.New("timeout: waited too long for pod to be ready")
|
return errors.Errorf(
|
||||||
|
"Timeout: waited too long for pod of deployment %v in namespace %v to be ready",
|
||||||
|
gp.deployment.ObjectMeta.Name, gp.namespace)
|
||||||
}
|
}
|
||||||
time.Sleep(1000 * time.Millisecond)
|
time.Sleep(1000 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user