Skip to content

Commit 091eb74

Browse files
authored
Merge branch 'main' into kbn-140743-notifications-api-mvp
2 parents 1467966 + 404d08f commit 091eb74

249 files changed

Lines changed: 11194 additions & 3408 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.buildkite/ftr_configs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,5 @@ enabled:
279279
- x-pack/performance/journeys/promotion_tracking_dashboard.ts
280280
- x-pack/performance/journeys/web_logs_dashboard.ts
281281
- x-pack/performance/journeys/data_stress_test_lens.ts
282+
- x-pack/performance/journeys/ecommerce_dashboard_saved_search_only.ts
283+
- x-pack/performance/journeys/ecommerce_dashboard_tsvb_gauge_only.ts

examples/guided_onboarding_example/public/components/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ export const Main = (props: MainProps) => {
216216
)}
217217
{(guideState?.isActive === true ||
218218
guideState?.status === 'in_progress' ||
219-
guideState?.status === 'ready_to_complete') && (
219+
guideState?.status === 'ready_to_complete' ||
220+
guideState?.status === 'not_started') && (
220221
<FormattedMessage
221222
id="guidedOnboardingExample.guidesSelection.continueButtonLabel"
222223
defaultMessage="Continue {guideId} guide"

packages/core/node/core-node-server-internal/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
export { nodeConfig } from './src/node_config';
1010

1111
export { NodeService, type PrebootDeps } from './src/node_service';
12-
export type { InternalNodeServicePreboot } from './src/node_service';
12+
export type { InternalNodeServicePreboot, InternalNodeServiceStart } from './src/node_service';

packages/core/node/core-node-server-internal/src/node_service.test.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,62 @@ describe('NodeService', () => {
117117
});
118118
});
119119
});
120+
describe('#start()', () => {
121+
it('returns default roles values when wildcard is provided', async () => {
122+
configService = getMockedConfigService({ roles: ['*'] });
123+
coreContext = mockCoreContext.create({ logger, configService });
124+
125+
service = new NodeService(coreContext);
126+
await service.preboot({ loggingSystem: logger });
127+
const { roles } = service.start();
128+
129+
expect(roles.backgroundTasks).toBe(true);
130+
expect(roles.ui).toBe(true);
131+
});
132+
133+
it('returns correct roles when node is configured to `background_tasks`', async () => {
134+
configService = getMockedConfigService({ roles: ['background_tasks'] });
135+
coreContext = mockCoreContext.create({ logger, configService });
136+
137+
service = new NodeService(coreContext);
138+
await service.preboot({ loggingSystem: logger });
139+
const { roles } = service.start();
140+
141+
expect(roles.backgroundTasks).toBe(true);
142+
expect(roles.ui).toBe(false);
143+
});
144+
145+
it('returns correct roles when node is configured to `ui`', async () => {
146+
configService = getMockedConfigService({ roles: ['ui'] });
147+
coreContext = mockCoreContext.create({ logger, configService });
148+
149+
service = new NodeService(coreContext);
150+
await service.preboot({ loggingSystem: logger });
151+
const { roles } = service.start();
152+
153+
expect(roles.backgroundTasks).toBe(false);
154+
expect(roles.ui).toBe(true);
155+
});
156+
157+
it('returns correct roles when node is configured to both `background_tasks` and `ui`', async () => {
158+
configService = getMockedConfigService({ roles: ['background_tasks', 'ui'] });
159+
coreContext = mockCoreContext.create({ logger, configService });
160+
161+
service = new NodeService(coreContext);
162+
await service.preboot({ loggingSystem: logger });
163+
const { roles } = service.start();
164+
165+
expect(roles.backgroundTasks).toBe(true);
166+
expect(roles.ui).toBe(true);
167+
});
168+
it('throws if preboot has not been run', () => {
169+
configService = getMockedConfigService({ roles: ['background_tasks', 'ui'] });
170+
coreContext = mockCoreContext.create({ logger, configService });
171+
172+
service = new NodeService(coreContext);
173+
expect(() => service.start()).toThrowErrorMatchingInlineSnapshot(
174+
`"NodeService#start() can only be called after NodeService#preboot()"`
175+
);
176+
});
177+
});
120178
});

