Skip to content

Commit

Permalink
Merge branch 'main' into ml-package-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Dec 29, 2022
2 parents 6794796 + a9ac5ae commit b4d0bfd
Show file tree
Hide file tree
Showing 187 changed files with 4,780 additions and 1,195 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ elastic-agent.yml
fleet-server.yml
/packages/kbn-package-map/package-map.json
/packages/kbn-synthetic-package-map/
**/.synthetics/
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"@emotion/react": "^11.10.4",
"@emotion/serialize": "^1.1.0",
"@emotion/server": "^11.10.0",
"@emotion/styled": "^11.10.5",
"@grpc/grpc-js": "^1.6.7",
"@hapi/accept": "^5.0.2",
"@hapi/boom": "^9.1.4",
Expand Down Expand Up @@ -727,7 +728,7 @@
"@cypress/webpack-preprocessor": "^5.12.2",
"@elastic/eslint-plugin-eui": "0.0.2",
"@elastic/makelogs": "^6.1.1",
"@elastic/synthetics": "^1.0.0-beta.23",
"@elastic/synthetics": "^1.0.0-beta.39",
"@emotion/babel-preset-css-prop": "^11.10.0",
"@emotion/jest": "^11.10.0",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ export const SortableControl = (frameProps: SortableControlProps) => {
disabled: !isEditable,
});

frameProps.dragInfo = { ...frameProps.dragInfo, isOver: over?.id === embeddableId, isDragging };
const sortableFrameProps = {
...frameProps,
dragInfo: { ...frameProps.dragInfo, isOver: over?.id === embeddableId, isDragging },
};

