Skip to content

Commit

Permalink
[ML] Clear Kibana index pattern cache on creation or form reset. (#62184
Browse files Browse the repository at this point in the history
)

Clears the Kibana index pattern cache ...
- when reopening the "Create Analytics job" flyout
- after creating a transform or analyticsjob (this fixes moving from transforms to discover after creating a transform)
  • Loading branch information
walterra authored Apr 2, 2020
1 parent addb87d commit f747057
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ export const useCreateAnalyticsForm = (): CreateAnalyticsFormProps => {

const id = await newIndexPattern.create();

await mlContext.indexPatterns.clearCache();

// id returns false if there's a duplicate index pattern.
if (id === false) {
addRequestMessage({
Expand Down Expand Up @@ -248,6 +250,7 @@ export const useCreateAnalyticsForm = (): CreateAnalyticsFormProps => {
};

const openModal = async () => {
await mlContext.indexPatterns.clearCache();
resetForm();
await prepareFormValidation();
dispatch({ type: ACTION.OPEN_MODAL });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ async function createKibanaIndexPattern(

const id = await emptyPattern.create();

await indexPatterns.clearCache();

// check if there's a default index pattern, if not,
// set the newly created one as the default index pattern.
if (!kibanaConfig.get('defaultIndex')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ export const StepCreateForm: FC<Props> = React.memo(

const id = await newIndexPattern.create();

await indexPatterns.clearCache();

// id returns false if there's a duplicate index pattern.
if (id === false) {
toastNotifications.addDanger(
Expand Down

0 comments on commit f747057

Please sign in to comment.