Fixed a bunch of possible issues with User Input on cloud vs onprem, and how workflows start in shuffle-shared

This commit is contained in:
Frikky
2024-08-20 23:29:09 +02:00
parent 1a9f82a3e7
commit fe2e3105eb
9 changed files with 42 additions and 64 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ module shuffle
go 1.22.0 go 1.22.0
// replace github.com/shuffle/shuffle-shared => ../../../shuffle-shared //replace github.com/shuffle/shuffle-shared => ../../../shuffle-shared
toolchain go1.22.2 toolchain go1.22.2
@@ -20,7 +20,7 @@ require (
github.com/gorilla/mux v1.8.1 github.com/gorilla/mux v1.8.1
github.com/h2non/filetype v1.1.3 github.com/h2non/filetype v1.1.3
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/shuffle/shuffle-shared v0.6.62 github.com/shuffle/shuffle-shared v0.6.63
golang.org/x/crypto v0.22.0 golang.org/x/crypto v0.22.0
google.golang.org/api v0.176.1 google.golang.org/api v0.176.1
google.golang.org/grpc v1.63.2 google.golang.org/grpc v1.63.2
+1 -1
View File
@@ -3926,7 +3926,7 @@ func runInitEs(ctx context.Context) {
} }
if strings.Contains(os.Getenv("SHUFFLE_OPENSEARCH_URL"), "https") { if strings.Contains(os.Getenv("SHUFFLE_OPENSEARCH_URL"), "https") {
log.Printf("[INFO] Waiting during init to make sure the opensearch instance is up and running with security features properly") log.Printf("[INFO] Waiting 30 seconds during init to make sure the opensearch instance is up and running with security features enabled")
time.Sleep(30 * time.Second) time.Sleep(30 * time.Second)
} }
+12 -22
View File
@@ -669,7 +669,7 @@ func handleWorkflowQueue(resp http.ResponseWriter, request *http.Request) {
} }
//log.Printf("Actionresult unmarshal: %s", string(body)) //log.Printf("Actionresult unmarshal: %s", string(body))
log.Printf("[DEBUG] Got workflow result from %s of length %d", request.RemoteAddr, len(body)) //log.Printf("[DEBUG] Got workflow result from %s of length %d", request.RemoteAddr, len(body))
ctx := context.Background() ctx := context.Background()
err = shuffle.ValidateNewWorkerExecution(ctx, body) err = shuffle.ValidateNewWorkerExecution(ctx, body)
if err == nil { if err == nil {
@@ -680,7 +680,7 @@ func handleWorkflowQueue(resp http.ResponseWriter, request *http.Request) {
log.Printf("[DEBUG] Handling other execution variant (subflow?): %s", err) log.Printf("[DEBUG] Handling other execution variant (subflow?): %s", err)
} }
log.Printf("[DEBUG] Got workflow result from %s of length %d.", request.RemoteAddr, len(body)) //log.Printf("[DEBUG] Got workflow result from %s of length %d.", request.RemoteAddr, len(body))
var actionResult shuffle.ActionResult var actionResult shuffle.ActionResult
err = json.Unmarshal(body, &actionResult) err = json.Unmarshal(body, &actionResult)
@@ -738,7 +738,7 @@ func handleWorkflowQueue(resp http.ResponseWriter, request *http.Request) {
// Will make sure transactions are always ran for an execution. This is recursive if it fails. Allowed to fail up to 5 times // Will make sure transactions are always ran for an execution. This is recursive if it fails. Allowed to fail up to 5 times
func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workflowExecutionId string, actionResult shuffle.ActionResult, resp http.ResponseWriter) { func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workflowExecutionId string, actionResult shuffle.ActionResult, resp http.ResponseWriter) {
log.Printf("[DEBUG][%s] Running workflow execution update", workflowExecutionId) log.Printf("[DEBUG][%s] Running workflow execution update with result from %s (%s) of status %s", workflowExecutionId, actionResult.Action.Label, actionResult.Action.ID, actionResult.Status)
// Should start a tx for the execution here // Should start a tx for the execution here
workflowExecution, err := shuffle.GetWorkflowExecution(ctx, workflowExecutionId) workflowExecution, err := shuffle.GetWorkflowExecution(ctx, workflowExecutionId)
@@ -769,7 +769,6 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
setExecution := true setExecution := true
if setExecution || workflowExecution.Status == "FINISHED" || workflowExecution.Status == "ABORTED" || workflowExecution.Status == "FAILURE" { if setExecution || workflowExecution.Status == "FINISHED" || workflowExecution.Status == "ABORTED" || workflowExecution.Status == "FAILURE" {
err = shuffle.SetWorkflowExecution(ctx, *workflowExecution, true) err = shuffle.SetWorkflowExecution(ctx, *workflowExecution, true)
//err = shuffle.SetWorkflowExecution(ctx, *workflowExecution, dbSave)
if err != nil { if err != nil {
resp.WriteHeader(401) resp.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed setting workflowexecution actionresult: %s"}`, err))) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed setting workflowexecution actionresult: %s"}`, err)))
@@ -1000,17 +999,6 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
workflow = *tmpworkflow workflow = *tmpworkflow
} }
/*
if len(workflow.ExecutingOrg.Id) == 0 {
if len(orgId) > 0 {
workflow.ExecutingOrg.Id = orgId
} else {
log.Printf("[INFO] Stopped execution because there is no executing org for workflow %s", workflow.ID)
return shuffle.WorkflowExecution{}, fmt.Sprintf("Workflow has no executing org defined"), errors.New("Workflow has no executing org defined")
}
}
*/
if len(workflow.Actions) == 0 { if len(workflow.Actions) == 0 {
workflow.Actions = []shuffle.Action{} workflow.Actions = []shuffle.Action{}
} else { } else {
@@ -1061,18 +1049,21 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
workflowExecution, execInfo, _, workflowExecErr := shuffle.PrepareWorkflowExecution(ctx, workflow, request, int64(maxExecutionDepth)) workflowExecution, execInfo, _, workflowExecErr := shuffle.PrepareWorkflowExecution(ctx, workflow, request, int64(maxExecutionDepth))
if workflowExecErr != nil { if workflowExecErr != nil {
err := shuffle.SetWorkflowExecution(ctx, workflowExecution, true) if len(workflowExecution.Workflow.Actions) > 0 && len(workflowExecution.Results) > 0 && len(workflowExecution.ExecutionId) > 0 {
if err != nil { err := shuffle.SetWorkflowExecution(ctx, workflowExecution, true)
log.Printf("[ERROR] Failed setting workflow execution during init (2): %s", err) if err != nil {
log.Printf("[ERROR] Failed setting workflow execution during init (2): %s", err)
}
} }
if strings.Contains(fmt.Sprintf("%s", workflowExecErr), "User Input") { if strings.Contains(fmt.Sprintf("%s", workflowExecErr), "User Input") {
// Special for user input callbacks // Special for user input callbacks
log.Printf("[INFO] User input callback: %s", workflowExecErr)
// return workflowExecution, fmt.Sprintf("%s", err), nil // return workflowExecution, fmt.Sprintf("%s", err), nil
//log.Printf("[INFO] User input callback: %s", workflowExecErr)
return shuffle.WorkflowExecution{}, "", nil
} else { } else {
log.Printf("[ERROR] Failed in prepareExecution: '%s'", err) log.Printf("[ERROR] Failed in prepareExecution: '%s'", workflowExecErr)
return shuffle.WorkflowExecution{}, fmt.Sprintf("Failed running: %s", err), err return shuffle.WorkflowExecution{}, fmt.Sprintf("Failed running: %s", workflowExecErr), workflowExecErr
} }
} }
@@ -1854,7 +1845,6 @@ func executeWorkflow(resp http.ResponseWriter, request *http.Request) {
} }
log.Printf("[INFO] Inside execute workflow for ID %s", fileId) log.Printf("[INFO] Inside execute workflow for ID %s", fileId)
ctx := context.Background() ctx := context.Background()
workflow, err := shuffle.GetWorkflow(ctx, fileId) workflow, err := shuffle.GetWorkflow(ctx, fileId)
if err != nil && workflow.ID == "" { if err != nil && workflow.ID == "" {
+21 -17
View File
@@ -196,26 +196,30 @@ const App = (message, props) => {
} }
<div style={{ minHeight: 68, maxHeight: 68, }}> <div style={{ minHeight: 68, maxHeight: 68, }}>
<Header {curpath.includes("/workflows") && curpath.includes("/run") ?
billingInfo={{}} <div style={{ height: 60, }} />
:
<Header
billingInfo={{}}
notifications={notifications} notifications={notifications}
setNotifications={setNotifications} setNotifications={setNotifications}
checkLogin={checkLogin} checkLogin={checkLogin}
cookies={cookies} cookies={cookies}
removeCookie={removeCookie} removeCookie={removeCookie}
isLoaded={isLoaded} isLoaded={isLoaded}
globalUrl={globalUrl} globalUrl={globalUrl}
setIsLoggedIn={setIsLoggedIn} setIsLoggedIn={setIsLoggedIn}
isLoggedIn={isLoggedIn} isLoggedIn={isLoggedIn}
userdata={userdata} userdata={userdata}
curpath={curpath} curpath={curpath}
serverside={false} serverside={false}
isMobile={false} isMobile={false}
{...props} {...props}
/> />
}
</div> </div>
{/* {/*
+2 -2
View File
@@ -11,14 +11,14 @@ import {
import HealthBarChart from '../components/HealthBarChart.jsx'; import HealthBarChart from '../components/HealthBarChart.jsx';
const HealthPage = (props) => { const HealthPage = (props) => {
const { userdata } = props; const { globalUrl, userdata } = props;
const [healthData, setHealthData] = useState(null); const [healthData, setHealthData] = useState(null);
const [selectedRange, setSelectedRange] = useState('30d'); const [selectedRange, setSelectedRange] = useState('30d');
const [filteredData, setFilteredData] = useState([]); const [filteredData, setFilteredData] = useState([]);
const [averageUptime, setAverageUptime] = useState(0); const [averageUptime, setAverageUptime] = useState(0);
const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"; const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io";
const globalUrl = `https://shuffler.io` //const globalUrl = `https://shuffler.io`
console.log("HEALTHPAGE 1") console.log("HEALTHPAGE 1")
-18
View File
@@ -6305,10 +6305,6 @@ If you're interested, please let me know a time that works for you, or set up a
primary="Actions" primary="Actions"
style={{ minWidth: 200, maxWidth: 200 }} style={{ minWidth: 200, maxWidth: 200 }}
/> />
<ListItemText
primary="Last Edited"
style={{ minWidth: 170, maxWidth: 170 }}
/>
</ListItem> </ListItem>
{environments === undefined || environments === null {environments === undefined || environments === null
? null ? null
@@ -6626,20 +6622,6 @@ If you're interested, please let me know a time that works for you, or set up a
</ButtonGroup> </ButtonGroup>
</div> </div>
</ListItemText> </ListItemText>
<ListItemText
style={{
minWidth: 150,
maxWidth: 150,
overflow: "hidden",
}}
primary={
environment.edited !== undefined &&
environment.edited !== null &&
environment.edited !== 0
? new Date(environment.edited * 1000).toISOString()
: 0
}
/>
</ListItem> </ListItem>
{showCPUAlert === false ? null : ( {showCPUAlert === false ? null : (
<ListItem <ListItem
+1 -1
View File
@@ -10,7 +10,7 @@ require (
github.com/docker/docker v27.0.2+incompatible github.com/docker/docker v27.0.2+incompatible
github.com/docker/go-connections v0.5.0 github.com/docker/go-connections v0.5.0
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/shuffle/shuffle-shared v0.6.61 github.com/shuffle/shuffle-shared v0.6.63
k8s.io/api v0.30.2 k8s.io/api v0.30.2
k8s.io/apimachinery v0.30.2 k8s.io/apimachinery v0.30.2
k8s.io/client-go v0.30.2 k8s.io/client-go v0.30.2
+2
View File
@@ -269,6 +269,8 @@ github.com/shuffle/shuffle-shared v0.6.59 h1:Pjvq4Lz6OAjA+hycwzUnm+f/pUiR5apR9Cz
github.com/shuffle/shuffle-shared v0.6.59/go.mod h1:RAJiSFjmuKmijKTbbEf9A6Ojb+3/te7g71lED7JjPus= github.com/shuffle/shuffle-shared v0.6.59/go.mod h1:RAJiSFjmuKmijKTbbEf9A6Ojb+3/te7g71lED7JjPus=
github.com/shuffle/shuffle-shared v0.6.60 h1:8OaiNxNpzJmIbYIcXI3TIYZVrPJ1sSCa+u7itMUMmxs= github.com/shuffle/shuffle-shared v0.6.60 h1:8OaiNxNpzJmIbYIcXI3TIYZVrPJ1sSCa+u7itMUMmxs=
github.com/shuffle/shuffle-shared v0.6.60/go.mod h1:RAJiSFjmuKmijKTbbEf9A6Ojb+3/te7g71lED7JjPus= github.com/shuffle/shuffle-shared v0.6.60/go.mod h1:RAJiSFjmuKmijKTbbEf9A6Ojb+3/te7g71lED7JjPus=
github.com/shuffle/shuffle-shared v0.6.61 h1:+9CCLeZLiAVDgNRTkZxnIgz+FZ7UrEHez2BAGPS/axc=
github.com/shuffle/shuffle-shared v0.6.61/go.mod h1:RAJiSFjmuKmijKTbbEf9A6Ojb+3/te7g71lED7JjPus=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ=
github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
+1 -1
View File
@@ -6,7 +6,7 @@ require (
github.com/docker/docker v26.1.0+incompatible github.com/docker/docker v26.1.0+incompatible
github.com/gorilla/mux v1.8.1 github.com/gorilla/mux v1.8.1
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/shuffle/shuffle-shared v0.6.37 github.com/shuffle/shuffle-shared v0.6.63
k8s.io/api v0.30.0 k8s.io/api v0.30.0
k8s.io/apimachinery v0.30.0 k8s.io/apimachinery v0.30.0
k8s.io/client-go v0.30.0 k8s.io/client-go v0.30.0