Skip to content

Commit

Permalink
Merge branch 'main' into rollover-on-error
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Sep 26, 2023
2 parents 6e072a6 + 01a7841 commit cba97a5
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -893,9 +893,11 @@ to the `fields` option **were already present in the prior model version**. Othe
during upgrades, where newly introduced or backfilled fields may not necessarily appear in the documents returned
from the `search` API when the option is used.

### Using `update` with dynamically backfilled fields
### Using `bulkUpdate` with dynamically backfilled fields

The savedObjects `update` API is effectively a partial update (using Elasticsearch's `_update` under the hood),
(Note: this same limitation used to exist for the `update` method but has been [fixed](https://github.com/elastic/kibana/issues/165434). So while they're similar this limitation is only relevant for the `bulkUpdate` method)

The savedObjects `bulkUpdate` API is effectively a partial update (using Elasticsearch's `_update` under the hood),
allowing API consumers to only specify the subset of fields they want to update to new values, without having to
provide the full list of attributes (the unchanged ones). We're also not changing the `version` of the document
during updates, even when the instance performing the operation doesn't know about the current model version
Expand Down Expand Up @@ -935,8 +937,14 @@ const newDocAttributes = {
Which could occur either while being still in the cohabitation period, or in case of rollback:

```ts
savedObjectClient.update('type', 'id', {
index: 11,
savedObjectClient.bulkUpdate({
objects: [{
type: 'type',
id: 'id',
attributes: {
index: 11
}
}]
});
```

Expand All @@ -949,7 +957,7 @@ We will then be in a situation where our data is **inconsistent**, as the value
}
```

The long term solution for that is implementing [backward-compatible updates](https://github.com/elastic/kibana/issues/152807), however
The long term solution for that is implementing [backward-compatible updates](https://github.com/elastic/kibana/issues/165434), however
this won't be done for the MVP, so the workaround for now is to avoid situations where this edge case can occur.

It can be avoided by either:
Expand Down
3 changes: 2 additions & 1 deletion test/functional/apps/console/_autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ GET _search
for (const keyPress of keyPresses) {
await PageObjects.console.sleepForDebouncePeriod();
log.debug('Key', keyPress);
// @ts-ignore
await PageObjects.console[keyPress]();
expect(await PageObjects.console.isAutocompleteVisible()).to.be.eql(false);
}
Expand Down Expand Up @@ -257,7 +258,7 @@ GET _search
for (const char of [method.at(-1), ' ', '_']) {
await PageObjects.console.sleepForDebouncePeriod();
log.debug('Key type "%s"', char);
await PageObjects.console.enterText(char); // e.g. 'Post ' -> 'Post _'
await PageObjects.console.enterText(char ?? ''); // e.g. 'Post ' -> 'Post _'
}

await retry.waitFor('autocomplete to be visible', () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const security = getService('security');

const { dashboardControls, timePicker, common, dashboard } = getPageObjects([
const { dashboardControls, timePicker, dashboard } = getPageObjects([
'dashboardControls',
'timePicker',
'dashboard',
Expand Down
1 change: 0 additions & 1 deletion test/functional/apps/visualize/group2/_inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const inspector = getService('inspector');
const filterBar = getService('filterBar');
const monacoEditor = getService('monacoEditor');
const PageObjects = getPageObjects(['visualize', 'visEditor', 'visChart', 'timePicker']);

describe('inspector', function describeIndexTests() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function TemplateWithContext({
const {
path: { serviceName },
query,
query: { rangeFrom, rangeTo },
query: { rangeFrom, rangeTo, environment },
} = useApmParams('/services/{serviceName}/*');
const history = useHistory();
const location = useLocation();
Expand Down Expand Up @@ -140,6 +140,7 @@ function TemplateWithContext({
<EuiFlexItem grow={false}>
<ServiceIcons
serviceName={serviceName}
environment={environment}
start={start}
end={end}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function TemplateWithContext({
const {
path: { serviceName },
query,
query: { rangeFrom, rangeTo },
query: { rangeFrom, rangeTo, environment },
} = useApmParams('/mobile-services/{serviceName}/*');

const { start, end } = useTimeRange({ rangeFrom, rangeTo });
Expand Down Expand Up @@ -116,6 +116,7 @@ function TemplateWithContext({
<EuiFlexItem grow={false}>
<ServiceIcons
serviceName={serviceName}
environment={environment}
start={start}
end={end}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('ServiceIcons', () => {
<EuiThemeProvider>
<ServiceIcons
serviceName="foo"
environment="dev"
start="2021-08-20T10:00:00.000Z"
end="2021-08-20T10:15:00.000Z"
/>
Expand All @@ -87,6 +88,7 @@ describe('ServiceIcons', () => {
<EuiThemeProvider>
<ServiceIcons
serviceName="foo"
environment="dev"
start="2021-08-20T10:00:00.000Z"
end="2021-08-20T10:15:00.000Z"
/>
Expand All @@ -112,6 +114,7 @@ describe('ServiceIcons', () => {
<EuiThemeProvider>
<ServiceIcons
serviceName="foo"
environment="dev"
start="2021-08-20T10:00:00.000Z"
end="2021-08-20T10:15:00.000Z"
/>
Expand All @@ -138,6 +141,7 @@ describe('ServiceIcons', () => {
<EuiThemeProvider>
<ServiceIcons
serviceName="foo"
environment="dev"
start="2021-08-20T10:00:00.000Z"
end="2021-08-20T10:15:00.000Z"
/>
Expand Down Expand Up @@ -165,6 +169,7 @@ describe('ServiceIcons', () => {
<EuiThemeProvider>
<ServiceIcons
serviceName="foo"
environment="dev"
start="2021-08-20T10:00:00.000Z"
end="2021-08-20T10:15:00.000Z"
/>
Expand Down Expand Up @@ -212,6 +217,7 @@ describe('ServiceIcons', () => {
<EuiThemeProvider>
<ServiceIcons
serviceName="foo"
environment="dev"
start="2021-08-20T10:00:00.000Z"
end="2021-08-20T10:15:00.000Z"
/>
Expand Down Expand Up @@ -256,6 +262,7 @@ describe('ServiceIcons', () => {
<EuiThemeProvider>
<ServiceIcons
serviceName="foo"
environment="dev"
start="2021-08-20T10:00:00.000Z"
end="2021-08-20T10:15:00.000Z"
/>
Expand Down Expand Up @@ -308,6 +315,7 @@ describe('ServiceIcons', () => {
<EuiThemeProvider>
<ServiceIcons
serviceName="foo"
environment="dev"
start="2021-08-20T10:00:00.000Z"
end="2021-08-20T10:15:00.000Z"
/>
Expand Down Expand Up @@ -366,6 +374,7 @@ describe('ServiceIcons', () => {
<EuiThemeProvider>
<ServiceIcons
serviceName="foo"
environment="dev"
start="2021-08-20T10:00:00.000Z"
end="2021-08-20T10:15:00.000Z"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import openTelemetryIcon from '../agent_icon/icons/opentelemetry.svg';

interface Props {
serviceName: string;
environment: string;
start: string;
end: string;
}
Expand Down Expand Up @@ -92,7 +93,7 @@ export interface PopoverItem {
component: ReactChild;
}

export function ServiceIcons({ start, end, serviceName }: Props) {
export function ServiceIcons({ start, end, serviceName, environment }: Props) {
const [selectedIconPopover, setSelectedIconPopover] =
useState<Icons | null>();

Expand All @@ -117,20 +118,20 @@ export function ServiceIcons({ start, end, serviceName }: Props) {

const { data: details, status: detailsFetchStatus } = useFetcher(
(callApmApi) => {
if (selectedIconPopover && serviceName && start && end) {
if (selectedIconPopover && serviceName && start && end && environment) {
return callApmApi(
'GET /internal/apm/services/{serviceName}/metadata/details',
{
isCachable: true,
params: {
path: { serviceName },
query: { start, end },
query: { start, end, environment },
},
}
);
}
},
[selectedIconPopover, serviceName, start, end]
[selectedIconPopover, serviceName, start, end, environment]
);

const isLoading = !icons && iconsFetchStatus === FETCH_STATUS.LOADING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ServiceIconsReturnType =

interface Args {
serviceName: string;
environment: string;
start: string;
end: string;
icons: ServiceIconsReturnType;
Expand Down Expand Up @@ -64,7 +65,12 @@ const stories: Meta<Args> = {
};
export default stories;

export const Example: Story<Args> = ({ serviceName, start, end }) => {
export const Example: Story<Args> = ({
serviceName,
environment,
start,
end,
}) => {
return (
<EuiFlexGroup>
<EuiFlexItem>
Expand All @@ -83,6 +89,7 @@ export const Example: Story<Args> = ({ serviceName, start, end }) => {
<EuiFlexItem grow={false}>
<ServiceIcons
serviceName={serviceName}
environment={environment}
start={start}
end={end}
/>
Expand All @@ -98,6 +105,7 @@ export const Example: Story<Args> = ({ serviceName, start, end }) => {
};
Example.args = {
serviceName: 'opbeans-java',
environment: 'dev',
start: '2021-09-10T13:59:00.000Z',
end: '2021-09-10T14:14:04.789Z',
icons: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { rangeQuery } from '@kbn/observability-plugin/server';
import { ProcessorEvent } from '@kbn/observability-plugin/common';
import { environmentQuery } from '../../../common/utils/environment_query';
import {
AGENT,
CONTAINER,
Expand Down Expand Up @@ -86,17 +87,20 @@ export interface ServiceMetadataDetails {

export async function getServiceMetadataDetails({
serviceName,
environment,
apmEventClient,
start,
end,
}: {
serviceName: string;
environment: string;
apmEventClient: APMEventClient;
start: number;
end: number;
}): Promise<ServiceMetadataDetails> {
const filter = [
{ term: { [SERVICE_NAME]: serviceName } },
...environmentQuery(environment),
...rangeQuery(start, end),
];

Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/apm/server/routes/services/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,18 @@ const serviceMetadataDetailsRoute = createApmServerRoute({
endpoint: 'GET /internal/apm/services/{serviceName}/metadata/details',
params: t.type({
path: t.type({ serviceName: t.string }),
query: rangeRt,
query: t.intersection([rangeRt, environmentRt]),
}),
options: { tags: ['access:apm'] },
handler: async (resources): Promise<ServiceMetadataDetails> => {
const apmEventClient = await getApmEventClient(resources);
const { params } = resources;
const { serviceName } = params.path;
const { start, end } = params.query;
const { start, end, environment } = params.query;

const serviceMetadataDetails = await getServiceMetadataDetails({
serviceName,
environment,
apmEventClient,
start,
end,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/event_log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ prior releases, it was an alias with an initial index set up, with the
alias used to deal with rolled over indices from ILM. With the data stream,
there's a little less set up, and the bulk writing is slightly different.

The default data stream / alias name is `.kibana-event-log-${kibanaVersion}`.
The default data stream / alias name is `.kibana-event-log-ds`.
To search across all versions' event logs, use `.kibana-event-log-*`;
it will search over data streams and aliases as expected.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ beforeEach(() => {
clusterClientAdapter = new ClusterClientAdapter({
logger,
elasticsearchClientPromise: Promise.resolve(clusterClient),
esNames: getEsNames('kibana', '1.2.3'),
esNames: getEsNames('kibana'),
wait: () => Promise.resolve(true),
});
});
Expand All @@ -50,7 +50,7 @@ describe('indexDocument', () => {

expect(clusterClient.bulk).toHaveBeenCalledWith({
body: [{ create: {} }, { message: 'foo' }],
index: 'kibana-event-log-1.2.3',
index: 'kibana-event-log-ds',
});
});

Expand Down Expand Up @@ -103,7 +103,7 @@ describe('buffering documents', () => {

expect(clusterClient.bulk).toHaveBeenCalledWith({
body: expectedBody,
index: 'kibana-event-log-1.2.3',
index: 'kibana-event-log-ds',
});
});

Expand All @@ -124,12 +124,12 @@ describe('buffering documents', () => {

expect(clusterClient.bulk).toHaveBeenNthCalledWith(1, {
body: expectedBody,
index: 'kibana-event-log-1.2.3',
index: 'kibana-event-log-ds',
});

expect(clusterClient.bulk).toHaveBeenNthCalledWith(2, {
body: [{ create: {} }, { message: `foo 100` }],
index: 'kibana-event-log-1.2.3',
index: 'kibana-event-log-ds',
});
});

Expand Down Expand Up @@ -158,7 +158,7 @@ describe('buffering documents', () => {
}

expect(clusterClient.bulk).toHaveBeenNthCalledWith(i + 1, {
index: 'kibana-event-log-1.2.3',
index: 'kibana-event-log-ds',
body: expectedBody,
});
}
Expand Down
Loading

0 comments on commit cba97a5

Please sign in to comment.