Skip to content

Commit 4de9074

Browse files
committed
Further optimized usecase generation a tiny bit
1 parent 1adb68c commit 4de9074

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

db-connector.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,11 +1698,15 @@ func Fixexecution(ctx context.Context, workflowExecution WorkflowExecution) (Wor
16981698
dbsave := false
16991699
workflowExecution.Workflow.Image = ""
17001700

1701-
if workflowExecution.Status != "EXECUTING" {
1702-
validation, err := GetExecutionValidation(ctx, workflowExecution.ExecutionId)
1703-
if err == nil {
1704-
workflowExecution.Workflow.Validation = validation
1701+
// FIXME: May be a problem here with setting it at all times~
1702+
//if workflowExecution.Status != "EXECUTING" {
1703+
validation, err := GetExecutionValidation(ctx, workflowExecution.ExecutionId)
1704+
if err == nil {
1705+
if workflowExecution.NotificationsCreated > 0 {
1706+
validation.NotificationsCreated = workflowExecution.NotificationsCreated
17051707
}
1708+
1709+
workflowExecution.Workflow.Validation = validation
17061710
}
17071711

17081712
// Make sure to not having missing items in the execution
@@ -3235,6 +3239,15 @@ func GetWorkflow(ctx context.Context, id string) (*Workflow, error) {
32353239
cacheData := []byte(cache.([]uint8))
32363240
err = json.Unmarshal(cacheData, &workflow)
32373241
if err == nil && workflow.ID != "" {
3242+
validationData, err := GetCache(ctx, fmt.Sprintf("validation_workflow_%s", workflow.ID))
3243+
if err == nil {
3244+
cacheData := []byte(validationData.([]uint8))
3245+
err = json.Unmarshal(cacheData, &workflow.Validation)
3246+
if err != nil {
3247+
log.Printf("[ERROR] Failed unmarshalling cache data for execution status (4): %s", err)
3248+
}
3249+
}
3250+
32383251
// Somehow this can happen. Reverting to LATEST revision
32393252
if len(workflow.Actions) > 0 && len(workflow.Triggers) == 0 {
32403253
revisions, err := ListWorkflowRevisions(ctx, workflow.ID, 2)

shared.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5016,6 +5016,9 @@ func HandleGetTriggers(resp http.ResponseWriter, request *http.Request) {
50165016
}
50175017

50185018
func GetGcpSchedule(ctx context.Context, id string) (*ScheduleOld, error) {
5019+
if project.Environment != "cloud" {
5020+
return &ScheduleOld{}, nil
5021+
}
50195022

50205023
// Check if we have the schedule in cache
50215024
cacheData, err := GetCache(ctx, fmt.Sprintf("schedule-%s", id))
@@ -5055,9 +5058,13 @@ func GetGcpSchedule(ctx context.Context, id string) (*ScheduleOld, error) {
50555058
}
50565059
resp, err := c.GetJob(ctx, req)
50575060
if err != nil {
5058-
log.Printf("[ERROR] Failed getting schedule %s: %s", id, err)
5061+
if !strings.Contains(err.Error(), "NotFound") {
5062+
log.Printf("[ERROR] Failed getting schedule %s: %s", id, err)
5063+
}
5064+
50595065
return schedule, err
50605066
}
5067+
50615068
schedule.Id = id
50625069
schedule.Name = resp.Name
50635070
if resp.State == schedulerpb.Job_ENABLED {
@@ -10587,7 +10594,7 @@ func GetSpecificWorkflow(resp http.ResponseWriter, request *http.Request) {
1058710594
}
1058810595

1058910596
//Check if workflow trigger schedule is in sync with the gcp cron job
10590-
if workflow.Triggers != nil {
10597+
if project.Environment == "cloud" && workflow.Triggers != nil {
1059110598
var wg sync.WaitGroup
1059210599
triggerMutex := sync.Mutex{}
1059310600

@@ -23299,7 +23306,7 @@ func HealthCheckHandler(resp http.ResponseWriter, request *http.Request) {
2329923306
// 2. Parent workflow's owner is same org?
2330023307
// 3. Parent execution auth is correct
2330123308
func RunExecuteAccessValidation(request *http.Request, workflow *Workflow) (bool, string) {
23302-
log.Printf("[DEBUG] Inside execute validation for workflow %s (%s)! Request method: %s", workflow.Name, workflow.ID, request.Method)
23309+
//log.Printf("[DEBUG] Inside execute validation for workflow %s (%s)! Request method: %s", workflow.Name, workflow.ID, request.Method)
2330323310

2330423311
//if request.Method == "POST" {
2330523312
ctx := GetContext(request)
@@ -30585,6 +30592,7 @@ func checkExecutionStatus(ctx context.Context, exec *WorkflowExecution) *Workflo
3058530592
*/
3058630593
}
3058730594

30595+
exec.Workflow.Validation.NotificationsCreated = exec.NotificationsCreated
3058830596
exec.Workflow.Validation = workflow.Validation
3058930597
marshalledValidation, err := json.Marshal(workflow.Validation)
3059030598
if err != nil {
@@ -30597,7 +30605,6 @@ func checkExecutionStatus(ctx context.Context, exec *WorkflowExecution) *Workflo
3059730605
SetCache(backgroundContext, cacheKey, marshalledValidation, 120)
3059830606

3059930607
// ALWAYS have correct exec id for current execution, but not always in workflow
30600-
3060130608
//log.Printf("\n\n[DEBUG][%s] Set workflow validation (%d) to '%s'\n\n", exec.ExecutionId, len(workflow.Validation.Errors), marshalledValidation)
3060230609

3060330610
return exec

structs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,7 @@ type TypeValidation struct {
15321532
ChangedAt int64 `json:"changed_at" datastore:"changed_at"`
15331533
LastValid int64 `json:"last_valid" datastore:"last_valid"`
15341534
ValidationRan bool `json:"validation_ran" datastore:"validation_ran"`
1535+
NotificationsCreated int64 `json:"notifications_created" datastore:"notifications_created"`
15351536

15361537
// For the last update, which did it
15371538
WorkflowId string `json:"workflow_id" datastore:"workflow_id"`

0 commit comments

Comments
 (0)