Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions health.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,10 +885,7 @@ func fixOpensearch() error {
return nil
}

func fixSubflow(ctx context.Context, workflow *Workflow) error {

apiKey := os.Getenv("SHUFFLE_OPS_DASHBOARD_APIKEY")
orgId := os.Getenv("SHUFFLE_OPS_DASHBOARD_ORG")
func fixSubflowParameters(ctx context.Context, workflow *Workflow, apiKey string, orgId string) error {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a generic function we can pass in a workflow into and it will fix parameters at all times, or is it specifically for health?

If it's for health, please make that clear in the name, as while grepping for relevant functions, I may end up just using it (:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is specifically for the health API. Let me fix the name of the functions to make them more clear :)


subflowActionId := ""
for _, action := range workflow.Actions {
Expand All @@ -910,12 +907,20 @@ func fixSubflow(ctx context.Context, workflow *Workflow) error {
}
}

baseUrl := os.Getenv("SHUFFLE_CLOUDRUN_URL")
if len(baseUrl) == 0 {
baseUrl := "https://shuffler.io"
if len(os.Getenv("SHUFFLE_CLOUDRUN_URL")) > 0 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use SHUFFLE_CLOUDRUN_URL last, as that makes it possible to use it as an onprem environment variable to override URLs in general.

log.Printf("[DEBUG] Base url not set. Setting to default")
baseUrl = "https://shuffler.io"
baseUrl = os.Getenv("SHUFFLE_CLOUDRUN_URL")
}

if project.Environment == "onprem" {
log.Printf("[DEBUG] Onprem environment. Setting base url to localhost")
// This will work as the health will be handled in the backend itself.
// so localhost just works. (Tested)
baseUrl = "http://localhost:5001"
}


req, err := http.NewRequest("PUT", baseUrl+"/api/v1/workflows/"+workflow.ID+"?skip_save=true", nil)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this more readable. Just make a variable for the URL and newline each item. Hard to come in here and get the point without that.

Why is it a PUT request without any data? 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are actually defining the body in the later part of the code, this is just being use to create new Request type.
https://github.com/Shuffle/shuffle-shared/pull/143/files/a9d13e1dae8f0fa3863f10e982a4191dacf46c2f#diff-46ab8d7c52533584f96ba53eaeadd8cf52839f1c5d175c059ceb909c2c3e0715R947

if err != nil {
log.Println("[ERROR] creating HTTP request:", err)
Expand Down Expand Up @@ -1028,7 +1033,7 @@ func RunOpsWorkflow(apiKey string, orgId string, cloudRunUrl string) (WorkflowHe
workflowHealth.WorkflowId = opsWorkflowID
updateOpsCache(workflowHealth)

err = fixSubflow(ctx, workflowPtr)
err = fixSubflowParameters(ctx, workflowPtr, apiKey, orgId)

workflow := *workflowPtr

Expand Down
Loading