return (
<SortableControlInner
key={embeddableId}
ref={setNodeRef}
{...frameProps}
{...sortableFrameProps}
{...attributes}
{...listeners}
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const IndexPatternTable = ({
<EuiButton
color="danger"
iconType="trash"
data-test-subj="delete-data-views-button"
onClick={() => clickHandler(selectedItems, deleteModalMsg(selectedItems, !!spaces))}
>
<FormattedMessage
Expand Down
137 changes: 71 additions & 66 deletions src/plugins/discover/public/application/main/discover_main_route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useEffect, useState, memo, useCallback, useMemo } from 'react';
import { useParams, useHistory } from 'react-router-dom';
import { DataViewListItem } from '@kbn/data-plugin/public';
import { isOfAggregateQueryType } from '@kbn/es-query';
import { DataViewSavedObjectConflictError } from '@kbn/data-views-plugin/public';
import { DataViewSavedObjectConflictError, type DataView } from '@kbn/data-views-plugin/public';
import { redirectWhenMissing } from '@kbn/kibana-utils-plugin/public';
import { useExecutionContext } from '@kbn/kibana-react-plugin/public';
import {
Expand Down Expand Up @@ -129,84 +129,89 @@ export function DiscoverMainRoute(props: Props) {
]
);

const loadSavedSearch = useCallback(async () => {
try {
const currentSavedSearch = await getSavedSearch(id, {
search: services.data.search,
savedObjectsClient: core.savedObjects.client,
spaces: services.spaces,
savedObjectsTagging: services.savedObjectsTagging,
});
const loadSavedSearch = useCallback(
async (nextDataView?: DataView) => {
try {
const currentSavedSearch = await getSavedSearch(id, {
search: services.data.search,
savedObjectsClient: core.savedObjects.client,
spaces: services.spaces,
savedObjectsTagging: services.savedObjectsTagging,
});

const currentDataView = await loadDefaultOrCurrentDataView(currentSavedSearch);
const currentDataView = nextDataView
? nextDataView
: await loadDefaultOrCurrentDataView(currentSavedSearch);

if (!currentDataView) {
return;
}
if (!currentDataView) {
return;
}

if (!currentSavedSearch.searchSource.getField('index')) {
currentSavedSearch.searchSource.setField('index', currentDataView);
}
if (!currentSavedSearch.searchSource.getField('index')) {
currentSavedSearch.searchSource.setField('index', currentDataView);
}

restoreStateFromSavedSearch({
savedSearch: currentSavedSearch,
timefilter: services.timefilter,
});
restoreStateFromSavedSearch({
savedSearch: currentSavedSearch,
timefilter: services.timefilter,
});

setSavedSearch(currentSavedSearch);
setSavedSearch(currentSavedSearch);

if (currentSavedSearch.id) {
chrome.recentlyAccessed.add(
getSavedSearchFullPathUrl(currentSavedSearch.id),
currentSavedSearch.title ?? '',
currentSavedSearch.id
);
}
} catch (e) {
if (e instanceof DataViewSavedObjectConflictError) {
setError(e);
} else {
redirectWhenMissing({
history,
navigateToApp: core.application.navigateToApp,
basePath,
mapping: {
search: '/',
'index-pattern': {
app: 'management',
path: `kibana/objects/savedSearches/${id}`,
if (currentSavedSearch.id) {
chrome.recentlyAccessed.add(
getSavedSearchFullPathUrl(currentSavedSearch.id),
currentSavedSearch.title ?? '',
currentSavedSearch.id
);
}
} catch (e) {
if (e instanceof DataViewSavedObjectConflictError) {
setError(e);
} else {
redirectWhenMissing({
history,
navigateToApp: core.application.navigateToApp,
basePath,
mapping: {
search: '/',
'index-pattern': {
app: 'management',
path: `kibana/objects/savedSearches/${id}`,
},
},
},
toastNotifications,
onBeforeRedirect() {
getUrlTracker().setTrackedUrl('/');
},
theme: core.theme,
})(e);
toastNotifications,
onBeforeRedirect() {
getUrlTracker().setTrackedUrl('/');
},
theme: core.theme,
})(e);
}
}
}
}, [
id,
services.data,
services.spaces,
services.timefilter,
services.savedObjectsTagging,
core.savedObjects.client,
core.application.navigateToApp,
core.theme,
loadDefaultOrCurrentDataView,
chrome.recentlyAccessed,
history,
basePath,
toastNotifications,
]);
},
[
id,
services.data,
services.spaces,
services.timefilter,
services.savedObjectsTagging,
core.savedObjects.client,
core.application.navigateToApp,
core.theme,
loadDefaultOrCurrentDataView,
chrome.recentlyAccessed,
history,
basePath,
toastNotifications,
]
);

const onDataViewCreated = useCallback(
async (nextDataView: unknown) => {
if (nextDataView) {
setShowNoDataPage(false);
setError(undefined);
await loadSavedSearch();
await loadSavedSearch(nextDataView as DataView);
}
},
[loadSavedSearch]
Expand Down Expand Up @@ -243,7 +248,7 @@ export function DiscoverMainRoute(props: Props) {

return (
<AnalyticsNoDataPageKibanaProvider {...analyticsServices}>
<AnalyticsNoDataPage onDataViewCreated={onDataViewCreated} />
<AnalyticsNoDataPage onDataViewCreated={onDataViewCreated} allowAdHocDataView />
</AnalyticsNoDataPageKibanaProvider>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
overviewRulerLanes: 0,
hideCursorInOverviewRuler: true,
scrollbar: {
vertical: 'hidden',
horizontal: 'hidden',
vertical: 'auto',
},
overviewRulerBorder: false,
readOnly: isDisabled,
Expand Down
65 changes: 65 additions & 0 deletions test/functional/apps/discover/group1/_greeting_screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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 expect from '@kbn/expect';

import { FtrProviderContext } from '../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const esArchiver = getService('esArchiver');
const security = getService('security');
const PageObjects = getPageObjects(['common', 'header', 'discover', 'timePicker']);
const defaultSettings = {
defaultIndex: 'logstash-*',
};

describe('discover greeting screen', function describeIndexTests() {
before(async function () {
await security.testUser.setRoles(['kibana_admin', 'version_test', 'test_logstash_reader']);
await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] });
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json');
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
await kibanaServer.uiSettings.replace(defaultSettings);
});

after(async () => {
await security.testUser.restoreDefaults();
});

it('should create adhoc data view when there are no data view', async () => {
await kibanaServer.uiSettings.replace(defaultSettings);
await PageObjects.common.navigateToApp('management');
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.click('dataViews');
await testSubjects.click('checkboxSelectAll');

await testSubjects.click('delete-data-views-button');
await testSubjects.click('confirmModalConfirmButton');

await PageObjects.common.navigateToApp('discover');
await PageObjects.header.waitUntilLoadingHasFinished();

await testSubjects.click('createDataViewButton');

await testSubjects.setValue('createIndexPatternTitleInput', 'logs', {
clearWithKeyboard: true,
typeCharByChar: true,
});
await retry.waitFor('timestamp field loaded', async () => {
const timestampField = await testSubjects.find('timestampField');
return !(await timestampField.elementHasClass('euiComboBox-isDisabled'));
});
await testSubjects.click('exploreIndexPatternButton');
await PageObjects.header.waitUntilLoadingHasFinished();
expect(await PageObjects.discover.isAdHocDataViewSelected()).to.be(true);
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/discover/group1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./_sidebar'));
loadTestFile(require.resolve('./_source_filters'));
loadTestFile(require.resolve('./_large_string'));
loadTestFile(require.resolve('./_greeting_screen'));
loadTestFile(require.resolve('./_inspector'));
loadTestFile(require.resolve('./_date_nanos'));
loadTestFile(require.resolve('./_date_nanos_mixed'));
Expand Down
6 changes: 6 additions & 0 deletions test/functional/page_objects/discover_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@ export class DiscoverPageObject extends FtrService {
}
}

public async isAdHocDataViewSelected() {
const dataView = await this.getCurrentlySelectedDataView();
await this.testSubjects.click('discover-dataView-switch-link');
return this.testSubjects.exists(`dataViewItemTempBadge-${dataView}`);
}

public async isFieldSelected(field: string) {
if (!(await this.testSubjects.exists('fieldListGroupedSelectedFields'))) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/fleet/server/services/agents/action_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getAgentActions } from './actions';
import { closePointInTime, getAgentsByKuery } from './crud';
import type { BulkActionsResolver } from './bulk_actions_resolver';

export const MAX_RETRY_COUNT = 3;
export const MAX_RETRY_COUNT = 5;

export interface ActionParams {
kuery: string;
Expand Down Expand Up @@ -113,10 +113,10 @@ export abstract class ActionRunner {
);

if (this.retryParams.retryCount === MAX_RETRY_COUNT) {
const errorMessage = `Stopping after ${MAX_RETRY_COUNT}rd retry. Error: ${error.message}`;
const errorMessage = `Stopping after retry #${MAX_RETRY_COUNT}. Error: ${error.message}`;
appContextService.getLogger().warn(errorMessage);

// clean up tasks after 3rd retry reached
// clean up tasks after last retry reached
await Promise.all([
this.bulkActionsResolver!.removeIfExists(this.checkTaskId!),
this.bulkActionsResolver!.removeIfExists(this.retryParams.taskId!),
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/server/services/agents/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export async function getAgentStatusForAgentPolicy(
},
});
} catch (error) {
logger.error(`Error getting agent statuses: ${error}`);
logger.warn(`Error getting agent statuses: ${error}`);
throw error;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ describe('update_agent_tags', () => {
tagsToRemove: [],
kuery: '',
total: 100,
retryCount: 3,
retryCount: 5,
}
)
).rejects.toThrowError('version conflict of 100 agents');
const errorResults = esClient.bulk.mock.calls[0][0] as any;
expect(errorResults.body[1].error).toEqual('version conflict on 3rd retry');
expect(errorResults.body[1].error).toEqual('version conflict on last retry');
});

it('should run add tags async when actioning more agents than batch size', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export async function updateTagsBatch(
getUuidArray(res.version_conflicts!).map((id) => ({
agentId: id,
actionId,
error: 'version conflict on 3rd retry',
error: 'version conflict on last retry',
}))
);
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/server/services/fleet_usage_logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function registerFleetUsageLogger(
} catch (error) {
appContextService
.getLogger()
.error('Error occurred while fetching fleet usage: ' + error);
.warn('Error occurred while fetching fleet usage: ' + error);
}
},

Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/observability/e2e/parse_args_params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const { argv } = yargs(process.argv.slice(2))
type: 'boolean',
description: 'Pause on error',
})
.option('watch', {
default: false,
type: 'boolean',
description: 'Runs the server in watch mode, restarting on changes',
})
.option('grep', {
default: undefined,
type: 'string',
Expand Down
Loading

0 comments on commit b4d0bfd

Please sign in to comment.