Skip to content

Commit

Permalink
[Rename] missed es/ES references in project (#37) (#176)
Browse files Browse the repository at this point in the history
Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>
  • Loading branch information
boktorbb authored and mihirsoni committed Mar 20, 2021
1 parent bea181a commit ceafe62
Show file tree
Hide file tree
Showing 47 changed files with 340 additions and 611 deletions.
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**/*.js.snap
**/graphql/types.ts
/.es
/.opensearch
/.chromium
/build
/built_assets
Expand All @@ -18,7 +18,7 @@ target
# plugin overrides
/src/core/lib/osd_internal_native_observable
/src/legacy/plugin_discovery/plugin_pack/__tests__/fixtures/plugins/broken
/src/plugins/data/common/es_query/kuery/ast/_generated_/**
/src/plugins/data/common/opensearch_query/kuery/ast/_generated_/**
/src/plugins/vis_type_timelion/public/_generated_/**

# package overrides
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ module.exports = {
'packages/osd-ui-framework/doc_site/**/*.js',
'packages/osd-ui-framework/generator-kui/**/*.js',
'packages/osd-ui-framework/Gruntfile.js',
'packages/osd-es/src/**/*.js',
'packages/osd-opensearch/src/**/*.js',
'packages/osd-interpreter/tasks/**/*.js',
'packages/osd-interpreter/src/plugin/**/*.js',
'x-pack/{dev-tools,tasks,scripts,test,build_chromium}/**/*.js',
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.aws-config.json
.signing-config.json
.ackrc
/.es
/.opensearch
/.chromium
.DS_Store
.node_binaries
Expand Down
6 changes: 3 additions & 3 deletions packages/osd-monaco/src/xjson/lexer_rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
/* eslint-disable-next-line @osd/eslint/module_migration */
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
import * as xJson from './xjson';
import * as esql from './esql';
import * as opensearchql from './opensearchql';
import * as painless from './painless';

export const registerLexerRules = (m: typeof monaco) => {
m.languages.register({ id: xJson.ID });
m.languages.setMonarchTokensProvider(xJson.ID, xJson.lexerRules);
m.languages.register({ id: painless.ID });
m.languages.setMonarchTokensProvider(painless.ID, painless.lexerRules);
m.languages.register({ id: esql.ID });
m.languages.setMonarchTokensProvider(esql.ID, esql.lexerRules);
m.languages.register({ id: opensearchql.ID });
m.languages.setMonarchTokensProvider(opensearchql.ID, opensearchql.lexerRules);
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { monaco } from '../../monaco';

export const ID = 'esql';
export const ID = 'opensearchql';

const brackets = [
{ open: '[', close: ']', token: 'delimiter.square' },
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-monaco/src/xjson/lexer_rules/xjson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { monaco } from '../../monaco';
import { ID } from '../constants';
import './painless';
import './esql';
import './opensearchql';

import { globals } from './shared';

Expand Down Expand Up @@ -56,7 +56,7 @@ export const lexerRules: monaco.languages.IMonarchLanguage = {
'punctuation.start_triple_quote',
{
token: 'punctuation.start_triple_quote.lang_marker',
nextEmbedded: 'esql',
nextEmbedded: 'opensearchql',
next: 'my_sql',
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-opensearch-archiver/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/** ***********************************************************
*
* Run `node scripts/es_archiver --help` for usage information
* Run `node scripts/opensearch_archiver --help` for usage information
*
*************************************************************/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const recordsToBulkBody = (records: any[]) => {
}, [] as any[]);
};

describe('esArchiver: createIndexDocRecordsStream()', () => {
describe('opensearchArchiver: createIndexDocRecordsStream()', () => {
it('consumes doc records and sends to `_bulk` api', async () => {
const records = createPersonDocRecords(1);
const client = createStubClient([
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-opensearch-archiver/src/lib/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function createStats(name: string, log: ToolingLog) {
}

/**
* Record that the esArchiver waited for an index that was in the middle of being snapshotted
* Record that the opensearchArchiver waited for an index that was in the middle of being snapshotted
* @param index
*/
public waitingForInProgressSnapshot(index: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-opensearch/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ run(
});
},
{
description: 'Simple build tool for @osd/es package',
description: 'Simple build tool for @osd/opensearch package',
flags: {
boolean: ['watch', 'source-maps'],
help: `
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-opensearch/src/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ exports.Cluster = class Cluster {

options.opensearchEnvVars = options.opensearchEnvVars || {};

// ES now automatically sets heap size to 50% of the machine's available memory
// OpenSearch now automatically sets heap size to 50% of the machine's available memory
// so we need to set it to a smaller size for local dev and CI
// especially because we currently run many instances of OpenSearch on the same machine during CI
options.opensearchEnvVars.OPENSEARCH_JAVA_OPTS =
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-opensearch/src/install/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const { Artifact } = require('../artifact');
const { parseSettings, SettingsFilter } = require('../settings');

/**
* Extracts an ES archive and optionally installs plugins
* Extracts an OpenSearch archive and optionally installs plugins
*
* @param {String} archive - path to tar
* @param {Object} options
Expand All @@ -46,7 +46,7 @@ exports.installArchive = async function installArchive(archive, options = {}) {
installPath = path.resolve(basePath, path.basename(archive, '.tar.gz')),
log = defaultLog,
bundledJDK = false,
esArgs = [],
opensearchArgs = [],
} = options;

let dest = archive;
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-opensearch/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export enum SettingsFilter {
}

/**
* Accepts an array of `esSettingName=opensearchSettingValue` strings and parses them into an array of
* Accepts an array of `opensearchSettingName=opensearchSettingValue` strings and parses them into an array of
* [opensearchSettingName, opensearchSettingValue] tuples optionally filter out secure or non-secure settings.
* @param rawSettingNameValuePairs Array of strings to parse
* @param [filter] Optional settings filter.
Expand Down
6 changes: 3 additions & 3 deletions packages/osd-telemetry-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This command has no additional flags or arguments. The `.telemetryrc.json` files
### Output


The generated JSON files contain an ES mapping for each schema. This mapping is used to verify changes in the collectors and as the basis to map those fields into the external telemetry cluster.
The generated JSON files contain an OpenSearch mapping for each schema. This mapping is used to verify changes in the collectors and as the basis to map those fields into the external telemetry cluster.

**Example**:

Expand Down Expand Up @@ -67,9 +67,9 @@ We don't catch every possible misuse of the collectors, but only the most common

What will not be caught by the validator:

* Mistyped SavedObject/CallCluster return value. Since the hits returned from ES can be typed to anything without any checks. It is advised to add functional tests that grabs the schema json file and checks that the returned usage matches the types exactly.
* Mistyped SavedObject/CallCluster return value. Since the hits returned from OpenSearch can be typed to anything without any checks. It is advised to add functional tests that grabs the schema json file and checks that the returned usage matches the types exactly.

* Fields in the schema that are never collected. If you are trying to report a field from ES but that value is never stored in ES, the check will not be able to detect if that field is ever collected in the first palce. It is advised to add unit/functional tests to check that all the fields are being reported as expected.
* Fields in the schema that are never collected. If you are trying to report a field from OpenSearch but that value is never stored in OpenSearch, the check will not be able to detect if that field is ever collected in the first palce. It is advised to add unit/functional tests to check that all the fields are being reported as expected.

The tool looks for `.telemetryrc.json` files in the root of the project and in the `x-pack` dir for its runtime configurations.

Expand Down
4 changes: 2 additions & 2 deletions packages/osd-telemetry-tools/src/cli/run_telemetry_check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ export function runTelemetryCheck() {
{
enabled: (_) => fix,
skip: ({ roots }: TaskContext) => {
return roots.every(({ esMappingDiffs }) => !esMappingDiffs || !esMappingDiffs.length);
return roots.every(({ opensearchMappingDiffs }) => !opensearchMappingDiffs || !opensearchMappingDiffs.length);
},
title: 'Generating new telemetry mappings',
task: (context) => new Listr(generateSchemasTask(context), { exitOnError: true }),
},
{
enabled: (_) => fix,
skip: ({ roots }: TaskContext) => {
return roots.every(({ esMappingDiffs }) => !esMappingDiffs || !esMappingDiffs.length);
return roots.every(({ opensearchMappingDiffs }) => !opensearchMappingDiffs || !opensearchMappingDiffs.length);
},
title: 'Updating telemetry mapping files',
task: (context) => new Listr(writeToFileTask(context), { exitOnError: true }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import { kindToDescriptorName } from './serializer';

export function checkMatchingMapping(
UsageCollections: ParsedUsageCollection[],
esMapping: any
opensearchMapping: any
): any {
const generatedMapping = generateMapping(UsageCollections);
return difference(generatedMapping, esMapping);
return difference(generatedMapping, opensearchMapping);
}

interface IncompatibleDescriptor {
Expand Down Expand Up @@ -100,6 +100,6 @@ export function checkCompatibleTypeDescriptor(
return results.filter((entry): entry is IncompatibleDescriptor => entry !== false);
}

export function checkCollectorIntegrity(UsageCollections: ParsedUsageCollection[], esMapping: any) {
export function checkCollectorIntegrity(UsageCollections: ParsedUsageCollection[], opensearchMapping: any) {
return UsageCollections;
}
12 changes: 6 additions & 6 deletions packages/osd-telemetry-tools/src/tools/manage_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function isObjectMapping(entity: any) {
return true;
}

// 'type' is not set; ES defaults to object mapping for when type is unspecified.
// 'type' is not set; OpenSearch defaults to object mapping for when type is unspecified.
if (typeof entity.type === 'undefined') {
return true;
}
Expand All @@ -73,10 +73,10 @@ function isArrayMapping(entity: any): entity is { type: 'array'; items: object }
}

function getValueMapping(value: any) {
return isObjectMapping(value) ? transformToEsMapping(value) : value;
return isObjectMapping(value) ? transformToOpenSearchMapping(value) : value;
}

function transformToEsMapping(usageMappingValue: any) {
function transformToOpenSearchMapping(usageMappingValue: any) {
const fieldMapping: any = { properties: {} };
for (const [key, value] of Object.entries(usageMappingValue)) {
if (isArrayMapping(value)) {
Expand All @@ -89,12 +89,12 @@ function transformToEsMapping(usageMappingValue: any) {
}

export function generateMapping(usageCollections: ParsedUsageCollection[]) {
const esMapping: any = { properties: {} };
const opensearchMapping: any = { properties: {} };
for (const [, collecionDetails] of usageCollections) {
esMapping.properties[collecionDetails.collectorName] = transformToEsMapping(
opensearchMapping.properties[collecionDetails.collectorName] = transformToOpenSearchMapping(
collecionDetails.schema.value
);
}

return esMapping;
return opensearchMapping;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export function checkMatchingSchemasTask({ roots }: TaskContext, throwOnDiff: bo
return roots.map((root) => ({
task: async () => {
const fullPath = path.resolve(process.cwd(), root.config.output);
const esMappingString = await readFileAsync(fullPath, 'utf-8');
const esMapping = JSON.parse(esMappingString);
const opensearchMappingString = await readFileAsync(fullPath, 'utf-8');
const opensearchMapping = JSON.parse(opensearchMappingString);

if (root.parsedCollections) {
const differences = checkMatchingMapping(root.parsedCollections, esMapping);
root.esMappingDiffs = Object.keys(differences);
if (root.esMappingDiffs.length && throwOnDiff) {
const differences = checkMatchingMapping(root.parsedCollections, opensearchMapping);
root.opensearchMappingDiffs = Object.keys(differences);
if (root.opensearchMappingDiffs.length && throwOnDiff) {
throw Error(
`The following changes must be persisted in ${fullPath} file. Use '--fix' to update.\n${JSON.stringify(
differences,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface TelemetryRoot {
config: TelemetryRC;
parsedCollections?: ParsedUsageCollection[];
mapping?: any;
esMappingDiffs?: string[];
opensearchMappingDiffs?: string[];
}

export interface TaskContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const schema = Joi.object()
// settings for the opensearchArchiver module
opensearchArchiver: Joi.object()
.keys({
directory: Joi.string().default(defaultRelativeToConfigPath('fixtures/es_archiver')),
directory: Joi.string().default(defaultRelativeToConfigPath('fixtures/opensearch_archiver')),
})
.default(),

Expand Down
6 changes: 3 additions & 3 deletions rfcs/text/0008_pulse.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ This is the service that will receive and store the telemetry from all the _opte
- Most likely maintained by the Infra team.
- GCP is contemplated at this moment, but we need to confirm how would it affect us regarding the FedRamp approvals (and similar).
- Exposes an API (check [Endpoints](#endpoints) to know more) to inject the data and retrieve the _instructions_.
- The data will be stored in an ES cluster.
- The data will be stored in an OpenSearch cluster.

#### Endpoints

Expand All @@ -150,7 +150,7 @@ This Endpoint will be used to retrieve a randomised `deploymentID` and a `token`

I'd appreciate some insights here to come up with a strong handshake mechanism to avoid stealing identities.

In order to _dereference_ the data, we can store these mappings in a Vault or Secrets provider instead of an index in our ES.
In order to _dereference_ the data, we can store these mappings in a Vault or Secrets provider instead of an index in our OpenSearch.

_NB: Not for phase 1_

Expand All @@ -162,7 +162,7 @@ Similar to the current telemetry, we want to keep track of when the user opts in

In order to minimise the amount of requests, this `POST` should accept bulks of data in the payload (mind the payload size limits if any). It will require authentication based on the `deploymentID` and `token` explained in the [previous endpoint](#authenticate) (_NB: Not for phase 1_).

The received payload will be pushed to a streaming technology (AWS Firehose, Google Pub/Sub, ...). This way we can maintain a buffer in cases the ingestion of data spikes or we need to stop our ES cluster for any maintenance purposes.
The received payload will be pushed to a streaming technology (AWS Firehose, Google Pub/Sub, ...). This way we can maintain a buffer in cases the ingestion of data spikes or we need to stop our OpenSearch cluster for any maintenance purposes.

A subscriber to that stream will receive that info a split the payload into smaller documents per channel and index them into their separate indices.

Expand Down
2 changes: 1 addition & 1 deletion src/core/public/fatal_errors/get_error_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function formatErrorMessage(error: any): string {
return inspect(error);
}

// handle es error response with `root_cause`s
// handle opensearch error response with `root_cause`s
if (error.resp && error.resp.error && error.resp.error.root_cause) {
return error.resp.error.root_cause.map((cause: { reason: string }) => cause.reason).join('\n');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ describe('http service', () => {
expect(header['www-authenticate']).toEqual('content');
});

it('uses a default value for `www-authenticate` header when ES 401 does not specify it', async () => {
it('uses a default value for `www-authenticate` header when OpenSearch 401 does not specify it', async () => {
const { http } = await root.setup();
const { createRouter } = http;
// eslint-disable-next-line prefer-const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('savedObjectsClient/decorateOpenSearchError', () => {
});

describe('when opensearch.BadRequest has a reason', () => {
it('makes a SavedObjectsClient/esCannotExecuteScriptError error when script context is disabled', () => {
it('makes a SavedObjectsClient/opensearchCannotExecuteScriptError error when script context is disabled', () => {
const error = new opensearchErrors.ResponseError(
opensearchClientMock.createApiResponse({
statusCode: 400,
Expand All @@ -147,7 +147,7 @@ describe('savedObjectsClient/decorateOpenSearchError', () => {
expect(SavedObjectsErrorHelpers.isBadRequestError(error)).toBe(false);
});

it('makes a SavedObjectsClient/esCannotExecuteScriptError error when inline scripts are disabled', () => {
it('makes a SavedObjectsClient/opensearchCannotExecuteScriptError error when inline scripts are disabled', () => {
const error = new opensearchErrors.ResponseError(
opensearchClientMock.createApiResponse({
statusCode: 400,
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/service/lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const CODE_CONFLICT = 'SavedObjectsClient/conflict';
// 429 - Too Many Requests
const CODE_TOO_MANY_REQUESTS = 'SavedObjectsClient/tooManyRequests';
// 400 - OpenSearch Cannot Execute Script
const CODE_OPENSEARCH_CANNOT_EXECUTE_SCRIPT = 'SavedObjectsClient/esCannotExecuteScript';
const CODE_OPENSEARCH_CANNOT_EXECUTE_SCRIPT = 'SavedObjectsClient/opensearchCannotExecuteScript';
// 503 - OpenSearch Unavailable
const CODE_OPENSEARCH_UNAVAILABLE = 'SavedObjectsClient/esUnavailable';
const CODE_OPENSEARCH_UNAVAILABLE = 'SavedObjectsClient/opensearchUnavailable';
// 500 - General Error
const CODE_GENERAL_ERROR = 'SavedObjectsClient/generalError';

Expand Down
16 changes: 8 additions & 8 deletions src/plugins/dashboard/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ interface FieldSubType {
export interface Field {
name: string;
type: string;
// esTypes might be undefined on old index patterns that have not been refreshed since we added
// opensearchTypes might be undefined on old index patterns that have not been refreshed since we added
// this prop. It is also undefined on scripted fields.
esTypes?: string[];
opensearchTypes?: string[];
aggregatable: boolean;
filterable: boolean;
searchable: boolean;
Expand Down Expand Up @@ -109,15 +109,15 @@ export interface DashboardAppStateTransitions {
set: (
state: DashboardAppState
) => <T extends keyof DashboardAppState>(
prop: T,
value: DashboardAppState[T]
) => DashboardAppState;
prop: T,
value: DashboardAppState[T]
) => DashboardAppState;
setOption: (
state: DashboardAppState
) => <T extends keyof DashboardAppState['options']>(
prop: T,
value: DashboardAppState['options'][T]
) => DashboardAppState;
prop: T,
value: DashboardAppState['options'][T]
) => DashboardAppState;
}

export interface SavedDashboardPanelMap {
Expand Down
Loading

0 comments on commit ceafe62

Please sign in to comment.