in openwhisk/initHandler.go [114:165]
func doRemoteInit(ap *ActionProxy, request initRequest, w http.ResponseWriter) bool {
Debug("Remote initialization started.")
// Get the action code hash from the client request
actionCodeHash, ok := request.Value.Env[OW_CODE_HASH].(string)
if !ok {
sendError(w, http.StatusBadGateway, "Cannot identify the action in remote runtime (missing hash).")
return false
}
if request.ProxiedActionID == "" {
sendError(w, http.StatusBadGateway, "Missing action id from client.")
return false
}
Debug("Action code hash extracted: %s", actionCodeHash)
// check if the action is already initialized
if nestedAP, ok := ap.serverProxyData.actions[actionCodeHash]; ok {
Debug("Action already initialized. Added action ID %s to action hash %s", request.ProxiedActionID, actionCodeHash)
nestedAP.connectedActionIDs = append(nestedAP.connectedActionIDs, request.ProxiedActionID)
sendOK(w)
return true
}
outLog, err := os.CreateTemp("", "out-log")
if err != nil {
outLog = ap.outFile
}
errLog, err := os.CreateTemp("", "err-log")
if err != nil {
errLog = ap.errFile
}
Debug("Creating nested action proxy...")
innerActionProxy := NewActionProxy(ap.baseDir, ap.compiler, outLog, errLog, ProxyModeNone)
if err := innerActionProxy.doInit(request, w); err != nil {
return false
}
ap.serverProxyData.actions[actionCodeHash] = &RemoteAPValue{
remoteProxy: innerActionProxy,
connectedActionIDs: []string{request.ProxiedActionID},
runRequestQueue: make(chan *remoteRunChanPayload, 50), // size could be determined empirically
}
Debug("Started listening to run requests for AP with code hash %s...", actionCodeHash)
go startListenToRunRequests(innerActionProxy, ap.serverProxyData.actions[actionCodeHash].runRequestQueue)
Debug("Added action id %s to action hash %s", request.ProxiedActionID, actionCodeHash)
return true
}