Skip to content

Commit

Permalink
Added ability to hard code health items to work around health endpoin…
Browse files Browse the repository at this point in the history
…t unavailability.
  • Loading branch information
anilnatha committed Sep 23, 2024
1 parent d42b354 commit 70e2299
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ VITE_UNITY_UI_VERSION=${npm_package_version}
VITE_ADMIN_EMAIL=ENV_UNITY_UI_ADMIN_EMAIL
VITE_WWW_DOMAIN=ENV_UNITY_UI_WWW_DOMAIN
VITE_BASE_PATH=ENV_UNITY_UI_BASE_PATH
VITE_PROJECT=ENV_UNITY_UI_PROJECT
VITE_VENUE=ENV_UNITY_UI_VENUE

# Auth
#VITE_AUTH_OAUTH_CLIENT_ID=ENV_UNITY_UI_AUTH_OAUTH_CLIENT_ID
Expand Down
2 changes: 2 additions & 0 deletions .env/.env.docker.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
ENV_UNITY_UI_ADMIN_EMAIL=REPLACE_WITH_ADMIN_EMAIL
ENV_UNITY_UI_WWW_DOMAIN=REPLACE_WITH_UNITY_DOMAIN_NAME
ENV_UNITY_UI_BASE_PATH=REPLACE_WITH_BASE_PATH
ENV_UNITY_UI_PROJECT=REPLACE_WITH_UNITY_PROJECT_NAME
ENV_UNITY_UI_VENUE=REPLACE_WITH_UNITY_VENUE_NAME

# Auth
#ENV_UNITY_UI_AUTH_OAUTH_CLIENT_ID=REPLACE_WITH_COGNITO_USER_POOL_CLIENT_ID
Expand Down
2 changes: 2 additions & 0 deletions src/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const Config = {
unity_admin_email: import.meta.env.VITE_ADMIN_EMAIL,
www_domain: import.meta.env.VITE_WWW_DOMAIN,
base_path: import.meta.env.VITE_BASE_PATH,
project: import.meta.env.VITE_PROJECT,
venue: import.meta.env.VITE_VENUE
},

['auth']: {
Expand Down
65 changes: 62 additions & 3 deletions src/state/slices/healthSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum HEALTH_ACTIONS {

type HealthCheck = {
status:string;
httpResponseCode:string;
date:string | number;
}

Expand All @@ -34,6 +35,64 @@ const initialState:HealthState = {
status: 'idle',
};

const getItems = () => {

// Get additional links that should be added for the given project and venue

const project = Config['general']['project'];
const venue = Config['general']['venue'];

let serviceItems:Service[] = Array<Service>();

if( project.toUpperCase() === 'EMIT' && venue.toUpperCase() === 'DEV' ) {

serviceItems = [
{
componentName: "Jupyterhub",
ssmKey: "",
healthCheckUrl: "",
landingPageUrl: "https://www.mdps.mcp.nasa.gov:4443/emit/dev/jupyter/",
healthChecks: [
{
status: "UNKNOWN",
httpResponseCode: "",
date: ""
}
]
},
{
componentName: "Airflow",
ssmKey: "",
healthCheckUrl: "",
landingPageUrl: "http://k8s-sps-airflowi-3b3c3cafcc-31473296.us-west-2.elb.amazonaws.com:5000/home",
healthChecks: [
{
status: "UNKNOWN",
httpResponseCode: "",
date: ""
}
]
},
{
componentName: "Airflow-ogc",
ssmKey: "",
healthCheckUrl: "",
landingPageUrl: "http://k8s-sps-ogcproce-927cdf8d63-717063809.us-west-2.elb.amazonaws.com:5001/",
healthChecks: [
{
status: "UNKNOWN",
httpResponseCode: "",
date: ""
}
]
},
];
}

return serviceItems;

}

/**
* Get all the instruments from the PDS OpenSearch API
*/
Expand All @@ -51,7 +110,6 @@ export const getHealthData = createAsyncThunk(
}
}


try {
const response = await axios.get(url, config);
return response.data.services;
Expand Down Expand Up @@ -80,14 +138,15 @@ const healthSlice = createSlice({

// Parse and store the fetched data into the state
const data = action.payload;
state.items = data;
state.items = data.concat(getItems());

});

builder.addCase(getHealthData.rejected, (state, action) => {
// When data is fetched unsuccessfully
state.status = "failed";


state.items = getItems();
// Update the error message for proper error handling
state.error = action.error.message;
});
Expand Down

0 comments on commit 70e2299

Please sign in to comment.