Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[Data Usage] remove autoops.api.tls.ca config (#200808)" #201182

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/plugins/data_usage/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const configSchema = schema.object({
schema.object({
certificate: schema.maybe(schema.string()),
key: schema.maybe(schema.string()),
ca: schema.maybe(schema.string()),
})
),
})
Expand Down
21 changes: 6 additions & 15 deletions x-pack/plugins/data_usage/server/services/autoops_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,12 @@ export class AutoOpsAPIService {
throw new AutoOpsError(AUTO_OPS_MISSING_CONFIG_ERROR);
}

if (!autoopsConfig.api?.url) {
this.logger.error(`[AutoOps API] Missing API URL in the configuration.`, errorMetadata);
throw new AutoOpsError('Missing API URL in AutoOps configuration.');
}

if (!autoopsConfig.api?.tls?.certificate || !autoopsConfig.api?.tls?.key) {
this.logger.error(
`[AutoOps API] Missing required TLS certificate or key in the configuration.`,
errorMetadata
);
throw new AutoOpsError('Missing required TLS certificate or key in AutoOps configuration.');
}

this.logger.debug(
`[AutoOps API] Creating autoops agent with request URL: ${autoopsConfig.api.url} and TLS cert: [REDACTED] and TLS key: [REDACTED]`
`[AutoOps API] Creating autoops agent with TLS cert: ${
autoopsConfig?.api?.tls?.certificate ? '[REDACTED]' : 'undefined'
} and TLS key: ${autoopsConfig?.api?.tls?.key ? '[REDACTED]' : 'undefined'}
and TLS ca: ${autoopsConfig?.api?.tls?.ca ? '[REDACTED]' : 'undefined'}`
);

const controller = new AbortController();
const tlsConfig = this.createTlsConfig(autoopsConfig);
const cloudSetup = appContextService.getCloud();
Expand Down Expand Up @@ -180,6 +169,7 @@ export class AutoOpsAPIService {
enabled: true,
certificate: autoopsConfig?.api?.tls?.certificate,
key: autoopsConfig?.api?.tls?.key,
certificateAuthorities: autoopsConfig?.api?.tls?.ca,
})
);
}
Expand All @@ -197,6 +187,7 @@ export class AutoOpsAPIService {
...requestConfig.httpsAgent.options,
cert: requestConfig.httpsAgent.options.cert ? 'REDACTED' : undefined,
key: requestConfig.httpsAgent.options.key ? 'REDACTED' : undefined,
ca: requestConfig.httpsAgent.options.ca ? 'REDACTED' : undefined,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { CA_CERT_PATH, KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { createTestConfig } from '../../config.base';
import { services as apmServices } from './apm_api_integration/common/services';
import { services as datasetQualityServices } from './dataset_quality_api_integration/common/services';
Expand Down Expand Up @@ -32,5 +32,6 @@ export default createTestConfig({
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
`--xpack.dataUsage.autoops.api.tls.certificate=${KBN_CERT_PATH}`,
`--xpack.dataUsage.autoops.api.tls.key=${KBN_KEY_PATH}`,
`--xpack.dataUsage.autoops.api.tls.ca=${CA_CERT_PATH}`,
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { CA_CERT_PATH, KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { createTestConfig } from '../../config.base';

export default createTestConfig({
Expand All @@ -28,5 +28,6 @@ export default createTestConfig({
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
`--xpack.dataUsage.autoops.api.tls.certificate=${KBN_CERT_PATH}`,
`--xpack.dataUsage.autoops.api.tls.key=${KBN_KEY_PATH}`,
`--xpack.dataUsage.autoops.api.tls.ca=${CA_CERT_PATH}`,
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { CA_CERT_PATH, KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { createTestConfig } from '../../config.base';

export default createTestConfig({
Expand All @@ -32,5 +32,6 @@ export default createTestConfig({
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
`--xpack.dataUsage.autoops.api.tls.certificate=${KBN_CERT_PATH}`,
`--xpack.dataUsage.autoops.api.tls.key=${KBN_KEY_PATH}`,
`--xpack.dataUsage.autoops.api.tls.ca=${CA_CERT_PATH}`,
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { CA_CERT_PATH, KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { createTestConfig } from '../../config.base';

export default createTestConfig({
Expand All @@ -25,5 +25,6 @@ export default createTestConfig({
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
`--xpack.dataUsage.autoops.api.tls.certificate=${KBN_CERT_PATH}`,
`--xpack.dataUsage.autoops.api.tls.key=${KBN_KEY_PATH}`,
`--xpack.dataUsage.autoops.api.tls.ca=${CA_CERT_PATH}`,
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { CA_CERT_PATH, KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { createTestConfig } from '../../config.base';

export default createTestConfig({
Expand All @@ -28,6 +28,7 @@ export default createTestConfig({
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
`--xpack.dataUsage.autoops.api.tls.certificate=${KBN_CERT_PATH}`,
`--xpack.dataUsage.autoops.api.tls.key=${KBN_KEY_PATH}`,
`--xpack.dataUsage.autoops.api.tls.ca=${CA_CERT_PATH}`,
],
apps: {
serverlessElasticsearch: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { CA_CERT_PATH, KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
import { createTestConfig } from '../../config.base';

export default createTestConfig({
Expand All @@ -25,5 +25,6 @@ export default createTestConfig({
'--xpack.dataUsage.autoops.api.url=http://localhost:9000',
`--xpack.dataUsage.autoops.api.tls.certificate=${KBN_CERT_PATH}`,
`--xpack.dataUsage.autoops.api.tls.key=${KBN_KEY_PATH}`,
`--xpack.dataUsage.autoops.api.tls.ca=${CA_CERT_PATH}`,
],
});