Fixed a broken part of the condition system which didn't look for skipped/failed nodes

This commit is contained in:
frikky
2022-04-08 01:50:09 +02:00
parent b66d81178a
commit 63ce93500c
3 changed files with 61 additions and 17 deletions
+21
View File
@@ -2466,6 +2466,23 @@ class AppBase:
continue continue
matching_branches += 1 matching_branches += 1
# Find if previous is skipped or failed. Skipped != correct branch
try:
should_skip = False
for res in fullexecution["results"]:
if res["action"]["id"] == branch["source_id"]:
if res["status"] == "FAILURE" or res["status"] == "SKIPPED":
should_skip = True
break
if should_skip:
continue
except Exception as e:
self.logger.info("[WARNING] Failed handling check of if parent is skipped")
# Remove anything without a condition # Remove anything without a condition
try: try:
if (branch["conditions"]) == 0 or branch["conditions"] == None: if (branch["conditions"]) == 0 or branch["conditions"] == None:
@@ -2475,6 +2492,8 @@ class AppBase:
correct_branches += 1 correct_branches += 1
continue continue
# FIXME: Check if the previous node has a result or not
self.logger.info("[DEBUG] Relevant conditions: %s" % branch["conditions"]) self.logger.info("[DEBUG] Relevant conditions: %s" % branch["conditions"])
successful_conditions = [] successful_conditions = []
failed_conditions = [] failed_conditions = []
@@ -2535,6 +2554,8 @@ class AppBase:
if matching_branches > 0 and correct_branches > 0: if matching_branches > 0 and correct_branches > 0:
return True, "" return True, ""
# FIXME: Check if previous branches are at all finished
self.logger.info("[DEBUG] Correct branches vs matching branches: %d vs %d" % (correct_branches, matching_branches)) self.logger.info("[DEBUG] Correct branches vs matching branches: %d vs %d" % (correct_branches, matching_branches))
return False, {"success": False, "reason": "Minimum of one branch's conditions must be correct to continue. Total: %d of %d" % (correct_branches, matching_branches)} return False, {"success": False, "reason": "Minimum of one branch's conditions must be correct to continue. Total: %d of %d" % (correct_branches, matching_branches)}
+1 -1
View File
@@ -4075,7 +4075,7 @@ func runInitEs(ctx context.Context) {
// FIXME: Have this for all envs in all orgs (loop and find). // FIXME: Have this for all envs in all orgs (loop and find).
if len(parsedApikey) > 0 { if len(parsedApikey) > 0 {
cleanupSchedule := 600 cleanupSchedule := 300
environments := []string{"Shuffle"} environments := []string{"Shuffle"}
log.Printf("[DEBUG] Starting schedule setup for execution cleanup every %d seconds. Running first immediately.", cleanupSchedule) log.Printf("[DEBUG] Starting schedule setup for execution cleanup every %d seconds. Running first immediately.", cleanupSchedule)
cleanupJob := func() func() { cleanupJob := func() func() {
+39 -16
View File
@@ -495,23 +495,24 @@ func deployWorker(image string, identifier string, env []string, executionReques
// FIXME: Should we handle replies properly? // FIXME: Should we handle replies properly?
// In certain cases, a workflow may e.g. be aborted already. If it's aborted, that returns // In certain cases, a workflow may e.g. be aborted already. If it's aborted, that returns
// a 401 from the worker, which returns an error here // a 401 from the worker, which returns an error here
err := sendWorkerRequest(executionRequest) go sendWorkerRequest(executionRequest)
if err != nil { //err := sendWorkerRequest(executionRequest)
log.Printf("[ERROR] Failed worker request for %s: %s", executionRequest.ExecutionId, err) //if err != nil {
// log.Printf("[ERROR] Failed worker request for %s: %s", executionRequest.ExecutionId, err)
if strings.Contains(fmt.Sprintf("%s", err), "connection refused") || strings.Contains(fmt.Sprintf("%s", err), "EOF") { // if strings.Contains(fmt.Sprintf("%s", err), "connection refused") || strings.Contains(fmt.Sprintf("%s", err), "EOF") {
workerImage := fmt.Sprintf("%s/%s/shuffle-worker:%s", baseimageregistry, baseimagename, workerVersion) // workerImage := fmt.Sprintf("%s/%s/shuffle-worker:%s", baseimageregistry, baseimagename, workerVersion)
deployServiceWorkers(workerImage) // deployServiceWorkers(workerImage)
time.Sleep(time.Duration(10) * time.Second) // time.Sleep(time.Duration(10) * time.Second)
err = sendWorkerRequest(executionRequest) // err = sendWorkerRequest(executionRequest)
} // }
} //}
if err == nil { //if err == nil {
// FIXME: Readd this? Removed for rerun reasons // // FIXME: Readd this? Removed for rerun reasons
// executionIds = append(executionIds, executionRequest.ExecutionId) // // executionIds = append(executionIds, executionRequest.ExecutionId)
} //}
//}() //}()
return nil return nil
@@ -1327,21 +1328,36 @@ func sendWorkerRequest(workflowExecution shuffle.ExecutionRequest) error {
streamUrl = fmt.Sprintf("%s:33333/api/v1/execute", parsedBaseurl) streamUrl = fmt.Sprintf("%s:33333/api/v1/execute", parsedBaseurl)
} }
client := &http.Client{}
req, err := http.NewRequest( req, err := http.NewRequest(
"POST", "POST",
streamUrl, streamUrl,
bytes.NewBuffer([]byte(data)), bytes.NewBuffer([]byte(data)),
) )
client := &http.Client{}
if err != nil { if err != nil {
log.Printf("[ERROR] Failed creating worker request: %s", err) log.Printf("[ERROR] Failed creating worker request: %s", err)
if strings.Contains(fmt.Sprintf("%s", err), "connection refused") || strings.Contains(fmt.Sprintf("%s", err), "EOF") {
workerImage := fmt.Sprintf("%s/%s/shuffle-worker:%s", baseimageregistry, baseimagename, workerVersion)
deployServiceWorkers(workerImage)
time.Sleep(time.Duration(10) * time.Second)
//err = sendWorkerRequest(executionRequest)
}
return err return err
} }
newresp, err := client.Do(req) newresp, err := client.Do(req)
if err != nil { if err != nil {
log.Printf("[ERROR] Error running worker request: %s", err) log.Printf("[ERROR] Error running worker request: %s", err)
if strings.Contains(fmt.Sprintf("%s", err), "connection refused") || strings.Contains(fmt.Sprintf("%s", err), "EOF") {
workerImage := fmt.Sprintf("%s/%s/shuffle-worker:%s", baseimageregistry, baseimagename, workerVersion)
deployServiceWorkers(workerImage)
time.Sleep(time.Duration(10) * time.Second)
//err = sendWorkerRequest(executionRequest)
}
return err return err
} }
@@ -1353,6 +1369,13 @@ func sendWorkerRequest(workflowExecution shuffle.ExecutionRequest) error {
if newresp.StatusCode != 200 { if newresp.StatusCode != 200 {
log.Printf("[ERROR] Error running worker request - status code is %d, not 200. Body: %s", newresp.StatusCode, string(body)) log.Printf("[ERROR] Error running worker request - status code is %d, not 200. Body: %s", newresp.StatusCode, string(body))
workerImage := fmt.Sprintf("%s/%s/shuffle-worker:%s", baseimageregistry, baseimagename, workerVersion)
deployServiceWorkers(workerImage)
time.Sleep(time.Duration(10) * time.Second)
//err = sendWorkerRequest(executionRequest)
return errors.New(fmt.Sprintf("Bad statuscode from worker: %d - expecting 200", newresp.StatusCode)) return errors.New(fmt.Sprintf("Bad statuscode from worker: %d - expecting 200", newresp.StatusCode))
} }