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

Set mget task claim strategy as the default #197070

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
11703c2
Revert "Onboard elastic owned ECH clusters to use `mget` task claimin…
mikecote Oct 21, 2024
9e6737f
Revert "[Response Ops][Task Manager] Onboard 12.5% of ECH clusters to…
mikecote Oct 21, 2024
140c1a6
Initial commit
mikecote Oct 21, 2024
518c5d7
No longer need the serverless specific setting
mikecote Oct 21, 2024
e1041ee
Switch secondary tests to update by query
mikecote Oct 21, 2024
27476b2
Some fixes for update by query tests
mikecote Oct 21, 2024
59b71bc
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Oct 21, 2024
9f703e3
Move task partitions tests
mikecote Oct 21, 2024
e433bfe
Merge branch 'task-manager/mget-default-claim-strategy-2' of github.c…
mikecote Oct 21, 2024
aea910e
Flaky test
mikecote Oct 21, 2024
77492e8
Merge branch 'main' into task-manager/mget-default-claim-strategy-2
mikecote Oct 21, 2024
1374422
Wait for cache to update
mikecote Oct 21, 2024
b86da43
Merge branch 'task-manager/mget-default-claim-strategy-2' of github.c…
mikecote Oct 21, 2024
30793c0
Delete tasks after test
mikecote Oct 22, 2024
4723ced
Try higher timeout
mikecote Oct 22, 2024
3d667a0
supertest -> request
mikecote Oct 22, 2024
d28c8c5
Fix some flaky tests
mikecote Oct 22, 2024
1defead
Fix failing test
mikecote Oct 23, 2024
dd7773a
Merge branch 'main' into task-manager/mget-default-claim-strategy-2
mikecote Oct 23, 2024
fda521a
Fix jest integration tests
mikecote Oct 23, 2024
62ad1ec
Merge branch 'main' into task-manager/mget-default-claim-strategy-2
mikecote Oct 23, 2024
45a35d5
Merge branch 'main' into task-manager/mget-default-claim-strategy-2
mikecote Oct 25, 2024
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
2 changes: 1 addition & 1 deletion .buildkite/ftr_platform_stateful_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ enabled:
- x-pack/test/spaces_api_integration/security_and_spaces/config_trial.ts
- x-pack/test/spaces_api_integration/security_and_spaces/copy_to_space_config_trial.ts
- x-pack/test/spaces_api_integration/spaces_only/config.ts
- x-pack/test/task_manager_claimer_mget/config.ts
- x-pack/test/task_manager_claimer_update_by_query/config.ts
- x-pack/test/ui_capabilities/security_and_spaces/config.ts
- x-pack/test/ui_capabilities/spaces_only/config.ts
- x-pack/test/upgrade_assistant_integration/config.ts
Expand Down
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ x-pack/plugins/runtime_fields @elastic/kibana-management
packages/kbn-safer-lodash-set @elastic/kibana-security
x-pack/test/security_api_integration/plugins/saml_provider @elastic/kibana-security
x-pack/test/plugin_api_integration/plugins/sample_task_plugin @elastic/response-ops
x-pack/test/task_manager_claimer_mget/plugins/sample_task_plugin_mget @elastic/response-ops
x-pack/test/task_manager_claimer_update_by_query/plugins/sample_task_plugin_mget @elastic/response-ops
test/plugin_functional/plugins/saved_object_export_transforms @elastic/kibana-core
test/plugin_functional/plugins/saved_object_import_warnings @elastic/kibana-core
x-pack/test/saved_object_api_integration/common/plugins/saved_object_test_plugin @elastic/kibana-security
Expand Down Expand Up @@ -1495,7 +1495,7 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/x-pack/test/alerting_api_integration/observability @elastic/obs-ux-management-team
/x-pack/test/plugin_api_integration/test_suites/task_manager/ @elastic/response-ops
/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/ @elastic/response-ops
/x-pack/test/task_manager_claimer_mget/ @elastic/response-ops
/x-pack/test/task_manager_claimer_update_by_query/ @elastic/response-ops
/docs/user/alerting/ @elastic/response-ops
/docs/management/connectors/ @elastic/response-ops
/x-pack/test/cases_api_integration/ @elastic/response-ops
Expand Down
1 change: 0 additions & 1 deletion config/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ uiSettings:
labs:dashboard:deferBelowFold: false

