Fix newdeploy failed to find serviceEntry in cache (#1349)
When a function with executor type newdeploy got created, Newdeploy is expected to create deployment/HPA/service for it and insert serviceEntry to the cache for later use. Once clients call the function, newdeploy returns the serviceEntry to the router. However, the log shows that the newdeploy was unable to find the entry and prints "Resource not found - key 'xxx' not found". The root cause is that the informer controller instead of processing items in parallel, it dispatches XXFunc to process items one by one. So if there is any problem during the creation of the kubernetes resource, it takes a longer time to process the next item and hence the serviceEntry was not inserted before clients call the function. This PR lets the newdeploy to process items in extra goroutines instead of blocking the process loop. It's a workaround to solve the problem above, we should consider using workqueue to solve it in the future.
This commit is contained in:
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
@@ -111,11 +110,10 @@ func (api *API) respondWithSuccess(w http.ResponseWriter, resp []byte) {
|
||||
}
|
||||
|
||||
func (api *API) respondWithError(w http.ResponseWriter, err error) {
|
||||
debug.PrintStack()
|
||||
|
||||
// this error type comes with an HTTP code, so just use that
|
||||
se, ok := err.(*kerrors.StatusError)
|
||||
if ok {
|
||||
api.logger.Error(err.Error(), zap.Int32("code", se.ErrStatus.Code))
|
||||
http.Error(w, string(se.ErrStatus.Reason), int(se.ErrStatus.Code))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user