Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for time-based interval index patterns with migration #35262

Merged
merged 10 commits into from May 2, 2019
Expand Up @@ -74,8 +74,20 @@
<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 || !migration.newTitle.trim()" class="kuiButton kuiButton--primary kuiButton--iconText" ng-click="migrate()">
<span ng-if="migration.isMigrating" class="euiLoadingSpinner euiLoadingSpinner--medium" />
<span i18n-id="kbn.management.editIndexPattern.migrate"
i18n-default-message="Migrate"></span>
</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,81 +17,30 @@
* 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 index = (indexPattern && indexPattern.getIndex) ? indexPattern.getIndex() : indexPattern;

const header = {
index,
Expand Down
Expand Up @@ -26,10 +26,6 @@ function serializeFetchParamsWithDefaults(paramOverrides) {
const paramDefaults = {
requestFetchParams: [],
Promise,
timeFilter: {
getActiveBounds: () => undefined,
},
kbnIndex: '.kibana',
sessionId: DEFAULT_SESSION_ID,
config: {
get: () => {
Expand All @@ -43,8 +39,6 @@ function serializeFetchParamsWithDefaults(paramOverrides) {
return serializeFetchParams(
params.requestFetchParams,
Promise,
params.timeFilter,
params.kbnIndex,
params.sessionId,
params.config,
params.timeout,
Expand All @@ -67,34 +61,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,15 +18,12 @@
*/

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

export function SerializeFetchParamsProvider(Promise, kbnIndex, sessionId, config, esShardTimeout) {
export function SerializeFetchParamsProvider(Promise, sessionId, config, esShardTimeout) {
return (fetchParams) => (
serializeFetchParams(
fetchParams,
Promise,
timefilter,
kbnIndex,
sessionId,
config,
esShardTimeout)
Expand Down
Expand Up @@ -110,7 +110,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