# Task Manager
xpack.task_manager.claim_strategy: mget
xpack.task_manager.allow_reading_invalid_state: false
xpack.task_manager.request_timeouts.update_by_query: 60000
xpack.task_manager.metrics_reset_interval: 120000
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
"@kbn/safer-lodash-set": "link:packages/kbn-safer-lodash-set",
"@kbn/saml-provider-plugin": "link:x-pack/test/security_api_integration/plugins/saml_provider",
"@kbn/sample-task-plugin": "link:x-pack/test/plugin_api_integration/plugins/sample_task_plugin",
"@kbn/sample-task-plugin-mget": "link:x-pack/test/task_manager_claimer_mget/plugins/sample_task_plugin_mget",
"@kbn/sample-task-plugin-update-by-query": "link:x-pack/test/task_manager_claimer_update_by_query/plugins/sample_task_plugin_mget",
"@kbn/saved-object-export-transforms-plugin": "link:test/plugin_functional/plugins/saved_object_export_transforms",
"@kbn/saved-object-import-warnings-plugin": "link:test/plugin_functional/plugins/saved_object_import_warnings",
"@kbn/saved-object-test-plugin": "link:x-pack/test/saved_object_api_integration/common/plugins/saved_object_test_plugin",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1484,8 +1484,8 @@
"@kbn/saml-provider-plugin/*": ["x-pack/test/security_api_integration/plugins/saml_provider/*"],
"@kbn/sample-task-plugin": ["x-pack/test/plugin_api_integration/plugins/sample_task_plugin"],
"@kbn/sample-task-plugin/*": ["x-pack/test/plugin_api_integration/plugins/sample_task_plugin/*"],
"@kbn/sample-task-plugin-mget": ["x-pack/test/task_manager_claimer_mget/plugins/sample_task_plugin_mget"],
"@kbn/sample-task-plugin-mget/*": ["x-pack/test/task_manager_claimer_mget/plugins/sample_task_plugin_mget/*"],
"@kbn/sample-task-plugin-update-by-query": ["x-pack/test/task_manager_claimer_update_by_query/plugins/sample_task_plugin_mget"],
"@kbn/sample-task-plugin-update-by-query/*": ["x-pack/test/task_manager_claimer_update_by_query/plugins/sample_task_plugin_mget/*"],
"@kbn/saved-object-export-transforms-plugin": ["test/plugin_functional/plugins/saved_object_export_transforms"],
"@kbn/saved-object-export-transforms-plugin/*": ["test/plugin_functional/plugins/saved_object_export_transforms/*"],
"@kbn/saved-object-import-warnings-plugin": ["test/plugin_functional/plugins/saved_object_import_warnings"],
Expand Down
11 changes: 7 additions & 4 deletions x-pack/plugins/task_manager/server/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('config validation', () => {
Object {
"allow_reading_invalid_state": true,
"auto_calculate_default_ech_capacity": false,
"claim_strategy": "mget",
"discovery": Object {
"active_nodes_lookback": "30s",
"interval": 10000,
Expand Down Expand Up @@ -44,7 +45,7 @@ describe('config validation', () => {
"warn_threshold": 80,
},
},
"poll_interval": 3000,
"poll_interval": 500,
"request_capacity": 1000,
"request_timeouts": Object {
"update_by_query": 30000,
Expand All @@ -66,7 +67,7 @@ describe('config validation', () => {
expect(() => {
configSchema.validate(config);
}).toThrowErrorMatchingInlineSnapshot(
`"The specified monitored_stats_required_freshness (100) is invalid, as it is below the poll_interval (3000)"`
`"The specified monitored_stats_required_freshness (100) is invalid, as it is below the poll_interval (500)"`
);
});

Expand All @@ -76,6 +77,7 @@ describe('config validation', () => {
Object {
"allow_reading_invalid_state": true,
"auto_calculate_default_ech_capacity": false,
"claim_strategy": "mget",
"discovery": Object {
"active_nodes_lookback": "30s",
"interval": 10000,
Expand Down Expand Up @@ -106,7 +108,7 @@ describe('config validation', () => {
"warn_threshold": 80,
},
},
"poll_interval": 3000,
"poll_interval": 500,
"request_capacity": 1000,
"request_timeouts": Object {
"update_by_query": 30000,
Expand Down Expand Up @@ -136,6 +138,7 @@ describe('config validation', () => {
Object {
"allow_reading_invalid_state": true,
"auto_calculate_default_ech_capacity": false,
"claim_strategy": "mget",
"discovery": Object {
"active_nodes_lookback": "30s",
"interval": 10000,
Expand Down Expand Up @@ -171,7 +174,7 @@ describe('config validation', () => {
"warn_threshold": 80,
},
},
"poll_interval": 3000,
"poll_interval": 500,
"request_capacity": 1000,
"request_timeouts": Object {
"update_by_query": 30000,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/task_manager/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export const configSchema = schema.object(
max: 100,
min: 1,
}),
claim_strategy: schema.maybe(schema.string()),
claim_strategy: schema.string({ defaultValue: CLAIM_STRATEGY_MGET }),
request_timeouts: requestTimeoutsConfig,
auto_calculate_default_ech_capacity: schema.boolean({ defaultValue: false }),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ describe('switch task claiming strategies', () => {
jest.clearAllMocks();
});

it('should switch from default to mget and still claim tasks', async () => {
it('should switch from default to update_by_query and still claim tasks', async () => {
const setupResultDefault = await setupTestServers();
const esServer = setupResultDefault.esServer;
let kibanaServer = setupResultDefault.kibanaServer;
let taskClaimingOpts: TaskClaimingOpts = TaskClaimingMock.mock.calls[0][0];

expect(taskClaimingOpts.strategy).toBe('update_by_query');
expect(taskClaimingOpts.strategy).toBe('mget');

mockTaskTypeRunFn.mockImplementation(() => {
return { state: {} };
Expand Down Expand Up @@ -90,17 +90,17 @@ describe('switch task claiming strategies', () => {
await kibanaServer.stop();
}

const setupResultMget = await setupKibanaServer({
const setupResultUbq = await setupKibanaServer({
xpack: {
task_manager: {
claim_strategy: 'mget',
claim_strategy: 'update_by_query',
},
},
});
kibanaServer = setupResultMget.kibanaServer;
kibanaServer = setupResultUbq.kibanaServer;

taskClaimingOpts = TaskClaimingMock.mock.calls[1][0];
expect(taskClaimingOpts.strategy).toBe('mget');
expect(taskClaimingOpts.strategy).toBe('update_by_query');

// inject a task to run and ensure it is claimed and run
const id2 = uuidV4();
Expand Down Expand Up @@ -132,19 +132,19 @@ describe('switch task claiming strategies', () => {
}
});

it('should switch from mget to default and still claim tasks', async () => {
const setupResultMget = await setupTestServers({
it('should switch from update_by_query to default and still claim tasks', async () => {
const setupResultUbq = await setupTestServers({
xpack: {
task_manager: {
claim_strategy: 'mget',
claim_strategy: 'update_by_query',
},
},
});
const esServer = setupResultMget.esServer;
let kibanaServer = setupResultMget.kibanaServer;
const esServer = setupResultUbq.esServer;
let kibanaServer = setupResultUbq.kibanaServer;
let taskClaimingOpts: TaskClaimingOpts = TaskClaimingMock.mock.calls[0][0];

expect(taskClaimingOpts.strategy).toBe('mget');
expect(taskClaimingOpts.strategy).toBe('update_by_query');

mockTaskTypeRunFn.mockImplementation(() => {
return { state: {} };
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('switch task claiming strategies', () => {
kibanaServer = setupResultDefault.kibanaServer;

taskClaimingOpts = TaskClaimingMock.mock.calls[1][0];
expect(taskClaimingOpts.strategy).toBe('update_by_query');
expect(taskClaimingOpts.strategy).toBe('mget');

// inject a task to run and ensure it is claimed and run
const id2 = uuidV4();
Expand Down Expand Up @@ -212,13 +212,13 @@ describe('switch task claiming strategies', () => {
}
});

it('should switch from default to mget and claim tasks that were running during shutdown', async () => {
it('should switch from default to update_by_query and claim tasks that were running during shutdown', async () => {
const setupResultDefault = await setupTestServers();
const esServer = setupResultDefault.esServer;
let kibanaServer = setupResultDefault.kibanaServer;
let taskClaimingOpts: TaskClaimingOpts = TaskClaimingMock.mock.calls[0][0];

expect(taskClaimingOpts.strategy).toBe('update_by_query');
expect(taskClaimingOpts.strategy).toBe('mget');

mockTaskTypeRunFn.mockImplementation(async () => {
await new Promise((resolve) => setTimeout(resolve, 2000));
Expand Down Expand Up @@ -252,17 +252,17 @@ describe('switch task claiming strategies', () => {
await kibanaServer.stop();
}

const setupResultMget = await setupKibanaServer({
const setupResultUbq = await setupKibanaServer({
xpack: {
task_manager: {
claim_strategy: 'mget',
claim_strategy: 'update_by_query',
},
},
});
kibanaServer = setupResultMget.kibanaServer;
kibanaServer = setupResultUbq.kibanaServer;

taskClaimingOpts = TaskClaimingMock.mock.calls[1][0];
expect(taskClaimingOpts.strategy).toBe('mget');
expect(taskClaimingOpts.strategy).toBe('update_by_query');

// task doc should still exist and be running
const task = await kibanaServer.coreStart.elasticsearch.client.asInternalUser.get<{
Expand Down Expand Up @@ -290,19 +290,19 @@ describe('switch task claiming strategies', () => {
}
});

it('should switch from mget to default and claim tasks that were running during shutdown', async () => {
const setupResultMget = await setupTestServers({
it('should switch from update_by_query to default and claim tasks that were running during shutdown', async () => {
const setupResultUbq = await setupTestServers({
xpack: {
task_manager: {
claim_strategy: 'mget',
claim_strategy: 'update_by_query',
},
},
});
const esServer = setupResultMget.esServer;
let kibanaServer = setupResultMget.kibanaServer;
const esServer = setupResultUbq.esServer;
let kibanaServer = setupResultUbq.kibanaServer;
let taskClaimingOpts: TaskClaimingOpts = TaskClaimingMock.mock.calls[0][0];

expect(taskClaimingOpts.strategy).toBe('mget');
expect(taskClaimingOpts.strategy).toBe('update_by_query');

mockTaskTypeRunFn.mockImplementation(async () => {
await new Promise((resolve) => setTimeout(resolve, 2000));
Expand Down Expand Up @@ -340,7 +340,7 @@ describe('switch task claiming strategies', () => {
kibanaServer = setupResultDefault.kibanaServer;

taskClaimingOpts = TaskClaimingMock.mock.calls[1][0];
expect(taskClaimingOpts.strategy).toBe('update_by_query');
expect(taskClaimingOpts.strategy).toBe('mget');

// task doc should still exist and be running
const task = await kibanaServer.coreStart.elasticsearch.client.asInternalUser.get<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ describe('task state validation', () => {

it('should fail the task run when setting allow_reading_invalid_state:false and reading an invalid state', async () => {
const logSpy = jest.spyOn(pollingLifecycleOpts.logger, 'warn');
const updateSpy = jest.spyOn(pollingLifecycleOpts.taskStore, 'bulkUpdate');
const updateSpy = jest.spyOn(pollingLifecycleOpts.taskStore, 'bulkPartialUpdate');

const id = uuidV4();
await injectTask(kibanaServer.coreStart.elasticsearch.client.asInternalUser, {
Expand All @@ -332,8 +332,7 @@ describe('task state validation', () => {
const found = calls.map((arr) => arr[0]).find((message) => message.match(expected) != null);
expect(found).toMatch(expected);
expect(updateSpy).toHaveBeenCalledWith(
expect.arrayContaining([expect.objectContaining({ id, taskType: 'fooType' })]),
{ validate: false }
expect.arrayContaining([expect.objectContaining({ id })])
);
});
});
Expand Down
Loading