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

[Synthetics] add migration to supported monitor schedules and remove deprecated zip url fields #154010

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fdecad9
add migration to remove zip url
dominiqueclarke Mar 29, 2023
ab867a9
merge upstream
dominiqueclarke Mar 30, 2023
1205c6e
adjust tests
dominiqueclarke Mar 30, 2023
ae1aa8e
adjust tests
dominiqueclarke Mar 30, 2023
373aeed
fix test
dominiqueclarke Mar 30, 2023
054a618
Merge branch 'main' of github.com:elastic/kibana into feat/synthetics…
dominiqueclarke Mar 30, 2023
77818b4
adjust tests
dominiqueclarke Mar 30, 2023
3542b6a
adjust tests
dominiqueclarke Mar 30, 2023
febd0c7
add schedule migration
dominiqueclarke Mar 30, 2023
3362f20
adjust tests
dominiqueclarke Mar 31, 2023
1bdf2e4
add more tests
dominiqueclarke Mar 31, 2023
1314183
adjust types
dominiqueclarke Apr 3, 2023
db8dca1
adjust snapshot test
dominiqueclarke Apr 3, 2023
33745b7
adjust types
dominiqueclarke Apr 3, 2023
7818de9
add validation for invalid monitor schedules
dominiqueclarke Apr 3, 2023
c68be93
Merge branch 'main' into feat/synthetics-saved-object-migration-8.8.0
kibanamachine Apr 3, 2023
58baa63
synthetics - paginate service requests in batches of 100
dominiqueclarke Apr 3, 2023
f75f7ac
merge upstream
dominiqueclarke Apr 3, 2023
b7850c2
adjust types
dominiqueclarke Apr 3, 2023
2a51889
Merge branch 'feat/synthetics-limit-sync-to-batches-of-100' of https:…
dominiqueclarke Apr 3, 2023
03c33ed
Merge branch 'feat/synthetics-saved-object-migration-8.8.0' of https:…
dominiqueclarke Apr 3, 2023
8370321
adjust order of validation
dominiqueclarke Apr 4, 2023
332d50b
Update x-pack/plugins/synthetics/server/legacy_uptime/lib/saved_objec…
dominiqueclarke Apr 4, 2023
4c5696e
adjust content
dominiqueclarke Apr 4, 2023
d1c8b54
Merge branch 'main' of github.com:elastic/kibana into feat/synthetics…
dominiqueclarke Apr 4, 2023
729cade
Merge branch 'feat/synthetics-saved-object-migration-8.8.0' of https:…
dominiqueclarke Apr 4, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"slo": "ee0e16abebba5779c37277bc3fe8da1fe1207b7a",
"space": "7fc578a1f9f7708cb07479f03953d664ad9f1dae",
"spaces-usage-stats": "084bd0f080f94fb5735d7f3cf12f13ec92f36bad",
"synthetics-monitor": "96cc312bfa597022f83dfb3b5d1501e27a73e8d5",
"synthetics-monitor": "7136a2669a65323c56da849f26c369cdeeb3b381",
"synthetics-param": "9776c9b571d35f0d0397e8915e035ea1dc026db7",
"synthetics-privates-locations": "7d032fc788905e32152029ae7ab3d6038c48ae44",
"tag": "87f21f07df9cc37001b15a26e413c18f50d1fbfe",
Expand Down
27 changes: 13 additions & 14 deletions x-pack/plugins/synthetics/common/constants/monitor_defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ import { ConfigKey } from './monitor_management';

export const DEFAULT_NAMESPACE_STRING = 'default';

export const ALLOWED_SCHEDULES_IN_MINUTES = [
'1',
'3',
'5',
'10',
'15',
'20',
'30',
'60',
'120',
'240',
];

