X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fhealth%2Fhealth.go;h=3046559c366a8728a39c51b20606f9960252bd63;hb=cd908f5dddeac538eb33e8344bb53e50f6b2b6af;hp=d007da443955a02720722fc1ec4448e1b542eb88;hpb=cd6cc6ad28c32ccce6a2833917f7408a798e45fc;p=ric-plt%2Fricdms.git diff --git a/pkg/health/health.go b/pkg/health/health.go index d007da4..3046559 100644 --- a/pkg/health/health.go +++ b/pkg/health/health.go @@ -20,7 +20,13 @@ package health -import "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/models" +import ( + "fmt" + "net/http" + + "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/models" + "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/ricdms" +) var ( HEALTHY = "Service is running healthy" @@ -28,6 +34,7 @@ var ( type IHealthChecker interface { GetStatus() *models.Status + GetxAppStatus(appName, namespace string) *models.Status } type HealthChecker struct { @@ -41,3 +48,20 @@ func (h *HealthChecker) GetStatus() *models.Status { Status: &HEALTHY, } } + +func (h *HealthChecker) GetxAppStatus(appName, namespace string) *models.Status { + resp, err := http.Get(fmt.Sprintf(ricdms.Config.GETxAPPHealthURL, appName, namespace)) + if err != nil { + ricdms.Logger.Error("Received error while fetching health info: %v", err) + return nil + } + + if resp.StatusCode != http.StatusOK { + ricdms.Logger.Error("xApp is not healthy (http status=%s)", resp.Status) + return nil + } + + return &models.Status{ + Status: &HEALTHY, + } +}