Test for httptrigger and functions container/newdeploy (#2861)
* Test for httptrigger and functions * Fixes with multierror * review changes Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
+12
-10
@@ -110,7 +110,9 @@ func MakeExecutor(ctx context.Context, logger *zap.Logger, cms *cms.ConfigSecret
|
||||
func (executor *Executor) serveCreateFuncServices() {
|
||||
for {
|
||||
req := <-executor.requestChan
|
||||
fnMetadata := &req.function.ObjectMeta
|
||||
function := req.function
|
||||
fnName := k8sCache.MetaObjectToName(function)
|
||||
fnkeyUR := crd.CacheKeyURFromObject(function)
|
||||
|
||||
if req.function.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fv1.ExecutorTypePoolmgr {
|
||||
go func() {
|
||||
@@ -138,13 +140,13 @@ func (executor *Executor) serveCreateFuncServices() {
|
||||
}
|
||||
|
||||
// Cache miss -- is this first one to request the func?
|
||||
wg, found := executor.fsCreateWg.Load(crd.CacheKeyURFromMeta(fnMetadata))
|
||||
wg, found := executor.fsCreateWg.Load(fnkeyUR)
|
||||
if !found {
|
||||
// create a waitgroup for other requests for
|
||||
// the same function to wait on
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
executor.fsCreateWg.Store(crd.CacheKeyURFromMeta(fnMetadata), wg)
|
||||
executor.fsCreateWg.Store(fnkeyUR, wg)
|
||||
|
||||
// launch a goroutine for each request, to parallelize
|
||||
// the specialization of different functions
|
||||
@@ -176,17 +178,17 @@ func (executor *Executor) serveCreateFuncServices() {
|
||||
funcSvc: fsvc,
|
||||
err: err,
|
||||
}
|
||||
executor.fsCreateWg.Delete(crd.CacheKeyURFromMeta(fnMetadata))
|
||||
executor.fsCreateWg.Delete(fnkeyUR)
|
||||
wg.Done()
|
||||
}()
|
||||
} else {
|
||||
// There's an existing request for this function, wait for it to finish
|
||||
go func() {
|
||||
executor.logger.Debug("waiting for concurrent request for the same function",
|
||||
zap.Any("function", fnMetadata))
|
||||
zap.String("function", fnName.String()))
|
||||
wg, ok := wg.(*sync.WaitGroup)
|
||||
if !ok {
|
||||
err := fmt.Errorf("could not convert value to workgroup for function %v in namespace %v", fnMetadata.Name, fnMetadata.Namespace)
|
||||
err := fmt.Errorf("could not convert value to workgroup for function %s", fnName)
|
||||
req.respChan <- &createFuncServiceResponse{
|
||||
funcSvc: nil,
|
||||
err: err,
|
||||
@@ -201,7 +203,7 @@ func (executor *Executor) serveCreateFuncServices() {
|
||||
// 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.Wrapf(err, "error getting service for function %v in namespace %v", fnMetadata.Name, fnMetadata.Namespace)
|
||||
err = errors.Wrapf(err, "error getting service for function %s", fnName)
|
||||
req.respChan <- &createFuncServiceResponse{
|
||||
funcSvc: fsvc,
|
||||
err: err,
|
||||
@@ -221,7 +223,7 @@ func (executor *Executor) createServiceForFunction(ctx context.Context, fn *fv1.
|
||||
t := fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType
|
||||
e, ok := executor.executorTypes[t]
|
||||
if !ok {
|
||||
return nil, errors.Errorf("Unknown executor type '%v'", t)
|
||||
return nil, errors.Errorf("Unknown executor type '%s'", t)
|
||||
}
|
||||
|
||||
fsvc, fsvcErr := e.GetFuncSvc(ctx, fn)
|
||||
@@ -242,7 +244,7 @@ func (executor *Executor) getFunctionServiceFromCache(ctx context.Context, fn *f
|
||||
t := fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType
|
||||
e, ok := executor.executorTypes[t]
|
||||
if !ok {
|
||||
return nil, errors.Errorf("Unknown executor type '%v'", t)
|
||||
return nil, errors.Errorf("Unknown executor type '%s'", t)
|
||||
}
|
||||
return e.GetFuncSvcFromCache(ctx, fn)
|
||||
}
|
||||
@@ -277,7 +279,7 @@ func StartExecutor(ctx context.Context, clientGen crd.ClientGeneratorInterface,
|
||||
executorInstanceID := strings.ToLower(uniuri.NewLen(8))
|
||||
|
||||
podSpecPatch, err := util.GetSpecFromConfigMap(fv1.RuntimePodSpecPath)
|
||||
if err != nil {
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
logger.Warn("error reading data for pod spec patch", zap.String("path", fv1.RuntimePodSpecPath), zap.Error(err))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user