Skip to content

Commit

Permalink
Merge branch 'reporting/api-test-unify' of github.com:tsullivan/kiban…
Browse files Browse the repository at this point in the history
…a into reporting/api-test-unify
  • Loading branch information
tsullivan committed May 18, 2020
2 parents 62ff1aa + 0539a76 commit ba21be6
Show file tree
Hide file tree
Showing 13 changed files with 450 additions and 57 deletions.
1 change: 1 addition & 0 deletions src/cli/cluster/run_kbn_optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function runKbnOptimizer(opts: Record<string, any>, config: LegacyConfig)
repoRoot: REPO_ROOT,
watch: true,
includeCoreBundle: true,
cache: !!opts.cache,
oss: !!opts.oss,
examples: !!opts.runExamples,
pluginPaths: config.get('plugins.paths'),
Expand Down
1 change: 1 addition & 0 deletions src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export default function(program) {
"Don't put a proxy in front of the dev server, which adds a random basePath"
)
.option('--no-watch', 'Prevents automatic restarts of the server in --dev mode')
.option('--no-cache', 'Disable the kbn/optimizer cache')
.option('--no-dev-config', 'Prevents loading the kibana.dev.yml file in --dev mode');
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/public/application/ui/app_container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export const AppContainer: FunctionComponent<Props> = ({
})) || null;
} catch (e) {
// TODO: add error UI
// eslint-disable-next-line no-console
console.error(e);
} finally {
setShowSpinner(false);
setIsMounting(false);
Expand Down
13 changes: 13 additions & 0 deletions x-pack/plugins/apm/common/agent_name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ export function isJavaAgentName(
): agentName is 'java' {
return agentName === 'java';
}

/**
* "Normalizes" and agent name by:
*
* * Converting to lowercase
* * Converting "rum-js" to "js-base"
*
* This helps dealing with some older agent versions
*/
export function getNormalizedAgentName(agentName?: string) {
const lowercased = agentName && agentName.toLowerCase();
return isRumAgentName(lowercased) ? 'js-base' : lowercased;
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ storiesOf('app/ServiceMap/Cytoscape', module)
'agent.name': 'dotnet'
}
},
{
data: {
id: 'dotNet',
'service.name': 'dotNet service',
'agent.name': 'dotNet'
}
},
{
data: {
id: 'go',
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import cytoscape from 'cytoscape';
import { isRumAgentName } from '../../../../common/agent_name';
import { getNormalizedAgentName } from '../../../../common/agent_name';
import {
AGENT_NAME,
SPAN_SUBTYPE,
Expand Down Expand Up @@ -87,8 +87,7 @@ const agentIcons: { [key: string]: string } = {
};

function getAgentIcon(agentName?: string) {
// RUM can have multiple names. Normalize it
const normalizedAgentName = isRumAgentName(agentName) ? 'js-base' : agentName;
const normalizedAgentName = getNormalizedAgentName(agentName);
return normalizedAgentName && agentIcons[normalizedAgentName];
}

Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/ingest_manager/server/routes/setup/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,22 @@ export const createFleetSetupHandler: RequestHandler<
export const ingestManagerSetupHandler: RequestHandler = async (context, request, response) => {
const soClient = context.core.savedObjects.client;
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
const logger = appContextService.getLogger();
try {
await setupIngestManager(soClient, callCluster);
return response.ok({
body: { isInitialized: true },
});
} catch (e) {
if (e.isBoom) {
logger.error(e.output.payload.message);
return response.customError({
statusCode: e.output.statusCode,
body: { message: e.output.payload.message },
});
}
logger.error(e.message);
logger.error(e.stack);
return response.customError({
statusCode: 500,
body: { message: e.message },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import Boom from 'boom';
import { Dataset, RegistryPackage, ElasticsearchAssetType, TemplateRef } from '../../../../types';
import { CallESAsCurrentUser } from '../../../../types';
import { Field, loadFieldsFromYaml, processFields } from '../../fields/field';
Expand All @@ -20,8 +21,8 @@ export const installTemplates = async (
// install any pre-built index template assets,
// atm, this is only the base package's global index templates
// Install component templates first, as they are used by the index templates
installPreBuiltComponentTemplates(pkgName, pkgVersion, callCluster);
installPreBuiltTemplates(pkgName, pkgVersion, callCluster);
await installPreBuiltComponentTemplates(pkgName, pkgVersion, callCluster);
await installPreBuiltTemplates(pkgName, pkgVersion, callCluster);

// build templates per dataset from yml files
const datasets = registryPackage.datasets;
Expand Down Expand Up @@ -53,16 +54,7 @@ const installPreBuiltTemplates = async (
pkgVersion,
(entry: Registry.ArchiveEntry) => isTemplate(entry)
);
// templatePaths.forEach(async path => {
// const { file } = Registry.pathParts(path);
// const templateName = file.substr(0, file.lastIndexOf('.'));
// const content = JSON.parse(Registry.getAsset(path).toString('utf8'));
// await callCluster('indices.putTemplate', {
// name: templateName,
// body: content,
// });
// });
templatePaths.forEach(async path => {
const templateInstallPromises = templatePaths.map(async path => {
const { file } = Registry.pathParts(path);
const templateName = file.substr(0, file.lastIndexOf('.'));
const content = JSON.parse(Registry.getAsset(path).toString('utf8'));
Expand Down Expand Up @@ -91,8 +83,15 @@ const installPreBuiltTemplates = async (
// The existing convenience endpoint `indices.putTemplate` only sends to _template,
// which does not support v2 templates.
// See src/core/server/elasticsearch/api_types.ts for available endpoints.
await callCluster('transport.request', callClusterParams);
return callCluster('transport.request', callClusterParams);
});
try {
return await Promise.all(templateInstallPromises);
} catch (e) {
throw new Boom(`Error installing prebuilt index templates ${e.message}`, {
statusCode: 400,
});
}
};

const installPreBuiltComponentTemplates = async (
Expand All @@ -105,7 +104,7 @@ const installPreBuiltComponentTemplates = async (
pkgVersion,
(entry: Registry.ArchiveEntry) => isComponentTemplate(entry)
);
templatePaths.forEach(async path => {
const templateInstallPromises = templatePaths.map(async path => {
const { file } = Registry.pathParts(path);
const templateName = file.substr(0, file.lastIndexOf('.'));
const content = JSON.parse(Registry.getAsset(path).toString('utf8'));
Expand All @@ -124,8 +123,15 @@ const installPreBuiltComponentTemplates = async (
// This uses the catch-all endpoint 'transport.request' because there is no
// convenience endpoint for component templates yet.
// See src/core/server/elasticsearch/api_types.ts for available endpoints.
await callCluster('transport.request', callClusterParams);
return callCluster('transport.request', callClusterParams);
});
try {
return await Promise.all(templateInstallPromises);
} catch (e) {
throw new Boom(`Error installing prebuilt component templates ${e.message}`, {
statusCode: 400,
});
}
};

const isTemplate = ({ path }: Registry.ArchiveEntry) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,13 @@ export async function ensureInstalledPackage(options: {
if (installedPackage) {
return installedPackage;
}
// if the requested packaged was not found to be installed, try installing
try {
await installLatestPackage({
savedObjectsClient,
pkgName,
callCluster,
});
return await getInstallation({ savedObjectsClient, pkgName });
} catch (err) {
throw new Error(err.message);
}
// if the requested packaged was not found to be installed, install
await installLatestPackage({
savedObjectsClient,
pkgName,
callCluster,
});
return await getInstallation({ savedObjectsClient, pkgName });
}

export async function installPackage(options: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function getResponse(url: string): Promise<Response> {
throw new Boom(response.statusText, { statusCode: response.status });
}
} catch (e) {
throw Boom.boomify(e);
throw new Boom(`Error connecting to package registry: ${e.message}`, { statusCode: 502 });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ export function postProcess(parsedFiles: any[]): void {
*/
function updateBlockParameters(docEntries: DocEntry[], block: Block, paramsGroup: string): void {
if (!block.local.parameter) {
block.local.parameter = {
fields: {},
};
block.local.parameter = {};
}
if (!block.local.parameter.fields) {
block.local.parameter.fields = {};
}

if (!block.local.parameter.fields![paramsGroup]) {
Expand Down
Loading

0 comments on commit ba21be6

Please sign in to comment.