Fixed further execution concurrency issues with sdk & worker
This commit is contained in:
@@ -656,7 +656,7 @@ func getDockerImage(resp http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Image to load: %s", version.Name)
|
||||
//log.Printf("[DEBUG] Image to load: %s", version.Name)
|
||||
dockercli, err := client.NewEnvClient()
|
||||
if err != nil {
|
||||
log.Printf("[WARNING] Unable to create docker client: %s", err)
|
||||
@@ -701,16 +701,16 @@ func getDockerImage(resp http.ResponseWriter, request *http.Request) {
|
||||
if len(img.ID) == 0 {
|
||||
if len(img2.ID) == 0 {
|
||||
workflowapps, err := shuffle.GetAllWorkflowApps(ctx, 0, 0)
|
||||
log.Printf("[INFO] Getting workflowapps for a rebuild. Got %d with err %#v", len(workflowapps), err)
|
||||
//log.Printf("[INFO] Getting workflowapps for a rebuild. Got %d with err %#v", len(workflowapps), err)
|
||||
if err == nil {
|
||||
imageName := ""
|
||||
imageVersion := ""
|
||||
newNameSplit := strings.Split(version.Name, ":")
|
||||
if len(newNameSplit) == 2 {
|
||||
log.Printf("[DEBUG] Found name %#v", newNameSplit)
|
||||
//log.Printf("[DEBUG] Found name %#v", newNameSplit)
|
||||
|
||||
findVersionSplit := strings.Split(newNameSplit[1], "_")
|
||||
log.Printf("[DEBUG] Found another split %#v", findVersionSplit)
|
||||
//log.Printf("[DEBUG] Found another split %#v", findVersionSplit)
|
||||
if len(findVersionSplit) == 2 {
|
||||
imageVersion = findVersionSplit[len(findVersionSplit)-1]
|
||||
imageName = findVersionSplit[0]
|
||||
@@ -776,7 +776,7 @@ func getDockerImage(resp http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
|
||||
//log.Printf("[INFO] Img found (%s): %#v", tagFound, img)
|
||||
log.Printf("[INFO] Img found to be downloaded by client: %s", tagFound)
|
||||
//log.Printf("[INFO] Img found to be downloaded by client: %s", tagFound)
|
||||
|
||||
newClient, err := newdockerclient.NewClientFromEnv()
|
||||
if err != nil {
|
||||
|
||||
@@ -24,7 +24,7 @@ require (
|
||||
github.com/h2non/filetype v1.1.3
|
||||
github.com/nirasan/go-oauth-pkce-code-verifier v0.0.0-20170819232839-0fbfe93532da // indirect
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/shuffle/shuffle-shared v0.2.17
|
||||
github.com/shuffle/shuffle-shared v0.2.27
|
||||
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce
|
||||
google.golang.org/api v0.65.0
|
||||
|
||||
@@ -376,10 +376,22 @@ func handleGetStreamResults(resp http.ResponseWriter, request *http.Request) {
|
||||
|
||||
// Authorization is done here
|
||||
if workflowExecution.Authorization != actionResult.Authorization {
|
||||
log.Printf("[WARNING] Bad authorization key when getting stream results %s.", actionResult.ExecutionId)
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad authorization key or execution_id might not exist."}`)))
|
||||
return
|
||||
user, err := shuffle.HandleApiAuthentication(resp, request)
|
||||
if err != nil {
|
||||
log.Printf("[WARNING] Api authentication failed in exec grabbing workflow: %s", err)
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad authorization key or execution_id might not exist."}`)))
|
||||
return
|
||||
}
|
||||
|
||||
if len(workflowExecution.ExecutionOrg) > 0 && user.ActiveOrg.Id == workflowExecution.ExecutionOrg && user.Role == "admin" {
|
||||
log.Printf("[DEBUG] Correct org for execution!")
|
||||
} else {
|
||||
log.Printf("[WARNING] Bad authorization key when getting stream results %s.", actionResult.ExecutionId)
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad authorization key or execution_id might not exist."}`)))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
newjson, err := json.Marshal(workflowExecution)
|
||||
@@ -828,7 +840,7 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
|
||||
if workflow.ID == "" || workflow.ID != id {
|
||||
tmpworkflow, err := shuffle.GetWorkflow(ctx, id)
|
||||
if err != nil {
|
||||
log.Printf("[WARNING] Failed getting the workflow locally (execution setup): %s", err)
|
||||
//log.Printf("[WARNING] Failed getting the workflow locally (execution setup): %s", err)
|
||||
return shuffle.WorkflowExecution{}, "Failed getting workflow", err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user