export const DEFAULT_COMMON_FIELDS: CommonFields = {
[ConfigKey.MONITOR_TYPE]: DataStream.HTTP,
[ConfigKey.FORM_MONITOR_TYPE]: FormMonitorType.MULTISTEP,
Expand Down Expand Up @@ -74,7 +87,6 @@ export const DEFAULT_BROWSER_SIMPLE_FIELDS: BrowserSimpleFields = {
is_generated_script: false,
file_name: '',
},
is_zip_url_tls_enabled: false,
},
[ConfigKey.MONITOR_TYPE]: DataStream.BROWSER,
[ConfigKey.PARAMS]: '',
Expand All @@ -85,23 +97,10 @@ export const DEFAULT_BROWSER_SIMPLE_FIELDS: BrowserSimpleFields = {
},
[ConfigKey.SOURCE_INLINE]: '',
[ConfigKey.SOURCE_PROJECT_CONTENT]: '',
[ConfigKey.SOURCE_ZIP_URL]: '',
[ConfigKey.SOURCE_ZIP_USERNAME]: '',
[ConfigKey.SOURCE_ZIP_PASSWORD]: '',
[ConfigKey.SOURCE_ZIP_FOLDER]: '',
[ConfigKey.SOURCE_ZIP_PROXY_URL]: '',
[ConfigKey.TEXT_ASSERTION]: '',
[ConfigKey.URLS]: '',
[ConfigKey.FORM_MONITOR_TYPE]: FormMonitorType.MULTISTEP,
[ConfigKey.TIMEOUT]: null,

// Deprecated, slated to be removed in a future version
[ConfigKey.ZIP_URL_TLS_CERTIFICATE_AUTHORITIES]: undefined,
[ConfigKey.ZIP_URL_TLS_CERTIFICATE]: undefined,
[ConfigKey.ZIP_URL_TLS_KEY]: undefined,
[ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE]: undefined,
[ConfigKey.ZIP_URL_TLS_VERIFICATION_MODE]: undefined,
[ConfigKey.ZIP_URL_TLS_VERSION]: undefined,
};

