@@ -481,7 +481,7 @@ func deleteJunkOpsWorkflow(ctx context.Context, workflowHealth WorkflowHealth) e
481481
482482 if len (workflows ) == 0 {
483483 //log.Printf("[DEBUG] Couldn't find any workflow named SHUFFLE_INTERNAL_OPS_WORKFLOW")
484- return errors .New ("Failed finding workflow named SHUFFLE_INTERNAL_OPS_WORKFLOW " )
484+ return errors .New ("Failed finding workflow named Ops Dashboard Workflow " )
485485 }
486486
487487 //log.Printf("[DEBUG] Found %d workflows named SHUFFLE_INTERNAL_OPS_WORKFLOW: ", len(workflows))
@@ -747,9 +747,21 @@ func RunOpsHealthCheck(resp http.ResponseWriter, request *http.Request) {
747747 errorChannel <- err
748748 }()
749749
750+ datastoreHealthChannel := make (chan DatastoreHealth )
751+ go func () {
752+ datastoreHealth , err := RunOpsDatastore (apiKey , orgId )
753+ if err != nil {
754+ log .Printf ("[ERROR] Failed running datastore health check: %s" , err )
755+ }
756+
757+ datastoreHealthChannel <- datastoreHealth
758+ errorChannel <- err
759+ }()
760+
750761 // Use channel for getting RunOpsWorkflow function results
751762 platformHealth .Apps = <- openapiAppHealthChannel
752763 platformHealth .PythonApps = <- pythonAppHealthChannel
764+ platformHealth .Datastore = <- datastoreHealthChannel
753765 }
754766
755767 platformHealth .Workflows = <- workflowHealthChannel
@@ -1977,7 +1989,16 @@ func InitOpsWorkflow(apiKey string, OrgId string) (string, error) {
19771989// Create datastore
19781990// read it
19791991// delete it
1980- func RunOpsDatastore (baseUrl , apikey , orgId string ) (DatastoreHealth , error ) {
1992+ func RunOpsDatastore (apikey , orgId string ) (DatastoreHealth , error ) {
1993+ baseUrl := os .Getenv ("SHUFFLE_CLOUDRUN_URL" )
1994+ if len (baseUrl ) == 0 {
1995+ baseUrl = "https://shuffler.io"
1996+ }
1997+
1998+ if project .Environment == "onprem" {
1999+ baseUrl = "http://localhost:5001"
2000+ }
2001+
19812002 datastoreHealth := DatastoreHealth {
19822003 Create : false ,
19832004 Read : false ,
@@ -1986,8 +2007,8 @@ func RunOpsDatastore(baseUrl, apikey, orgId string) (DatastoreHealth, error) {
19862007 }
19872008
19882009 // create datastore entry
1989- PAYLOAD := `{"key": "SHUFFLE_HEALTH_CHECK", "value": [1,2,3,4,5,6,7,8] }, "category": "SHUFFLE_HEALTH_CHECK"}`
1990- url := fmt .Sprint ("%s/api/v1/orgs/%s/set_cache" , baseUrl , orgId )
2010+ PAYLOAD := `{"key": "SHUFFLE_HEALTH_CHECK", "value": "yesy" }, "category": "SHUFFLE_HEALTH_CHECK"}`
2011+ url := fmt .Sprintf ("%s/api/v1/orgs/%s/set_cache" , baseUrl , orgId )
19912012 req , err := http .NewRequest ("POST" , url , bytes .NewBuffer ([]byte (PAYLOAD )))
19922013 if err != nil {
19932014 log .Printf ("[ERROR] Failed to create request (%s) for set_cache %s" , url , err )
@@ -2006,14 +2027,12 @@ func RunOpsDatastore(baseUrl, apikey, orgId string) (DatastoreHealth, error) {
20062027 return datastoreHealth , err
20072028 }
20082029
2009- if resp .StatusCode != 200 {
2010- return datastoreHealth , errors .New ("Failed to create cache internal server error not 200 status code" )
2011- }
2030+ log .Printf ("Org-Id: %s" , orgId )
20122031
20132032 datastoreHealth .Create = true
20142033 //read datastore entry
2015- PAYLOAD = fmt .Sprint (`{"org_id": "%s", "key": "SHUFFLE_HEALTH_CHECK"}` , orgId )
2016- url = fmt .Sprint ("%s/api/v1/orgs/%s/get_cache" , baseUrl , orgId )
2034+ PAYLOAD = fmt .Sprintf (`{"org_id": "%s", "key": "SHUFFLE_HEALTH_CHECK"}` , orgId )
2035+ url = fmt .Sprintf ("%s/api/v1/orgs/%s/get_cache" , baseUrl , orgId )
20172036 req , err = http .NewRequest ("POST" , url , bytes .NewBuffer ([]byte (PAYLOAD )))
20182037 if err != nil {
20192038 log .Printf ("[ERROR] Failed to create request (%s) for get_cache: %s" , url , err )
@@ -2039,8 +2058,8 @@ func RunOpsDatastore(baseUrl, apikey, orgId string) (DatastoreHealth, error) {
20392058 datastoreHealth .Read = true
20402059
20412060 // Delete
2042- PAYLOAD = fmt .Sprint (`{"org_id": "%s", "key": "SHUFFLE_HEALTH_CHECK"}` , orgId )
2043- url = fmt .Sprint ("%s/api/v1/orgs/%s/delete_key " , baseUrl , orgId )
2061+ PAYLOAD = fmt .Sprintf (`{"org_id": "%s", "key": "SHUFFLE_HEALTH_CHECK"}` , orgId )
2062+ url = fmt .Sprintf ("%s/api/v1/orgs/%s/delete_cache " , baseUrl , orgId )
20442063 req , err = http .NewRequest ("POST" , url , bytes .NewBuffer ([]byte (PAYLOAD )))
20452064 if err != nil {
20462065 log .Printf ("[ERROR] Failed to create request (%s) for delete_key: %s" , url , err )
@@ -2094,6 +2113,7 @@ func RunFileHealthOps(baseUrl, apikey, orgId string) (FileHealth, error) {
20942113
20952114 fileHealth .Create = true
20962115 //Read metadata
2116+ //Delete file
20972117
20982118 return fileHealth , nil
20992119}
0 commit comments