Skip to content

Commit

Permalink
Remove support for time-based interval index patterns but provide mig…
Browse files Browse the repository at this point in the history
…ration tooling
  • Loading branch information
lukasolson committed Apr 17, 2019
1 parent 4025d1d commit 36ef2ca
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 944 deletions.
Expand Up @@ -74,8 +74,19 @@
<div class="kuiInfoPanelBody">
<div class="kuiInfoPanelBody__message">
<span i18n-id="kbn.management.editIndexPattern.unsupportedTimePatternLabel"
i18n-default-message="Support for time-interval based index patterns has been removed! In the next major version of Kibana this index patterns will stop working. Migrate saved objects that use this index pattern to a wildcard pattern and delete this one."></span>
i18n-default-message="Support for time-interval based index patterns has been removed! In the next major version of Kibana these index patterns will stop working. Migrate this index pattern to a wildcard pattern by specifying the new pattern below."></span>
</div>
<form>
<input
class="form-control"
type="text"
ng-model="migration.newTitle"
/>
</form>
<button ng-disabled="migration.isMigrating" class="kuiButton kuiButton--primary kuiButton--iconText" ng-click="migrate()">
<span ng-if="migration.isMigrating" class="euiLoadingSpinner euiLoadingSpinner--medium" />
Migrate
</button>
</div>
</div>

Expand Down
Expand Up @@ -198,6 +198,16 @@ uiModules.get('apps/management')
updateScriptedFieldsTable($scope, $state);
});

$scope.migration = {
isMigrating: false,
newTitle: $scope.indexPattern.getIndex()
};
$scope.migrate = async function () {
$scope.migration.isMigrating = true;
await $scope.indexPattern.migrate($scope.migration.newTitle);
$scope.migration.isMigrating = false;
};

$scope.refreshFilters = function () {
const indexedFieldTypes = [];
const scriptedFieldLanguages = [];
Expand Down
11 changes: 0 additions & 11 deletions src/legacy/core_plugins/kibana/ui_setting_defaults.js
Expand Up @@ -600,17 +600,6 @@ export function getUiSettingDefaults() {
'patterns from which to query the field mapping',
}),
},
'indexPatterns:warnAboutUnsupportedTimePatterns': {
name: i18n.translate('kbn.advancedSettings.indexPattern.unsupportedTimePatternWarningTitle', {
defaultMessage: 'Time pattern warning',
}),
value: false,
description: i18n.translate('kbn.advancedSettings.indexPattern.unsupportedTimePatternWarningText', {
defaultMessage:
'When an index pattern is using the now unsupported "time pattern" format, a warning will ' +
'be displayed once per session that is using this pattern. Set this to false to disable that warning.',
}),
},
'format:defaultTypeMap': {
name: i18n.translate('kbn.advancedSettings.format.defaultTypeMapTitle', {
defaultMessage: 'Field type format name',
Expand Down

This file was deleted.

Expand Up @@ -17,84 +17,33 @@
* under the License.
*/

import _ from 'lodash';

function emptySearch() {
return {
query: {
bool: {
must_not: [
{ match_all: {} }
]
}
}
};
}

/**
*
* @param requestsFetchParams {Array.<Object>}
* @param Promise
* @param timeFilter - Only needed for time based interval indexes, which support has been removed from in 6.0. Come
* 7.0 we can completely rip this code out and break them completely. See
* https://github.com/elastic/kibana/issues/12242 and
* https://github.com/elastic/kibana/pull/12158 for more background
* @param kbnIndex
* @param sessionId
* @return {Promise.<string>}
*/
export function serializeFetchParams(
requestsFetchParams,
Promise,
timeFilter,
kbnIndex,
sessionId,
config,
esShardTimeout) {
const indexToListMapping = {};
const timeBounds = timeFilter.getActiveBounds();
const promises = requestsFetchParams.map(function (fetchParams) {
return Promise.resolve(fetchParams.index)
.then(function (indexList) {
if (!_.isFunction(_.get(indexList, 'toIndexList'))) {
return indexList;
}

if (!indexToListMapping[indexList.id]) {
indexToListMapping[indexList.id] = timeBounds
? indexList.toIndexList(timeBounds.min, timeBounds.max)
: indexList.toIndexList();
}
return indexToListMapping[indexList.id].then(indexList => {
// Make sure the index list in the cache can't be subsequently updated.
return _.clone(indexList);
});
})
.then(function (indexList) {
let body = {
.then(function (indexPattern) {
const body = {
...fetchParams.body || {},
};
if (esShardTimeout > 0) {
body.timeout = `${esShardTimeout}ms`;
}
let index = [];
// If we've reached this point and there are no indexes in the
// index list at all, it means that we shouldn't expect any indexes
// to contain the documents we're looking for, so we instead
// perform a request for an index pattern that we know will always
// return an empty result (ie. -*). If instead we had gone ahead
// with an msearch without any index patterns, elasticsearch would
// handle that request by querying *all* indexes, which is the
// opposite of what we want in this case.
if (Array.isArray(indexList) && indexList.length === 0) {
index.push(kbnIndex);
body = emptySearch();
} else {
index = indexList;
}

const header = {
index,
index: indexPattern.getIndex(),
type: fetchParams.type,
search_type: fetchParams.search_type,
ignore_unavailable: true,
Expand Down
Expand Up @@ -26,9 +26,6 @@ function serializeFetchParamsWithDefaults(paramOverrides) {
const paramDefaults = {
requestFetchParams: [],
Promise,
timeFilter: {
getActiveBounds: () => undefined,
},
kbnIndex: '.kibana',
sessionId: DEFAULT_SESSION_ID,
config: {
Expand All @@ -43,7 +40,6 @@ function serializeFetchParamsWithDefaults(paramOverrides) {
return serializeFetchParams(
params.requestFetchParams,
Promise,
params.timeFilter,
params.kbnIndex,
params.sessionId,
params.config,
Expand All @@ -67,34 +63,6 @@ describe('when indexList is not empty', () => {
});
});

describe('when indexList is empty', () => {
const emptyMustNotQuery = JSON.stringify({
query: {
bool: {
must_not: [
{ match_all: {} }
]
}
}
});

const requestFetchParams = [
{
index: [],
type: 'blah',
search_type: 'blah2',
body: { foo: 'bar', $foo: 'bar' }
}
];

test('queries the kibana index (.kibana) with a must_not match_all boolean', () => {
return serializeFetchParamsWithDefaults({ requestFetchParams }).then(value => {
expect(_.includes(value, '"index":[".kibana"]')).toBe(true);
expect(_.includes(value, emptyMustNotQuery)).toBe(true);
});
});
});

describe('headers', () => {

const requestFetchParams = [
Expand Down
Expand Up @@ -18,14 +18,12 @@
*/

import { serializeFetchParams } from './serialize_fetch_params';
import { timefilter } from 'ui/timefilter';

export function SerializeFetchParamsProvider(Promise, kbnIndex, sessionId, config, esShardTimeout) {
return (fetchParams) => (
serializeFetchParams(
fetchParams,
Promise,
timefilter,
kbnIndex,
sessionId,
config,
Expand Down
Expand Up @@ -111,7 +111,7 @@ function parseInitialFields(initialFields) {
}

function isIndexPattern(val) {
return Boolean(val && typeof val.toIndexList === 'function');
return Boolean(val && typeof val.getIndex === 'function');
}

export function SearchSourceProvider(Promise, Private, config) {
Expand Down

0 comments on commit 36ef2ca

Please sign in to comment.