Skip to content

Commit

Permalink
fix: fixing cache issues
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0elliot committed Oct 11, 2023
1 parent 7ad0936 commit 05e5d38
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions health.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,13 @@ func RunOpsHealthCheck(resp http.ResponseWriter, request *http.Request) {

if workflowHealth.Create == true {
log.Printf("[DEBUG] Deleting created ops workflow")
workflowHealth, err = deleteWorkflow(workflowHealth, apiKey)
err = deleteWorkflow(workflowHealth, apiKey)
if err != nil {
log.Printf("[ERROR] Failed deleting workflow: %s", err)
} else {
log.Printf("[DEBUG] Deleted ops workflow successfully!")
workflowHealth.Delete = true
updateCache(workflowHealth)
}
}
}
Expand Down Expand Up @@ -587,7 +591,7 @@ func OpsDashboardCacheHitStat(resp http.ResponseWriter, request *http.Request) {
resp.Write(statsBody)
}

func deleteWorkflow(workflowHealth WorkflowHealth , apiKey string) (WorkflowHealth, error) {
func deleteWorkflow(workflowHealth WorkflowHealth , apiKey string) (error) {
baseUrl := os.Getenv("SHUFFLE_CLOUDRUN_URL")
if len(baseUrl) == 0 {
baseUrl = "https://shuffler.io"
Expand All @@ -607,7 +611,7 @@ func deleteWorkflow(workflowHealth WorkflowHealth , apiKey string) (WorkflowHeal
req, err := http.NewRequest("DELETE", url, nil)
if err != nil {
log.Printf("[ERROR] Failed creating HTTP request: %s", err)
return workflowHealth, err
return err
}

// set the headers
Expand All @@ -619,19 +623,17 @@ func deleteWorkflow(workflowHealth WorkflowHealth , apiKey string) (WorkflowHeal
resp, err := client.Do(req)
if err != nil {
log.Printf("[ERROR] Failed deleting the health check workflow with HTTP request: %s", err)
return workflowHealth, err
return err
}

if resp.StatusCode != 200 {
log.Printf("[ERROR] Failed deleting the health check workflow: %s. The status code was: %d", err, resp.StatusCode)
return workflowHealth, err
return err
}

defer resp.Body.Close()

workflowHealth.Delete = true

return workflowHealth, nil
return nil
}

func RunOpsWorkflow(apiKey string, orgId string) (WorkflowHealth, error) {
Expand Down

0 comments on commit 05e5d38

Please sign in to comment.