-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7395fee
commit a4ca9dc
Showing
7 changed files
with
287 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/core/server/saved_objects/migrationsv2/actions/es_errors.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { isIncompatibleMappingException, isWriteBlockException } from './es_errors'; | ||
|
||
describe('isWriteBlockError', () => { | ||
it('returns true for a `index write` cluster_block_exception', () => { | ||
expect( | ||
isWriteBlockException({ | ||
type: 'cluster_block_exception', | ||
reason: `index [.kibana_dolly] blocked by: [FORBIDDEN/8/index write (api)]`, | ||
}) | ||
).toEqual(true); | ||
}); | ||
it('returns true for a `moving to block index write` cluster_block_exception', () => { | ||
expect( | ||
isWriteBlockException({ | ||
type: 'cluster_block_exception', | ||
reason: `index [.kibana_dolly] blocked by: [FORBIDDEN/8/moving to block index write (api)]`, | ||
}) | ||
).toEqual(true); | ||
}); | ||
it('returns false for incorrect type', () => { | ||
expect( | ||
isWriteBlockException({ | ||
type: 'not_a_cluster_block_exception_at_all', | ||
reason: `index [.kibana_dolly] blocked by: [FORBIDDEN/8/index write (api)]`, | ||
}) | ||
).toEqual(false); | ||
}); | ||
}); | ||
|
||
describe('isIncompatibleMappingExceptionError', () => { | ||
it('returns true for `strict_dynamic_mapping_exception` errors', () => { | ||
expect( | ||
isIncompatibleMappingException({ | ||
type: 'strict_dynamic_mapping_exception', | ||
reason: 'idk', | ||
}) | ||
).toEqual(true); | ||
}); | ||
|
||
it('returns true for `mapper_parsing_exception` errors', () => { | ||
expect( | ||
isIncompatibleMappingException({ | ||
type: 'mapper_parsing_exception', | ||
reason: 'idk', | ||
}) | ||
).toEqual(true); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
src/core/server/saved_objects/migrationsv2/actions/es_errors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export interface EsErrorCause { | ||
type: string; | ||
reason: string; | ||
} | ||
|
||
export const isWriteBlockException = ({ type, reason }: EsErrorCause): boolean => { | ||
return ( | ||
type === 'cluster_block_exception' && | ||
reason.match(/index \[.+] blocked by: \[FORBIDDEN\/8\/.+ \(api\)\]/) !== null | ||
); | ||
}; | ||
|
||
export const isIncompatibleMappingException = ({ type }: EsErrorCause): boolean => { | ||
return type === 'strict_dynamic_mapping_exception' || type === 'mapper_parsing_exception'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.