Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ingest/config-to-…
Browse files Browse the repository at this point in the history
…policy
  • Loading branch information
jen-huang committed Aug 19, 2020
2 parents 301a412 + b944dd3 commit 0cf533a
Show file tree
Hide file tree
Showing 284 changed files with 5,987 additions and 2,792 deletions.
2 changes: 1 addition & 1 deletion .ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NOTE: This Dockerfile is ONLY used to run certain tasks in CI. It is not used to run Kibana or as a distributable.
# If you're looking for the Kibana Docker image distributable, please see: src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.ts

ARG NODE_VERSION=10.21.0
ARG NODE_VERSION=10.22.0

FROM node:${NODE_VERSION} AS base

Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.21.0
10.22.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.21.0
10.22.0
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export interface SavedObjectsBulkCreateObject<T = unknown>
| [migrationVersion](./kibana-plugin-core-server.savedobjectsbulkcreateobject.migrationversion.md) | <code>SavedObjectsMigrationVersion</code> | Information about the migrations that have been applied to this SavedObject. When Kibana starts up, KibanaMigrator detects outdated documents and migrates them based on this value. For each migration that has been applied, the plugin's name is used as a key and the latest migration version as the value. |
| [references](./kibana-plugin-core-server.savedobjectsbulkcreateobject.references.md) | <code>SavedObjectReference[]</code> | |
| [type](./kibana-plugin-core-server.savedobjectsbulkcreateobject.type.md) | <code>string</code> | |
| [version](./kibana-plugin-core-server.savedobjectsbulkcreateobject.version.md) | <code>string</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsBulkCreateObject](./kibana-plugin-core-server.savedobjectsbulkcreateobject.md) &gt; [version](./kibana-plugin-core-server.savedobjectsbulkcreateobject.version.md)

## SavedObjectsBulkCreateObject.version property

<b>Signature:</b>

