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

Move KibanaMigrator into Server SavedObjectsService #43433

Merged
merged 47 commits into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4b85ee9
Rename SavedObjectsService -> SavedObjectsLegacyService
rudolf Aug 13, 2019
6263726
Expose legacy pluginSpecs from Core LegacyService
rudolf Aug 13, 2019
13301e2
Expose legacy uiExports from Core LegacyService
rudolf Aug 13, 2019
19c9806
Move kibana config to NP
rudolf Aug 14, 2019
728e97d
Expose pluginExtendedConfig from LegacyService
rudolf Aug 15, 2019
b36daf3
Make KibanaMigrator NP compatible
rudolf Aug 15, 2019
4458c26
KibanaMigrator -> NP SavedObjectsService
rudolf Aug 15, 2019
6e1f026
SavedObjectsService never stop retrying ES connection error
rudolf Aug 21, 2019
86b6c62
Move waiting for migrations to complete till after legacy service start
rudolf Aug 21, 2019
b2cfb14
Fix ESArchiver's KibanaMigrator
rudolf Aug 21, 2019
6fea102
Fix reload logging config tests
rudolf Aug 21, 2019
ea6486a
Run migrations on savedobjects start
rudolf Aug 22, 2019
4b2e03e
Fix env tests
rudolf Aug 22, 2019
4c6f865
Fix and make legacy tests more robust/isolated
rudolf Aug 22, 2019
c06f07a
Cleanup code
rudolf Aug 23, 2019
8c44805
Fix invalid config test
rudolf Aug 23, 2019
f41538c
Fix SavedObject Migrations logging test
rudolf Aug 26, 2019
6b9f2c4
Merge branch 'master' into server-saved-objects-service
rudolf Aug 26, 2019
cec7235
SavedObjectsService tests
rudolf Aug 26, 2019
c0edd70
Lifecycle logging and improve getting kibanaConfig instance
rudolf Aug 26, 2019
ea77bd9
Fix awaitMigration bug and test
rudolf Aug 27, 2019
d27d816
Fix typing error
rudolf Aug 27, 2019
e8b0d12
Merge branch 'master' into server-saved-objects-service
rudolf Aug 28, 2019
6e1a527
Review comments
rudolf Aug 28, 2019
172209c
Remove unecessary KibanaConfig class
rudolf Sep 3, 2019
8b7835b
Merge branch 'master' into server-saved-objects-service
rudolf Sep 18, 2019
da017f7
Move legacy plugin config extension, specs, uiExports entirely into Core
rudolf Sep 20, 2019
0371aa3
Fix config deprecation test
rudolf Sep 20, 2019
04bb2df
Merge branch 'master' into server-saved-objects-service
rudolf Sep 20, 2019
cd759ea
Use existing logger mock
rudolf Sep 23, 2019
c2b1fd0
Create SavedObjectsConfig for migration config
rudolf Sep 23, 2019
03ce480
Define KibanaMigratorContract type
rudolf Sep 23, 2019
e14d0a4
Merge branch 'master' into server-saved-objects-service
rudolf Sep 23, 2019
d87836f
KibanaMigratorContract -> IKibanaMigrator + docs improvements
rudolf Sep 24, 2019
f7effb8
Fix esArchiver's KibanaMigrator
rudolf Sep 24, 2019
98aec57
Fix plugin generator integration test
rudolf Sep 25, 2019
da6a902
Merge branch 'master' into server-saved-objects-service
rudolf Sep 25, 2019
f783d48
Merge branch 'master' into server-saved-objects-service
rudolf Sep 25, 2019
14b16d4
Merge branch 'master' into server-saved-objects-service
rudolf Sep 27, 2019
870447e
ConfigServiceContract -> IConfigService
rudolf Sep 27, 2019
80b3ec8
Address review comments
rudolf Sep 27, 2019
3cd4cd2
Review nits
rudolf Sep 27, 2019
a214e44
Document migrations.skip config
rudolf Sep 27, 2019
38adb1a
Review comments continued...
rudolf Sep 27, 2019
86c9eef
awaitMigrations -> runMigrations
rudolf Sep 27, 2019
6e39936
Merge branch 'master' into server-saved-objects-service
rudolf Sep 30, 2019
6980d6a
Type improvements
rudolf Sep 30, 2019
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 @@ -10,3 +10,10 @@
```typescript
export interface InternalCoreStart
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [savedObjects](./kibana-plugin-server.internalcorestart.savedobjects.md) | <code>SavedObjectsServiceStart</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [InternalCoreStart](./kibana-plugin-server.internalcorestart.md) &gt; [savedObjects](./kibana-plugin-server.internalcorestart.savedobjects.md)

## InternalCoreStart.savedObjects property

<b>Signature:</b>

```typescript
savedObjects: SavedObjectsServiceStart;
```
1 change: 0 additions & 1 deletion docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [SavedObjectsMigrationVersion](./kibana-plugin-server.savedobjectsmigrationversion.md) | Information about the migrations that have been applied to this SavedObject. When Kibana starts up, KibanaMigrator detects outdated documents and migrates them based on this value. For each migration that has been applied, the plugin's name is used as a key and the latest migration version as the value. |
| [SavedObjectsRawDoc](./kibana-plugin-server.savedobjectsrawdoc.md) | A raw document as represented directly in the saved object index. |
| [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) | Options to control the "resolve import" operation. |
| [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) | |
| [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) | |
| [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) | |
| [SessionStorage](./kibana-plugin-server.sessionstorage.md) | Provides an interface to store and retrieve data across requests. |
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion kibana.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export namespace Legacy {
export type Request = LegacyKibanaServer.Request;
export type ResponseToolkit = LegacyKibanaServer.ResponseToolkit;
export type SavedObjectsClient = LegacyKibanaServer.SavedObjectsClient;
export type SavedObjectsService = LegacyKibanaServer.SavedObjectsService;
export type SavedObjectsService = LegacyKibanaServer.SavedObjectsLegacyService;
export type Server = LegacyKibanaServer.Server;

export type InitPluginFunction = LegacyKibanaPluginSpec.InitPluginFunction;
Expand Down
5 changes: 4 additions & 1 deletion src/cli/serve/integration_tests/invalid_config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ const INVALID_CONFIG_PATH = resolve(__dirname, '__fixtures__/invalid_config.yml'

describe('cli invalid config support', function () {
it('exits with statusCode 64 and logs a single line when config is invalid', function () {
// Unused keys only throw once LegacyService starts, so disable migrations so that Core
// will finish the start lifecycle without a running Elasticsearch instance.
const { error, status, stdout } = spawnSync(process.execPath, [
'src/cli',
'--config', INVALID_CONFIG_PATH
'--config', INVALID_CONFIG_PATH,
'--skip-migrations'
], {
cwd: ROOT_DIR
});
Expand Down
18 changes: 10 additions & 8 deletions src/cli/serve/integration_tests/reload_logging_config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Server logging configuration', function () {
it('should be reloadable via SIGHUP process signaling', async function () {
expect.assertions(3);

child = spawn(process.execPath, [kibanaPath, '--config', testConfigFile, '--oss'], {
child = spawn(process.execPath, [kibanaPath, '--config', testConfigFile, '--oss', '--verbose'], {
stdio: 'pipe'
});

Expand Down Expand Up @@ -114,7 +114,9 @@ describe('Server logging configuration', function () {
const data = JSON.parse(line);
sawJson = true;

if (data.tags.includes('listening')) {
// We know the sighup handler will be registered before
// root.setup() is called
if (data.message.includes('setting up root')) {
isJson = false;
setLoggingJson(false);

Expand All @@ -128,10 +130,9 @@ describe('Server logging configuration', function () {
// the switch yet, so we ignore before switching over.
} else {
// Kibana has successfully stopped logging json, so kill the server.

sawNonjson = true;

child.kill();
child && child.kill();
child = undefined;
}
})
Expand Down Expand Up @@ -178,10 +179,11 @@ describe('Server logging configuration', function () {
'--config', testConfigFile,
'--logging.dest', logPath,
'--plugins.initialize', 'false',
'--logging.json', 'false'
'--logging.json', 'false',
'--verbose'
]);

watchFileUntil(logPath, /http server running/, 2 * minute)
watchFileUntil(logPath, /starting server/, 2 * minute)
rudolf marked this conversation as resolved.
Show resolved Hide resolved
.then(() => {
// once the server is running, archive the log file and issue SIGHUP
fs.renameSync(logPath, logPathArchived);
Expand All @@ -190,8 +192,8 @@ describe('Server logging configuration', function () {
.then(() => watchFileUntil(logPath, /Reloaded logging configuration due to SIGHUP/, 10 * second))
.then(contents => {
const lines = contents.toString().split('\n');
// should be the first and only new line of the log file
expect(lines).toHaveLength(2);
// should be the first line of the new log file
expect(lines[0]).toMatch(/Reloaded logging configuration due to SIGHUP/);
child.kill();
})
.then(done, done);
Expand Down
5 changes: 3 additions & 2 deletions src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export default function (program) {
.option('--plugins <path>', 'an alias for --plugin-dir', pluginDirCollector)
.option('--optimize', 'Optimize and then stop the server');


if (CAN_REPL) {
command.option('--repl', 'Run the server with a REPL prompt and access to the server object');
}
Expand All @@ -211,7 +210,8 @@ export default function (program) {
.option('--ssl', 'Run the dev server using HTTPS')
.option('--no-base-path', '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-dev-config', 'Prevents loading the kibana.dev.yml file in --dev mode');
.option('--no-dev-config', 'Prevents loading the kibana.dev.yml file in --dev mode')
.option('--skip-migrations', 'Don\'t run Saved Object migrations (testing only)');
}

command
Expand Down Expand Up @@ -241,6 +241,7 @@ export default function (program) {
basePath: !!opts.basePath,
optimize: !!opts.optimize,
oss: !!opts.oss,
skipMigrations: !!opts.skipMigrations,
},
features: {
isClusterModeSupported: CAN_CLUSTER,
Expand Down
32 changes: 16 additions & 16 deletions src/core/server/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ export async function bootstrap({

const root = new Root(rawConfigService.getConfig$(), env, onRootShutdown);

process.on('SIGHUP', () => {
const cliLogger = root.logger.get('cli');
cliLogger.info('Reloading logging configuration due to SIGHUP.', { tags: ['config'] });

try {
rawConfigService.reloadConfig();
} catch (err) {
return shutdown(err);
}

cliLogger.info('Reloaded logging configuration due to SIGHUP.', { tags: ['config'] });
});

process.on('SIGINT', () => shutdown());
process.on('SIGTERM', () => shutdown());

function shutdown(reason?: Error) {
rawConfigService.stop();
return root.shutdown(reason);
Expand All @@ -87,22 +103,6 @@ export async function bootstrap({
cliLogger.info('Optimization done.');
await shutdown();
}

process.on('SIGHUP', () => {
const cliLogger = root.logger.get('cli');
cliLogger.info('Reloading logging configuration due to SIGHUP.', { tags: ['config'] });

try {
rawConfigService.reloadConfig();
} catch (err) {
return shutdown(err);
}

cliLogger.info('Reloaded logging configuration due to SIGHUP.', { tags: ['config'] });
});

process.on('SIGINT', () => shutdown());
process.on('SIGTERM', () => shutdown());
}

function onRootShutdown(reason?: any) {
Expand Down
1 change: 1 addition & 0 deletions src/core/server/config/__mocks__/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function getEnvOptions(options: DeepPartial<EnvOptions> = {}): EnvOptions
basePath: false,
optimize: false,
oss: false,
skipMigrations: false,
...(options.cliArgs || {}),
},
isDevClusterMaster:
Expand Down
6 changes: 6 additions & 0 deletions src/core/server/config/__snapshots__/env.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/core/server/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface CliArgs {
optimize: boolean;
open: boolean;
oss: boolean;
skipMigrations: boolean;
}

export class Env {
Expand Down
Loading