export const DEFAULT_HTTP_SIMPLE_FIELDS: HTTPSimpleFields = {
Expand Down
29 changes: 14 additions & 15 deletions x-pack/plugins/synthetics/common/constants/monitor_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ export enum ConfigKey {
SCREENSHOTS = 'screenshots',
SOURCE_PROJECT_CONTENT = 'source.project.content',
SOURCE_INLINE = 'source.inline.script',
SOURCE_ZIP_URL = 'source.zip_url.url',
SOURCE_ZIP_USERNAME = 'source.zip_url.username',
SOURCE_ZIP_PASSWORD = 'source.zip_url.password',
SOURCE_ZIP_FOLDER = 'source.zip_url.folder',
SOURCE_ZIP_PROXY_URL = 'source.zip_url.proxy_url',
PROJECT_ID = 'project_id',
SYNTHETICS_ARGS = 'synthetics_args',
TEXT_ASSERTION = 'playwright_text_assertion',
Expand All @@ -78,12 +73,6 @@ export enum ConfigKey {
URLS = 'urls',
USERNAME = 'username',
WAIT = 'wait',
ZIP_URL_TLS_CERTIFICATE_AUTHORITIES = 'source.zip_url.ssl.certificate_authorities',
ZIP_URL_TLS_CERTIFICATE = 'source.zip_url.ssl.certificate',
ZIP_URL_TLS_KEY = 'source.zip_url.ssl.key',
ZIP_URL_TLS_KEY_PASSPHRASE = 'source.zip_url.ssl.key_passphrase',
ZIP_URL_TLS_VERIFICATION_MODE = 'source.zip_url.ssl.verification_mode',
ZIP_URL_TLS_VERSION = 'source.zip_url.ssl.supported_protocols',
MONITOR_QUERY_ID = 'id',
}

Expand All @@ -99,12 +88,22 @@ export const secretKeys = [
ConfigKey.RESPONSE_RECEIVE_CHECK,
ConfigKey.SOURCE_INLINE,
ConfigKey.SOURCE_PROJECT_CONTENT,
ConfigKey.SOURCE_ZIP_USERNAME,
ConfigKey.SOURCE_ZIP_PASSWORD,
ConfigKey.SYNTHETICS_ARGS,
ConfigKey.TLS_KEY,
ConfigKey.TLS_KEY_PASSPHRASE,
ConfigKey.USERNAME,
ConfigKey.ZIP_URL_TLS_KEY,
ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE,
] as const;

export enum LegacyConfigKey {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shahzad31 For the throttling feature, any keys you want to remove from the saved object you'll want to make sure you include in this enum. This will ensure that the old legacy fields are excluded from AAD when migrated, and ensure that decryption is able to progress with the legacy fields missing.

SOURCE_ZIP_URL = 'source.zip_url.url',
SOURCE_ZIP_USERNAME = 'source.zip_url.username',
SOURCE_ZIP_PASSWORD = 'source.zip_url.password',
SOURCE_ZIP_FOLDER = 'source.zip_url.folder',
SOURCE_ZIP_PROXY_URL = 'source.zip_url.proxy_url',
ZIP_URL_TLS_CERTIFICATE_AUTHORITIES = 'source.zip_url.ssl.certificate_authorities',
ZIP_URL_TLS_CERTIFICATE = 'source.zip_url.ssl.certificate',
ZIP_URL_TLS_KEY = 'source.zip_url.ssl.key',
ZIP_URL_TLS_KEY_PASSPHRASE = 'source.zip_url.ssl.key_passphrase',
ZIP_URL_TLS_VERIFICATION_MODE = 'source.zip_url.ssl.verification_mode',
ZIP_URL_TLS_VERSION = 'source.zip_url.ssl.supported_protocols',
}
18 changes: 0 additions & 18 deletions x-pack/plugins/synthetics/common/formatters/browser/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {
arrayToJsonFormatter,
objectToJsonFormatter,
stringToJsonFormatter,
tlsArrayToYamlFormatter,
tlsValueToStringFormatter,
tlsValueToYamlFormatter,
} from '../formatting_utils';

import { tlsFormatters } from '../tls/formatters';
Expand All @@ -35,20 +32,6 @@ const throttlingFormatter: Formatter = (fields) => {
.join('/');
};

export const deprecatedZipUrlFormatters = {
[ConfigKey.SOURCE_ZIP_URL]: null,
[ConfigKey.SOURCE_ZIP_USERNAME]: null,
[ConfigKey.SOURCE_ZIP_PASSWORD]: null,
[ConfigKey.SOURCE_ZIP_FOLDER]: null,
[ConfigKey.SOURCE_ZIP_PROXY_URL]: null,
[ConfigKey.ZIP_URL_TLS_CERTIFICATE_AUTHORITIES]: tlsValueToYamlFormatter,
[ConfigKey.ZIP_URL_TLS_CERTIFICATE]: tlsValueToYamlFormatter,
[ConfigKey.ZIP_URL_TLS_KEY]: tlsValueToYamlFormatter,
[ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE]: tlsValueToStringFormatter,
[ConfigKey.ZIP_URL_TLS_VERIFICATION_MODE]: tlsValueToStringFormatter,
[ConfigKey.ZIP_URL_TLS_VERSION]: tlsArrayToYamlFormatter,
};

export const browserFormatters: BrowserFormatMap = {
[ConfigKey.SOURCE_PROJECT_CONTENT]: null,
[ConfigKey.PARAMS]: null,
Expand All @@ -68,7 +51,6 @@ export const browserFormatters: BrowserFormatMap = {
[ConfigKey.JOURNEY_FILTERS_MATCH]: stringToJsonFormatter,
[ConfigKey.JOURNEY_FILTERS_TAGS]: arrayToJsonFormatter,
[ConfigKey.THROTTLING_CONFIG]: throttlingFormatter,
...deprecatedZipUrlFormatters,
...commonFormatters,
...tlsFormatters,
};
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ describe('formatSyntheticsPolicy', () => {
__ui: {
type: 'yaml',
value:
'{"script_source":{"is_generated_script":false,"file_name":""},"is_zip_url_tls_enabled":false,"is_tls_enabled":false}',
'{"script_source":{"is_generated_script":false,"file_name":""},"is_tls_enabled":false}',
},
config_id: {
type: 'text',
Expand Down Expand Up @@ -411,44 +411,6 @@ describe('formatSyntheticsPolicy', () => {
type: 'text',
value: '',
},
'source.zip_url.folder': {
type: 'text',
value: '',
},
'source.zip_url.password': {
type: 'password',
value: '',
},
'source.zip_url.proxy_url': {
type: 'text',
value: '',
},
'source.zip_url.ssl.certificate': {
type: 'yaml',
},
'source.zip_url.ssl.certificate_authorities': {
type: 'yaml',
},
'source.zip_url.ssl.key': {
type: 'yaml',
},
'source.zip_url.ssl.key_passphrase': {
type: 'text',
},
'source.zip_url.ssl.supported_protocols': {
type: 'yaml',
},
'source.zip_url.ssl.verification_mode': {
type: 'text',
},
'source.zip_url.url': {
type: 'text',
value: '',
},
'source.zip_url.username': {
type: 'text',
value: '',
},
synthetics_args: {
type: 'text',
value: null,
Expand Down Expand Up @@ -918,39 +880,6 @@ describe('formatSyntheticsPolicy', () => {
'source.project.content': {
type: 'text',
},
'source.zip_url.folder': {
type: 'text',
},
'source.zip_url.password': {
type: 'password',
},
'source.zip_url.proxy_url': {
type: 'text',
},
'source.zip_url.ssl.certificate': {
type: 'yaml',
},
'source.zip_url.ssl.certificate_authorities': {
type: 'yaml',
},
'source.zip_url.ssl.key': {
type: 'yaml',
},
'source.zip_url.ssl.key_passphrase': {
type: 'text',
},
'source.zip_url.ssl.supported_protocols': {
type: 'yaml',
},
'source.zip_url.ssl.verification_mode': {
type: 'text',
},
'source.zip_url.url': {
type: 'text',
},
'source.zip_url.username': {
type: 'text',
},
synthetics_args: {
type: 'text',
},
Expand Down Expand Up @@ -1147,10 +1076,6 @@ const testNewPolicy = {
'service.name': { type: 'text' },
timeout: { type: 'text' },
tags: { type: 'yaml' },
'source.zip_url.url': { type: 'text' },
'source.zip_url.username': { type: 'text' },
'source.zip_url.folder': { type: 'text' },
'source.zip_url.password': { type: 'password' },
'source.inline.script': { type: 'yaml' },
'source.project.content': { type: 'text' },
params: { type: 'yaml' },
Expand All @@ -1161,13 +1086,6 @@ const testNewPolicy = {
'throttling.config': { type: 'text' },
'filter_journeys.tags': { type: 'yaml' },
'filter_journeys.match': { type: 'text' },
'source.zip_url.ssl.certificate_authorities': { type: 'yaml' },
'source.zip_url.ssl.certificate': { type: 'yaml' },
'source.zip_url.ssl.key': { type: 'yaml' },
'source.zip_url.ssl.key_passphrase': { type: 'text' },
'source.zip_url.ssl.verification_mode': { type: 'text' },
'source.zip_url.ssl.supported_protocols': { type: 'yaml' },
'source.zip_url.proxy_url': { type: 'text' },
location_name: { value: 'Fleet managed', type: 'text' },
id: { type: 'text' },
config_id: { type: 'text' },
Expand Down Expand Up @@ -1212,7 +1130,6 @@ const browserConfig: any = {
playwright_options: '',
__ui: {
script_source: { is_generated_script: false, file_name: '' },
is_zip_url_tls_enabled: false,
is_tls_enabled: false,
},
params:
Expand All @@ -1221,11 +1138,6 @@ const browserConfig: any = {
'source.inline.script':
'step("Visit /users api route", async () => {\\n const response = await page.goto(\'https://nextjs-test-synthetics.vercel.app/api/users\');\\n expect(response.status()).toEqual(200);\\n});',
'source.project.content': '',
'source.zip_url.url': '',
'source.zip_url.username': '',
'source.zip_url.password': '',
'source.zip_url.folder': '',
'source.zip_url.proxy_url': '',
playwright_text_assertion: '',
urls: '',
screenshots: 'on',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const ScriptSourceCodec = t.interface({

export const MetadataCodec = t.partial({
is_tls_enabled: t.boolean,
is_zip_url_tls_enabled: t.boolean,
script_source: ScriptSourceCodec,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@ export const TLSCodec = t.intersection([TLSFieldsCodec, TLSSensitiveFieldsCodec]

export type TLSFields = t.TypeOf<typeof TLSCodec>;

// ZipUrlTLSFields
export const ZipUrlTLSFieldsCodec = t.partial({
[ConfigKey.ZIP_URL_TLS_CERTIFICATE_AUTHORITIES]: t.string,
[ConfigKey.ZIP_URL_TLS_CERTIFICATE]: t.string,
[ConfigKey.ZIP_URL_TLS_VERIFICATION_MODE]: VerificationModeCodec,
[ConfigKey.ZIP_URL_TLS_VERSION]: t.array(TLSVersionCodec),
});

export const ZipUrlTLSSensitiveFieldsCodec = t.partial({
[ConfigKey.ZIP_URL_TLS_KEY]: t.string,
[ConfigKey.ZIP_URL_TLS_KEY_PASSPHRASE]: t.string,
});

export const ZipUrlTLSCodec = t.intersection([ZipUrlTLSFieldsCodec, ZipUrlTLSSensitiveFieldsCodec]);

export type ZipUrlTLSFields = t.TypeOf<typeof ZipUrlTLSCodec>;

// CommonFields
export const CommonFieldsCodec = t.intersection([
t.interface({
Expand Down Expand Up @@ -222,31 +205,23 @@ export const EncryptedBrowserSimpleFieldsCodec = t.intersection([
t.intersection([
t.interface({
[ConfigKey.METADATA]: MetadataCodec,
[ConfigKey.SOURCE_ZIP_URL]: t.string,
[ConfigKey.SOURCE_ZIP_FOLDER]: t.string,
[ConfigKey.SOURCE_ZIP_PROXY_URL]: t.string,
}),
t.partial({
[ConfigKey.PLAYWRIGHT_OPTIONS]: t.string,
[ConfigKey.TEXT_ASSERTION]: t.string,
}),
]),
ZipUrlTLSFieldsCodec,
ZipUrlTLSSensitiveFieldsCodec,
CommonFieldsCodec,
]);

export const BrowserSensitiveSimpleFieldsCodec = t.intersection([
t.interface({
[ConfigKey.SOURCE_INLINE]: t.string,
[ConfigKey.SOURCE_PROJECT_CONTENT]: t.string,
[ConfigKey.SOURCE_ZIP_USERNAME]: t.string,
[ConfigKey.SOURCE_ZIP_PASSWORD]: t.string,
[ConfigKey.PARAMS]: t.string,
[ConfigKey.URLS]: t.union([t.string, t.null]),
[ConfigKey.PORT]: t.union([t.number, t.null]),
}),
ZipUrlTLSFieldsCodec,
CommonFieldsCodec,
]);

Expand All @@ -265,7 +240,6 @@ export const EncryptedBrowserAdvancedFieldsCodec = t.interface({
export const BrowserSimpleFieldsCodec = t.intersection([
EncryptedBrowserSimpleFieldsCodec,
BrowserSensitiveSimpleFieldsCodec,
ZipUrlTLSSensitiveFieldsCodec,
]);

export const BrowserSensitiveAdvancedFieldsCodec = t.interface({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,12 @@ export const testDataMonitor = {
playwright_options: '',
__ui: {
script_source: { is_generated_script: false, file_name: '' },
is_zip_url_tls_enabled: false,
},
params: '',
'url.port': null,
'source.inline.script':
"step('Go to https://www.google.com', async () => {\n await page.goto('https://www.google.com');\n expect(await page.isVisible('text=Data')).toBeTruthy();\n });",
'source.project.content': '',
'source.zip_url.url': '',
'source.zip_url.username': '',
'source.zip_url.password': '',
'source.zip_url.folder': '',
'source.zip_url.proxy_url': '',
playwright_text_assertion: 'Data',
urls: 'https://www.google.com',
screenshots: 'on',
Expand Down
Loading