From fe7c8ed67d64a33f9b0a214f0e8e9c21acdadb02 Mon Sep 17 00:00:00 2001 From: Anil Natha Date: Mon, 16 Sep 2024 11:11:19 -0700 Subject: [PATCH] Updated health dashboard endpoint configuration to use API GW instance of health API endpoint. Also fixed how cookies are read. --- public/data/health.json | 121 -------------------------------- src/AuthorizationWrapper.tsx | 20 ++++-- src/state/slices/healthSlice.ts | 6 +- 3 files changed, 19 insertions(+), 128 deletions(-) delete mode 100644 public/data/health.json diff --git a/public/data/health.json b/public/data/health.json deleted file mode 100644 index f4e5f67..0000000 --- a/public/data/health.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "services": [ - { - "componentName": "hargitay test fail", - "ssmKey": "/unity/shared-services/component/hargitay/test", - "healthCheckUrl": "https://www.google.com/account/about/fail", - "landingPageUrl": "https://www.google.com/account/about/", - "healthChecks": [ - { - "status": "UNHEALTHY", - "httpResponseCode": "404", - "date": "2024-07-26T07:29:20.755163" - } - ] - }, - { - "componentName": "hargitay test fail", - "ssmKey": "/unity/unity/dev/component/hargitay/fail", - "healthCheckUrl": "https://www.google.com/account/about/fail", - "landingPageUrl": "https://www.google.com/account/about/", - "healthChecks": [ - { - "status": "UNHEALTHY", - "httpResponseCode": "404", - "date": "2024-07-26T07:29:21.256424" - } - ] - }, - { - "componentName": "Airflow API", - "ssmKey": "/unity/unity/dev/component/luca/airflow-api", - "healthCheckUrl": "http://k8s-airflow-airflowi-c68f394a2a-1712638265.us-west-2.elb.amazonaws.com:5000/api/v1/health", - "landingPageUrl": "http://k8s-airflow-airflowi-c68f394a2a-1712638265.us-west-2.elb.amazonaws.com:5000/api/v1", - "healthChecks": [ - { - "status": "HEALTHY", - "httpResponseCode": "200", - "date": "2024-07-26T07:29:21.316116" - } - ] - }, - { - "componentName": "Airflow UI", - "ssmKey": "/unity/unity/dev/component/luca/airflow-ui", - "healthCheckUrl": "http://k8s-airflow-airflowi-c68f394a2a-1712638265.us-west-2.elb.amazonaws.com:5000/health", - "landingPageUrl": "http://k8s-airflow-airflowi-c68f394a2a-1712638265.us-west-2.elb.amazonaws.com:5000", - "healthChecks": [ - { - "status": "HEALTHY", - "httpResponseCode": "200", - "date": "2024-07-26T07:29:21.363497" - } - ] - }, - { - "componentName": "OGC API", - "ssmKey": "/unity/unity/dev/component/luca/ogc-api", - "healthCheckUrl": "http://k8s-airflow-ogcproce-e84448018d-906922971.us-west-2.elb.amazonaws.com:5001/health", - "landingPageUrl": "http://k8s-airflow-ogcproce-e84448018d-906922971.us-west-2.elb.amazonaws.com:5001", - "healthChecks": [ - { - "status": "HEALTHY", - "httpResponseCode": "200", - "date": "2024-07-26T07:29:21.395126" - } - ] - }, - { - "componentName": "Management Console", - "ssmKey": "/unity/unity/dev/component/management-console", - "healthCheckUrl": "http://unity-dev-httpd-alb-443241596.us-west-2.elb.amazonaws.com:8080/management/api/health_checks", - "landingPageUrl": "http://unity-dev-httpd-alb-443241596.us-west-2.elb.amazonaws.com:8080/management/ui", - "healthChecks": [ - { - "status": "UNHEALTHY", - "httpResponseCode": "404", - "date": "2024-07-26T07:29:21.417864" - } - ] - }, - { - "componentName": "Airflow API", - "ssmKey": "/unity/unity/dev/component/nikki/airflow-api", - "healthCheckUrl": "http://k8s-airflow-airflowi-c40bad68c9-606151489.us-west-2.elb.amazonaws.com:5000/api/v1/health", - "landingPageUrl": "http://k8s-airflow-airflowi-c40bad68c9-606151489.us-west-2.elb.amazonaws.com:5000/api/v1", - "healthChecks": [ - { - "status": "HEALTHY", - "httpResponseCode": "200", - "date": "2024-07-26T07:29:21.465918" - } - ] - }, - { - "componentName": "Airflow UI", - "ssmKey": "/unity/unity/dev/component/nikki/airflow-ui", - "healthCheckUrl": "http://k8s-airflow-airflowi-c40bad68c9-606151489.us-west-2.elb.amazonaws.com:5000/health", - "landingPageUrl": "http://k8s-airflow-airflowi-c40bad68c9-606151489.us-west-2.elb.amazonaws.com:5000", - "healthChecks": [ - { - "status": "HEALTHY", - "httpResponseCode": "200", - "date": "2024-07-26T07:29:21.509421" - } - ] - }, - { - "componentName": "OGC API", - "ssmKey": "/unity/unity/dev/component/nikki/ogc-api", - "healthCheckUrl": "http://k8s-airflow-ogcproce-5b03c67e8a-734530192.us-west-2.elb.amazonaws.com:5001/health", - "landingPageUrl": "http://k8s-airflow-ogcproce-5b03c67e8a-734530192.us-west-2.elb.amazonaws.com:5001", - "healthChecks": [ - { - "status": "HEALTHY", - "httpResponseCode": "200", - "date": "2024-07-26T07:29:21.535093" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/AuthorizationWrapper.tsx b/src/AuthorizationWrapper.tsx index 86219a0..5f90e8b 100644 --- a/src/AuthorizationWrapper.tsx +++ b/src/AuthorizationWrapper.tsx @@ -5,22 +5,30 @@ import App from './App'; import { useCookies } from 'react-cookie'; +let token:string; +let email:string; +let username:string; + export const GetUsername = () => { - const [cookies] = useCookies(['oidc_claim_username']); - return cookies['oidc_claim_username']; + return username; }; export const GetEmail = () => { - const [cookies] = useCookies(['oidc_claim_email']); - return cookies['oidc_claim_email']; + return email; }; export const GetToken = () => { - const [cookies] = useCookies(['oidc_access_token']); - return cookies['oidc_access_token']; + return token; }; const AuthorizationWrapper = () => { + + const [cookies] = useCookies(["oidc_access_token", "oidc_claim_username", "oidc_claim_email"]); + + token = cookies.oidc_access_token; + username = cookies.oidc_claim_username; + email = cookies.oidc_claim_email; + return ( diff --git a/src/state/slices/healthSlice.ts b/src/state/slices/healthSlice.ts index 6ec9480..180f666 100644 --- a/src/state/slices/healthSlice.ts +++ b/src/state/slices/healthSlice.ts @@ -1,6 +1,7 @@ import axios, { AxiosRequestConfig } from 'axios'; import { createSlice, createAsyncThunk } from "@reduxjs/toolkit"; import Config from "../../Config"; +import { GetToken } from '../../AuthorizationWrapper'; enum HEALTH_ACTIONS { GET_HEALTH = "health/getHealth", @@ -39,13 +40,16 @@ export const getHealthData = createAsyncThunk( async (_:void, thunkAPI) => { const url = Config['cs']['health_endpoint']; + const token = GetToken(); const config:AxiosRequestConfig = { headers: { - "Content-Type": "application/json" + "Content-Type": "application/json", + "Authorization": "Bearer " + token } } + try { const response = await axios.get(url, config); return response.data.services;