```typescript
version?: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions
| [overwrite](./kibana-plugin-core-server.savedobjectscreateoptions.overwrite.md) | <code>boolean</code> | Overwrite existing documents (defaults to false) |
| [references](./kibana-plugin-core-server.savedobjectscreateoptions.references.md) | <code>SavedObjectReference[]</code> | |
| [refresh](./kibana-plugin-core-server.savedobjectscreateoptions.refresh.md) | <code>MutatingOperationRefreshSetting</code> | The Elasticsearch Refresh setting for this operation |
| [version](./kibana-plugin-core-server.savedobjectscreateoptions.version.md) | <code>string</code> | An opaque version number which changes on each successful write operation. Can be used in conjunction with <code>overwrite</code> for implementing optimistic concurrency control. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsCreateOptions](./kibana-plugin-core-server.savedobjectscreateoptions.md) &gt; [version](./kibana-plugin-core-server.savedobjectscreateoptions.version.md)

## SavedObjectsCreateOptions.version property

An opaque version number which changes on each successful write operation. Can be used in conjunction with `overwrite` for implementing optimistic concurrency control.

<b>Signature:</b>

```typescript
version?: string;
```
2 changes: 1 addition & 1 deletion docs/settings/reporting-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ control the capturing process.
| Specify how long to allow the Reporting browser to wait for the "Loading..." screen
to dismiss and find the initial data for the Kibana page. If the time is
exceeded, a page screenshot is captured showing the current state, and the download link shows a warning message.
Defaults to `30000` (30 seconds).
Defaults to `60000` (1 minute).

| `xpack.reporting.capture.timeouts.waitForElements`
| Specify how long to allow the Reporting browser to wait for all visualization
Expand Down
8 changes: 2 additions & 6 deletions examples/search_examples/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import { NavigationPublicPluginStart } from '../../../../src/plugins/navigation/
import {
PLUGIN_ID,
PLUGIN_NAME,
IMyStrategyRequest,
IMyStrategyResponse,
SERVER_SEARCH_ROUTE_PATH,
} from '../../common';
Expand Down Expand Up @@ -134,12 +133,9 @@ export const SearchExamplesApp = ({
query,
},
},
};

if (strategy) {
// Add a custom request parameter to be consumed by `MyStrategy`.
(request as IMyStrategyRequest).get_cool = getCool;
}
...(strategy ? { get_cool: getCool } : {}),
};

// Submit the search request using the `data.search` service.
const searchSubscription$ = data.search
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@
"**/graphql-toolkit/lodash": "^4.17.15",
"**/hoist-non-react-statics": "^3.3.2",
"**/isomorphic-git/**/base64-js": "^1.2.1",
"**/istanbul-instrumenter-loader/schema-utils": "1.0.0",
"**/image-diff/gm/debug": "^2.6.9",
"**/load-grunt-config/lodash": "^4.17.20",
"**/react-dom": "^16.12.0",
"**/react": "^16.12.0",
"**/react-test-renderer": "^16.12.0",
"**/request": "^2.88.2",
"**/deepmerge": "^4.2.2",
"**/fast-deep-equal": "^3.1.1"
},
Expand Down Expand Up @@ -479,7 +481,7 @@
"zlib": "^1.0.5"
},
"engines": {
"node": "10.21.0",
"node": "10.22.0",
"yarn": "^1.21.1"
}
}
7 changes: 6 additions & 1 deletion src/core/server/saved_objects/import/import_saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
SavedObjectsImportOptions,
} from './types';
import { validateReferences } from './validate_references';
import { SavedObject } from '../types';

/**
* Import saved objects from given stream. See the {@link SavedObjectsImportOptions | options} for more
Expand Down Expand Up @@ -67,7 +68,7 @@ export async function importSavedObjectsFromStream({
}

// Create objects in bulk
const bulkCreateResult = await savedObjectsClient.bulkCreate(filteredObjects, {
const bulkCreateResult = await savedObjectsClient.bulkCreate(omitVersion(filteredObjects), {
overwrite,
namespace,
});
Expand All @@ -82,3 +83,7 @@ export async function importSavedObjectsFromStream({
...(errorAccumulator.length ? { errors: errorAccumulator } : {}),
};
}

export function omitVersion(objects: SavedObject[]): SavedObject[] {
return objects.map(({ version, ...object }) => object);
}
12 changes: 8 additions & 4 deletions src/core/server/saved_objects/import/resolve_import_errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
SavedObjectsResolveImportErrorsOptions,
} from './types';
import { validateReferences } from './validate_references';
import { omitVersion } from './import_saved_objects';

/**
* Resolve and return saved object import errors.
Expand Down Expand Up @@ -91,7 +92,7 @@ export async function resolveSavedObjectsImportErrors({
// Bulk create in two batches, overwrites and non-overwrites
const { objectsToOverwrite, objectsToNotOverwrite } = splitOverwrites(filteredObjects, retries);
if (objectsToOverwrite.length) {
const bulkCreateResult = await savedObjectsClient.bulkCreate(objectsToOverwrite, {
const bulkCreateResult = await savedObjectsClient.bulkCreate(omitVersion(objectsToOverwrite), {
overwrite: true,
namespace,
});
Expand All @@ -102,9 +103,12 @@ export async function resolveSavedObjectsImportErrors({
successCount += bulkCreateResult.saved_objects.filter((obj) => !obj.error).length;
}
if (objectsToNotOverwrite.length) {
const bulkCreateResult = await savedObjectsClient.bulkCreate(objectsToNotOverwrite, {
namespace,
});
const bulkCreateResult = await savedObjectsClient.bulkCreate(
omitVersion(objectsToNotOverwrite),
{
namespace,
}
);
errorAccumulator = [
...errorAccumulator,
...extractErrors(bulkCreateResult.saved_objects, objectsToNotOverwrite),
Expand Down
43 changes: 41 additions & 2 deletions src/core/server/saved_objects/service/lib/repository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,16 @@ describe('SavedObjectsRepository', () => {
{ method, _index = expect.any(String), getId = () => expect.any(String) }
) => {
const body = [];
for (const { type, id } of objects) {
body.push({ [method]: { _index, _id: getId(type, id) } });
for (const { type, id, if_primary_term: ifPrimaryTerm, if_seq_no: ifSeqNo } of objects) {
body.push({
[method]: {
_index,
_id: getId(type, id),
...(ifPrimaryTerm && ifSeqNo
? { if_primary_term: expect.any(Number), if_seq_no: expect.any(Number) }
: {}),
},
});
body.push(expect.any(Object));
}
expect(client.bulk).toHaveBeenCalledWith(
Expand Down Expand Up @@ -525,6 +533,27 @@ describe('SavedObjectsRepository', () => {
expectClientCallArgsAction([obj1, obj2], { method: 'index' });
});

it(`should use the ES index method with version if ID and version are defined and overwrite=true`, async () => {
await bulkCreateSuccess(
[
{
...obj1,
version: mockVersion,
},
obj2,
],
{ overwrite: true }
);

const obj1WithSeq = {
...obj1,
if_seq_no: mockVersionProps._seq_no,
if_primary_term: mockVersionProps._primary_term,
};

expectClientCallArgsAction([obj1WithSeq, obj2], { method: 'index' });
});

it(`should use the ES create method if ID is defined and overwrite=false`, async () => {
await bulkCreateSuccess([obj1, obj2]);
expectClientCallArgsAction([obj1, obj2], { method: 'create' });
Expand Down Expand Up @@ -1516,6 +1545,16 @@ describe('SavedObjectsRepository', () => {
expect(client.index).toHaveBeenCalled();
});

it(`should use the ES index with version if ID and version are defined and overwrite=true`, async () => {
await createSuccess(type, attributes, { id, overwrite: true, version: mockVersion });
expect(client.index).toHaveBeenCalled();

expect(client.index.mock.calls[0][0]).toMatchObject({
if_seq_no: mockVersionProps._seq_no,
if_primary_term: mockVersionProps._primary_term,
});
});

it(`should use the ES create action if ID is defined and overwrite=false`, async () => {
await createSuccess(type, attributes, { id });
expect(client.create).toHaveBeenCalled();
Expand Down
12 changes: 11 additions & 1 deletion src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export class SavedObjectsRepository {
overwrite = false,
references = [],
refresh = DEFAULT_REFRESH_SETTING,
version,
} = options;

if (!this._allowedTypes.includes(type)) {
Expand Down Expand Up @@ -259,6 +260,7 @@ export class SavedObjectsRepository {
index: this.getIndexForType(type),
refresh,
body: raw._source,
...(overwrite && version ? decodeRequestVersion(version) : {}),
};

const { body } =
Expand Down Expand Up @@ -345,7 +347,12 @@ export class SavedObjectsRepository {

let savedObjectNamespace;
let savedObjectNamespaces;
const { esRequestIndex, object, method } = expectedBulkGetResult.value;
let versionProperties;
const {
esRequestIndex,
object: { version, ...object },
method,
} = expectedBulkGetResult.value;
if (esRequestIndex !== undefined) {
const indexFound = bulkGetResponse?.statusCode !== 404;
const actualResult = indexFound ? bulkGetResponse?.body.docs[esRequestIndex] : undefined;
Expand All @@ -362,12 +369,14 @@ export class SavedObjectsRepository {
};
}
savedObjectNamespaces = getSavedObjectNamespaces(namespace, docFound && actualResult);
versionProperties = getExpectedVersionProperties(version, actualResult);
} else {
if (this._registry.isSingleNamespace(object.type)) {
savedObjectNamespace = namespace;
} else if (this._registry.isMultiNamespace(object.type)) {
savedObjectNamespaces = getSavedObjectNamespaces(namespace);
}
versionProperties = getExpectedVersionProperties(version);
}

const expectedResult = {
Expand All @@ -392,6 +401,7 @@ export class SavedObjectsRepository {
[method]: {
_id: expectedResult.rawMigratedDoc._id,
_index: this.getIndexForType(object.type),
...(overwrite && versionProperties),
},
},
expectedResult.rawMigratedDoc._source
Expand Down
6 changes: 6 additions & 0 deletions src/core/server/saved_objects/service/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions {
id?: string;
/** Overwrite existing documents (defaults to false) */
overwrite?: boolean;
/**
* An opaque version number which changes on each successful write operation.
* Can be used in conjunction with `overwrite` for implementing optimistic concurrency control.
**/
version?: string;
/** {@inheritDoc SavedObjectsMigrationVersion} */
migrationVersion?: SavedObjectsMigrationVersion;
references?: SavedObjectReference[];
Expand All @@ -52,6 +57,7 @@ export interface SavedObjectsBulkCreateObject<T = unknown> {
id?: string;
type: string;
attributes: T;
version?: string;
references?: SavedObjectReference[];
/** {@inheritDoc SavedObjectsMigrationVersion} */
migrationVersion?: SavedObjectsMigrationVersion;
Expand Down
3 changes: 3 additions & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,8 @@ export interface SavedObjectsBulkCreateObject<T = unknown> {
references?: SavedObjectReference[];
// (undocumented)
type: string;
// (undocumented)
version?: string;
}

// @public (undocumented)
Expand Down Expand Up @@ -2178,6 +2180,7 @@ export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions {
// (undocumented)
references?: SavedObjectReference[];
refresh?: MutatingOperationRefreshSetting;
version?: string;
}

// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ EXPOSE 5601
RUN for iter in {1..10}; do \
{{packageManager}} update --setopt=tsflags=nodocs -y && \
{{packageManager}} install --setopt=tsflags=nodocs -y \
fontconfig freetype shadow-utils {{#ubi}}findutils{{/ubi}} && \
fontconfig freetype shadow-utils libnss3.so {{#ubi}}findutils{{/ubi}} && \
{{packageManager}} clean all && exit_code=0 && break || exit_code=$? && echo "{{packageManager}} error: retry $iter in 10s" && \
sleep 10; \
done; \
Expand Down Expand Up @@ -119,4 +119,4 @@ LABEL name="Kibana" \

ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]

CMD ["/usr/local/bin/kibana-docker"]
CMD ["/usr/local/bin/kibana-docker"]
2 changes: 1 addition & 1 deletion src/dev/typescript/run_type_check_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function runTypeCheckCli() {
}

execInProjects(log, projects, process.execPath, (project) => [
...(project.name.startsWith('x-pack') ? ['--max-old-space-size=4096'] : []),
'--max-old-space-size=4096',
require.resolve('typescript/bin/tsc'),
...['--project', project.tsConfigPath],
...tscArgs,
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/data/common/search/es_search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SearchParams, SearchResponse } from 'elasticsearch';
import { SearchResponse } from 'elasticsearch';
import { Search } from '@elastic/elasticsearch/api/requestParams';
import { IKibanaSearchRequest, IKibanaSearchResponse } from '../types';

export const ES_SEARCH_STRATEGY = 'es';

export type ISearchRequestParams = {
trackTotalHits?: boolean;
} & SearchParams;
} & Search;

export interface IEsSearchRequest extends IKibanaSearchRequest {
params?: ISearchRequestParams;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import * as Rx from 'rxjs';
import { SavedObject } from 'src/core/server';
import { SavedObject as SavedObject_3 } from 'src/core/public';
import { SavedObjectsClientContract } from 'src/core/public';
import { SearchParams } from 'elasticsearch';
import { Search } from '@elastic/elasticsearch/api/requestParams';
import { SearchResponse as SearchResponse_2 } from 'elasticsearch';
import { SerializedFieldFormat as SerializedFieldFormat_2 } from 'src/plugins/expressions/common';
import { Subscription } from 'rxjs';
Expand Down
Loading

0 comments on commit 0cf533a

Please sign in to comment.