packages/core/node/core-node-server-internal/src/node_service.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,20 @@ const containsWildcard = (roles: string[]) => roles.includes(NODE_WILDCARD_CHAR)
2828
*/
2929
export interface InternalNodeServicePreboot {
3030
/**
31-
* Retrieve the Kibana instance uuid.
31+
* The Kibana process can take on specialised roles via the `node.roles` config.
32+
*
33+
* The roles can be used by plugins to adjust their behavior based
34+
* on the way the Kibana process has been configured.
35+
*/
36+
roles: NodeRoles;
37+
}
38+
39+
export interface InternalNodeServiceStart {
40+
/**
41+
* The Kibana process can take on specialised roles via the `node.roles` config.
42+
*
43+
* The roles can be used by plugins to adjust their behavior based
44+
* on the way the Kibana process has been configured.
3245
*/
3346
roles: NodeRoles;
3447
}
@@ -41,6 +54,7 @@ export interface PrebootDeps {
4154
export class NodeService {
4255
private readonly configService: IConfigService;
4356
private readonly log: Logger;
57+
private roles?: NodeRoles;
4458

4559
constructor(core: CoreContext) {
4660
this.configService = core.configService;
@@ -52,13 +66,22 @@ export class NodeService {
5266
loggingSystem.setGlobalContext({ service: { node: { roles } } });
5367
this.log.info(`Kibana process configured with roles: [${roles.join(', ')}]`);
5468

69+
this.roles = NODE_ACCEPTED_ROLES.reduce((acc, curr) => {
70+
return { ...acc, [camelCase(curr)]: roles.includes(curr) };
71+
}, {} as NodeRoles);
72+
5573
return {
56-
roles: NODE_ACCEPTED_ROLES.reduce((acc, curr) => {
57-
return { ...acc, [camelCase(curr)]: roles.includes(curr) };
58-
}, {} as NodeRoles),
74+
roles: this.roles,
5975
};
6076
}
6177

78+
public start(): InternalNodeServiceStart {
79+
if (this.roles == null) {
80+
throw new Error('NodeService#start() can only be called after NodeService#preboot()');
81+
}
82+
return { roles: this.roles };
83+
}
84+
6285
public stop() {
6386
// nothing to do here yet
6487
}

packages/core/node/core-node-server-mocks/src/node_service.mock.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
*/
88

99
import type { PublicMethodsOf } from '@kbn/utility-types';
10-
import type { NodeService, InternalNodeServicePreboot } from '@kbn/core-node-server-internal';
10+
import type {
11+
NodeService,
12+
InternalNodeServicePreboot,
13+
InternalNodeServiceStart,
14+
} from '@kbn/core-node-server-internal';
1115

1216
const createInternalPrebootContractMock = () => {
1317
const prebootContract: jest.Mocked<InternalNodeServicePreboot> = {
@@ -19,17 +23,38 @@ const createInternalPrebootContractMock = () => {
1923
return prebootContract;
2024
};
2125

26+
const createInternalStartContractMock = (
27+
{
28+
ui,
29+
backgroundTasks,
30+
}: {
31+
ui: boolean;
32+
backgroundTasks: boolean;
33+
} = { ui: true, backgroundTasks: true }
34+
) => {
35+
const startContract: jest.Mocked<InternalNodeServiceStart> = {
36+
roles: {
37+
backgroundTasks,
38+
ui,
39+
},
40+
};
41+
return startContract;
42+
};
43+
2244
type NodeServiceContract = PublicMethodsOf<NodeService>;
2345
const createMock = () => {
2446
const mocked: jest.Mocked<NodeServiceContract> = {
2547
preboot: jest.fn(),
48+
start: jest.fn(),
2649
stop: jest.fn(),
2750
};
2851
mocked.preboot.mockResolvedValue(createInternalPrebootContractMock());
52+
mocked.start.mockReturnValue(createInternalStartContractMock());
2953
return mocked;
3054
};
3155

3256
export const nodeServiceMock = {
3357
create: createMock,
3458
createInternalPrebootContract: createInternalPrebootContractMock,
59+
createInternalStartContract: createInternalStartContractMock,
3560
};

packages/core/saved-objects/core-saved-objects-migration-server-internal/src/README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,19 @@ the same version could have plugins enabled at any time that would introduce
167167
new transforms or mappings.
168168
`OUTDATED_DOCUMENTS_SEARCH`
169169

170-
3. If the `.kibana` alias exists we’re migrating from either a v1 or v2 index
170+
3. If `waitForMigrations` was set we're running on a background-tasks node and
171+
we should not participate in the migration but instead wait for the ui node(s)
172+
to complete the migration.
173+
`WAIT_FOR_MIGRATION_COMPLETION`
174+
175+
4. If the `.kibana` alias exists we’re migrating from either a v1 or v2 index
171176
and the migration source index is the index the `.kibana` alias points to.
172177
`WAIT_FOR_YELLOW_SOURCE`
173178

174-
4. If `.kibana` is a concrete index, we’re migrating from a legacy index
179+
5. If `.kibana` is a concrete index, we’re migrating from a legacy index
175180
`LEGACY_SET_WRITE_BLOCK`
176181

177-
5. If there are no `.kibana` indices, this is a fresh deployment. Initialize a
182+
6. If there are no `.kibana` indices, this is a fresh deployment. Initialize a
178183
new saved objects index
179184
`CREATE_NEW_TARGET`
180185

@@ -259,6 +264,15 @@ new `.kibana` alias that points to `.kibana_pre6.5.0_001`.
259264
`index_not_found_exception` another instance has already completed this step.
260265
`SET_SOURCE_WRITE_BLOCK`
261266

267+
## WAIT_FOR_MIGRATION_COMPLETION
268+
### Next action
269+
`fetchIndices`
270+
### New control state
271+
1. If the ui node finished the migration
272+
`DONE`
273+
2. Otherwise wait 2s and check again
274+
→ WAIT_FOR_MIGRATION_COMPLETION
275+
262276
## WAIT_FOR_YELLOW_SOURCE
263277
### Next action
264278
`waitForIndexStatus` (status='yellow')
@@ -417,6 +431,13 @@ update the mappings and then use an update_by_query to ensure that all fields ar
417431

418432
## UPDATE_TARGET_MAPPINGS_WAIT_FOR_TASK
419433
### Next action
434+
`waitForPickupUpdatedMappingsTask`
435+
436+
### New control state
437+
`MARK_VERSION_INDEX_READY`
438+
439+
## MARK_VERSION_INDEX_READY
440+
### Next action
420441
`updateAliases`
421442

422443
Atomically apply the `versionIndexReadyActions` using the _alias actions API. By performing the following actions we guarantee that if multiple versions of Kibana started the upgrade in parallel, only one version will succeed.

packages/core/saved-objects/core-saved-objects-migration-server-internal/src/__snapshots__/migrations_state_action_machine.test.ts.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)