Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into telemetry/opt…
Browse files Browse the repository at this point in the history
…ional_to
  • Loading branch information
Bamieh committed Oct 27, 2020
2 parents edb5f1b + db0816f commit 2d4162f
Show file tree
Hide file tree
Showing 465 changed files with 6,067 additions and 2,513 deletions.
11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE/v8_breaking_change.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: 8.0 Breaking change
about: Breaking changes from 7.x -> 8.0
title: "[Breaking change]"
labels: Team:Elasticsearch UI, Feature:Upgrade Assistant
labels: Team:Elasticsearch UI, Feature:Upgrade Assistant, Breaking Change
assignees: ''

---
Expand All @@ -11,15 +11,16 @@ assignees: ''

**Which release will ship the breaking change?**

<!-- e.g., v7.6.2 -->
8.0

**Describe the change. How will it manifest to users?**

**What percentage of users will be affected?**
**How many users will be affected?**

<!-- e.g., Roughly 75% will need to make changes to x. -->
<!-- e.g., Based on telemetry data, roughly 75% of our users will need to make changes to x -->
<!-- e.g., A majority of users will need to make changes to x. -->

**What can users to do to address the change manually?**
**What can users do to address the change manually?**

<!-- If applicable, describe the manual workaround -->

Expand Down
40 changes: 37 additions & 3 deletions packages/kbn-apm-config-loader/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {

import { ApmConfiguration } from './config';

const initialEnv = { ...process.env };

describe('ApmConfiguration', () => {
beforeEach(() => {
packageMock.raw = {
Expand All @@ -39,6 +41,7 @@ describe('ApmConfiguration', () => {
});

afterEach(() => {
process.env = { ...initialEnv };
resetAllMocks();
});

Expand Down Expand Up @@ -90,13 +93,16 @@ describe('ApmConfiguration', () => {
let config = new ApmConfiguration(mockedRootDir, {}, false);
expect(config.getConfig('serviceName')).toEqual(
expect.objectContaining({
serverUrl: expect.any(String),
secretToken: expect.any(String),
breakdownMetrics: true,
})
);

config = new ApmConfiguration(mockedRootDir, {}, true);
expect(Object.keys(config.getConfig('serviceName'))).not.toContain('serverUrl');
expect(config.getConfig('serviceName')).toEqual(
expect.objectContaining({
breakdownMetrics: false,
})
);
});

it('loads the configuration from the kibana config file', () => {
Expand Down Expand Up @@ -156,4 +162,32 @@ describe('ApmConfiguration', () => {
})
);
});

it('correctly sets environment', () => {
delete process.env.ELASTIC_APM_ENVIRONMENT;
delete process.env.NODE_ENV;

let config = new ApmConfiguration(mockedRootDir, {}, false);
expect(config.getConfig('serviceName')).toEqual(
expect.objectContaining({
environment: 'development',
})
);

process.env.NODE_ENV = 'production';
config = new ApmConfiguration(mockedRootDir, {}, false);
expect(config.getConfig('serviceName')).toEqual(
expect.objectContaining({
environment: 'production',
})
);

process.env.ELASTIC_APM_ENVIRONMENT = 'ci';
config = new ApmConfiguration(mockedRootDir, {}, false);
expect(config.getConfig('serviceName')).toEqual(
expect.objectContaining({
environment: 'ci',
})
);
});
});
48 changes: 29 additions & 19 deletions packages/kbn-apm-config-loader/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,26 @@ import { readFileSync } from 'fs';
import { ApmAgentConfig } from './types';

const getDefaultConfig = (isDistributable: boolean): ApmAgentConfig => {
if (isDistributable) {
return {
active: false,
globalLabels: {},
// Do not use a centralized controlled config
centralConfig: false,
// Capture all exceptions that are not caught
logUncaughtExceptions: true,
// Can be performance intensive, disabling by default
breakdownMetrics: false,
};
}

// https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html
return {
active: false,
serverUrl: 'https://f1542b814f674090afd914960583265f.apm.us-central1.gcp.cloud.es.io:443',
active: process.env.ELASTIC_APM_ACTIVE || false,
environment: process.env.ELASTIC_APM_ENVIRONMENT || process.env.NODE_ENV || 'development',

serverUrl: 'https://b1e3b4b4233e44cdad468c127d0af8d8.apm.europe-west1.gcp.cloud.es.io:443',

// The secretToken below is intended to be hardcoded in this file even though
// it makes it public. This is not a security/privacy issue. Normally we'd
// instead disable the need for a secretToken in the APM Server config where
// the data is transmitted to, but due to how it's being hosted, it's easier,
// for now, to simply leave it in.
secretToken: 'R0Gjg46pE9K9wGestd',
secretToken: '2OyjjaI6RVkzx2O5CV',

logUncaughtExceptions: true,
globalLabels: {},
breakdownMetrics: true,
centralConfig: false,
logUncaughtExceptions: true,

// Can be performance intensive, disabling by default
breakdownMetrics: isDistributable ? false : true,
};
};

Expand Down Expand Up @@ -84,7 +78,8 @@ export class ApmConfiguration {
getDefaultConfig(this.isDistributable),
this.getConfigFromKibanaConfig(),
this.getDevConfig(),
this.getDistConfig()
this.getDistConfig(),
this.getCIConfig()
);

const rev = this.getGitRev();
Expand Down Expand Up @@ -146,6 +141,21 @@ export class ApmConfiguration {
};
}

private getCIConfig(): ApmAgentConfig {
if (process.env.ELASTIC_APM_ENVIRONMENT !== 'ci') {
return {};
}

return {
globalLabels: {
branch: process.env.ghprbSourceBranch || '',
targetBranch: process.env.ghprbTargetBranch || '',
ciJobName: process.env.JOB_NAME || '',
ciBuildNumber: process.env.BUILD_NUMBER || '',
},
};
}

private getGitRev() {
if (this.isDistributable) {
return this.pkgBuild.sha;
Expand Down
6 changes: 5 additions & 1 deletion packages/kbn-optimizer/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ run(
await lastValueFrom(update$.pipe(logOptimizerState(log, config)));

if (updateLimits) {
updateBundleLimits(log, config);
updateBundleLimits({
log,
config,
dropMissing: !(focus || filter),
});
}
},
{
Expand Down
12 changes: 10 additions & 2 deletions packages/kbn-optimizer/src/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,18 @@ export function validateLimitsForAllBundles(log: ToolingLog, config: OptimizerCo
log.success('limits.yml file valid');
}

export function updateBundleLimits(log: ToolingLog, config: OptimizerConfig) {
interface UpdateBundleLimitsOptions {
log: ToolingLog;
config: OptimizerConfig;
dropMissing: boolean;
}

export function updateBundleLimits({ log, config, dropMissing }: UpdateBundleLimitsOptions) {
const metrics = getMetrics(log, config);

const pageLoadAssetSize: NonNullable<Limits['pageLoadAssetSize']> = {};
const pageLoadAssetSize: NonNullable<Limits['pageLoadAssetSize']> = dropMissing
? {}
: config.limits.pageLoadAssetSize ?? {};

for (const metric of metrics.sort((a, b) => a.id.localeCompare(b.id))) {
if (metric.group === 'page load bundle size') {
Expand Down
36 changes: 3 additions & 33 deletions src/core/server/elasticsearch/client/client_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,28 +216,14 @@ describe('parseClientOptions', () => {
);
});

it('adds auth to the nodes if both `username` and `password` are set', () => {
let options = parseClientOptions(
it('does not add auth to the nodes', () => {
const options = parseClientOptions(
createConfig({
username: 'user',
hosts: ['http://node-A:9200'],
}),
false
);
expect(options.nodes).toMatchInlineSnapshot(`
Array [
Object {
"url": "http://node-a:9200/",
},
]
`);

options = parseClientOptions(
createConfig({
password: 'pass',
hosts: ['http://node-A:9200'],
}),
false
true
);
expect(options.nodes).toMatchInlineSnapshot(`
Array [
Expand All @@ -246,22 +232,6 @@ describe('parseClientOptions', () => {
},
]
`);

options = parseClientOptions(
createConfig({
username: 'user',
password: 'pass',
hosts: ['http://node-A:9200'],
}),
false
);
expect(options.nodes).toMatchInlineSnapshot(`
Array [
Object {
"url": "http://user:pass@node-a:9200/",
},
]
`);
});
});
describe('when `scoped` is true', () => {
Expand Down
12 changes: 2 additions & 10 deletions src/core/server/elasticsearch/client/client_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function parseClientOptions(
};
}

clientOptions.nodes = config.hosts.map((host) => convertHost(host, !scoped, config));
clientOptions.nodes = config.hosts.map((host) => convertHost(host));

if (config.ssl) {
clientOptions.ssl = generateSslConfig(
Expand Down Expand Up @@ -140,18 +140,10 @@ const generateSslConfig = (
return ssl;
};

const convertHost = (
host: string,
needAuth: boolean,
{ username, password }: ElasticsearchClientConfig
): NodeOptions => {
const convertHost = (host: string): NodeOptions => {
const url = new URL(host);
const isHTTPS = url.protocol === 'https:';
url.port = url.port || (isHTTPS ? '443' : '80');
if (needAuth && username && password) {
url.username = username;
url.password = password;
}

return {
url,
Expand Down
4 changes: 4 additions & 0 deletions src/dev/ci_setup/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export NODE_OPTIONS="$NODE_OPTIONS --max-old-space-size=4096"
###
export FORCE_COLOR=1

### APM tracking
###
export ELASTIC_APM_ENVIRONMENT=ci

###
### check that we seem to be in a kibana project
###
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import { SolutionPanel } from './solution_panel';
import { FeatureCatalogueEntry, FeatureCatalogueSolution } from '../../../';

const sortByOrder = (
{ order: orderA = 0 }: FeatureCatalogueSolution,
{ order: orderB = 0 }: FeatureCatalogueSolution
{ order: orderA = 0 }: FeatureCatalogueSolution | FeatureCatalogueEntry,
{ order: orderB = 0 }: FeatureCatalogueSolution | FeatureCatalogueEntry
) => orderA - orderB;

interface Props {
Expand All @@ -38,7 +38,9 @@ interface Props {
export const SolutionsSection: FC<Props> = ({ addBasePath, solutions, directories }) => {
// Separate Kibana from other solutions
const kibana = solutions.find(({ id }) => id === 'kibana');
const kibanaApps = directories.filter(({ solutionId }) => solutionId === 'kibana');
const kibanaApps = directories
.filter(({ solutionId }) => solutionId === 'kibana')
.sort(sortByOrder);
solutions = solutions.sort(sortByOrder).filter(({ id }) => id !== 'kibana');

return (
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana_overview/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class KibanaOverviewPlugin
defaultMessage: 'Search and find insights.',
}),
i18n.translate('kibanaOverview.kibana.appDescription3', {
defaultMessage: 'Design pixel-perfect reports.',
defaultMessage: 'Design pixel-perfect presentations.',
}),
i18n.translate('kibanaOverview.kibana.appDescription4', {
defaultMessage: 'Plot geographic data.',
Expand Down
12 changes: 10 additions & 2 deletions x-pack/plugins/actions/server/saved_objects/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ describe('7.10.0', () => {
test('add hasAuth config property for .email actions', () => {
const migration710 = getMigrations(encryptedSavedObjectsSetup)['7.10.0'];
const action = getMockDataForEmail({});
expect(migration710(action, context)).toMatchObject({
const migratedAction = migration710(action, context);
expect(migratedAction.attributes.config).toEqual({
hasAuth: true,
});
expect(migratedAction).toEqual({
...action,
attributes: {
...action.attributes,
Expand All @@ -38,7 +42,11 @@ describe('7.10.0', () => {
test('rename cases configuration object', () => {
const migration710 = getMigrations(encryptedSavedObjectsSetup)['7.10.0'];
const action = getMockData({});
expect(migration710(action, context)).toMatchObject({
const migratedAction = migration710(action, context);
expect(migratedAction.attributes.config).toEqual({
incidentConfiguration: { mapping: [] },
});
expect(migratedAction).toEqual({
...action,
attributes: {
...action.attributes,
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/actions/server/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ function renameCasesConfigurationObject(
const addHasAuthConfigurationObject = (
doc: SavedObjectUnsanitizedDoc<RawAction>
): SavedObjectUnsanitizedDoc<RawAction> => {
if (doc.attributes.actionTypeId !== '.email') {
return doc;
}
const hasAuth = !!doc.attributes.secrets.user || !!doc.attributes.secrets.password;
return {
...doc,
Expand Down
Loading

0 comments on commit 2d4162f

Please sign in to comment.