Skip to content

Commit

Permalink
Bug 1856354: Keep swagger definitions up to date
Browse files Browse the repository at this point in the history
Poll k8s openapi/v2 endpoint every 5 minutes and every time API discovery occurs to ensure swagger definitions stay up to date.
  • Loading branch information
TheRealJon committed Nov 3, 2020
1 parent 8bc402c commit 7afd907
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions frontend/public/actions/k8s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { k8sList, k8sWatch, k8sGet } from '../module/k8s/resource';
import { makeReduxID } from '../components/utils/k8s-watcher';
import { APIServiceModel } from '../models';
import { coFetchJSON } from '../co-fetch';
import { referenceForModel, K8sResourceKind, K8sKind } from '../module/k8s';
import { referenceForModel, K8sResourceKind, K8sKind, fetchSwagger } from '../module/k8s';

export enum ActionType {
ReceivedResources = 'resources',
Expand Down Expand Up @@ -65,7 +65,10 @@ export const getResources = () => (dispatch: Dispatch) => {
dispatch(receivedResources(resources));
})
// eslint-disable-next-line no-console
.catch((err) => console.error(err));
.catch((err) => console.error(err))
.finally(() => {
setTimeout(fetchSwagger, 10000);
});
};

export const filterList = (id: string, name: string, value: string) =>
Expand Down
4 changes: 3 additions & 1 deletion frontend/public/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ graphQLReady.onReady(() => {
// Global timer to ensure all <Timestamp> components update in sync
setInterval(() => store.dispatch(UIActions.updateTimestamps(Date.now())), 10000);

// Fetch swagger on load if it's stale.
// Fetch swagger definitions immediately upon application start
fetchSwagger();
// then poll swagger definitions every 5 minutes to ensure they stay up to date
setInterval(fetchSwagger, 5 * 60 * 1000);

// Used by GUI tests to check for unhandled exceptions
window.windowError = null;
Expand Down

0 comments on commit 7afd907

Please sign in to comment.