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

Add x-pack plugin for new platform browser licensing information #44922

Closed
wants to merge 15 commits into from

Conversation

eliperelman
Copy link
Contributor

@eliperelman eliperelman commented Sep 5, 2019

Summary

Add x-pack plugin for new platform client licensing information. This will eventually replace the licensing information consumed via xpack_main.

Also fixes #44560

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

Dev Docs

Add x-pack plugin for new platform public licensing information. This will eventually replace the licensing information consumed via xpack_main. Upon setup, this plugin exposes an observable API for inspecting and making checks against the license information.

license$.subscribe(license => {
   console.log(license.uid);
   console.log(license.isActive);
   console.log(license.type);

   const { state } = license.check('my-plugin', LICENSE_TYPE.gold);

   if (state !== LICENSE_STATUS.Valid) {
     disableSomething();
   }
});

@eliperelman eliperelman added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. v8.0.0 v7.5.0 labels Sep 5, 2019
@eliperelman eliperelman requested a review from a team September 5, 2019 18:24
@eliperelman eliperelman self-assigned this Sep 5, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@eliperelman eliperelman force-pushed the licensing-plugin-client branch from 80988dd to 958be47 Compare September 5, 2019 18:26
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@joshdover joshdover left a comment

Choose a reason for hiding this comment

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

Some initial things I noticed. Still need to dig into actual behavior to verify correctness.

x-pack/plugins/licensing/common/license.ts Outdated Show resolved Hide resolved
x-pack/plugins/licensing/public/plugin.ts Outdated Show resolved Hide resolved
x-pack/plugins/licensing/public/plugin.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@mshustov mshustov left a comment

Choose a reason for hiding this comment

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

are we okay provide not backward compatible interface? if yes we can cleanup some other interfaces as well

x-pack/plugins/licensing/server/plugin.ts Show resolved Hide resolved
x-pack/plugins/licensing/server/plugin.ts Outdated Show resolved Hide resolved
x-pack/plugins/licensing/common/license.ts Outdated Show resolved Hide resolved
x-pack/plugins/licensing/public/license.test.ts Outdated Show resolved Hide resolved
x-pack/plugins/licensing/public/plugin.ts Outdated Show resolved Hide resolved
x-pack/plugins/licensing/public/plugin.ts Outdated Show resolved Hide resolved
x-pack/plugins/licensing/common/license.ts Show resolved Hide resolved
@eliperelman
Copy link
Contributor Author

are we okay provide not backward compatible interface? if yes we can cleanup some other interfaces as well

#43376.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@eliperelman eliperelman force-pushed the licensing-plugin-client branch from 958be47 to 3034061 Compare September 27, 2019 19:28
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@eliperelman eliperelman force-pushed the licensing-plugin-client branch from 3034061 to 970da28 Compare October 1, 2019 16:39
@elasticmachine
Copy link
Contributor

💔 Build Failed

@eliperelman eliperelman force-pushed the licensing-plugin-client branch from 970da28 to e54f5f6 Compare October 2, 2019 16:55
@elasticmachine
Copy link
Contributor

💔 Build Failed

@eliperelman eliperelman force-pushed the licensing-plugin-client branch from e54f5f6 to 8ffe6b7 Compare October 3, 2019 20:25
@joshdover joshdover requested review from a team as code owners October 3, 2019 20:25
@joshdover joshdover requested a review from a team October 3, 2019 20:25
@joshdover joshdover requested review from a team as code owners October 3, 2019 20:25
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@eliperelman eliperelman force-pushed the licensing-plugin-client branch from a724142 to de94fe1 Compare October 16, 2019 15:43
@elasticmachine
Copy link
Contributor

💔 Build Failed

@eliperelman eliperelman force-pushed the licensing-plugin-client branch from de94fe1 to a4678bc Compare October 17, 2019 17:04
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

clusterSource,
pollingFrequency
try {
const cluster = await this.elasticsearch.dataClient$.pipe(first()).toPromise();
Copy link
Contributor

Choose a reason for hiding this comment

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

plugin config specified clusterSource, but plugin always uses data client.
also legacy config doesn't allow to specify client name

xpack_api_polling_frequency_millis: Joi.number().default(XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS),

const cluster = await this.elasticsearch.dataClient$.pipe(first()).toPromise();
const response = await cluster.callAsInternalUser('transport.request', {
method: 'GET',
path: '/_xpack',
Copy link
Contributor

Choose a reason for hiding this comment

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

/_xpack is deprecated and will be removed in v8.elastic/elasticsearch#35958
we should switch to /_license

method: 'GET',
path: '/_xpack',
});
const rawLicense = response && response.license;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a real case when the server responds with empty data?
As I can see ES returns "Not Found" error if a user has no license https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/license/RestGetLicenseAction.java#L76

/**
* Used to trigger manual fetches of the license information from the server.
*/
private refresher$ = new BehaviorSubject(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

not connected.

/**
* Generate the signature for a serialized/stringified license.
*/
function sign(serialized: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should be provided as a part of plugin API

);
const setup = {
refresh: () => this.refresher$.next(true),
license$: initial$,
Copy link
Contributor

Choose a reason for hiding this comment

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

new subscriber causes a data refetch

@joshdover joshdover mentioned this pull request Oct 23, 2019
@mshustov mshustov mentioned this pull request Oct 25, 2019
3 tasks
@mshustov
Copy link
Contributor

mshustov commented Oct 25, 2019

superseded by #49345

@mshustov mshustov closed this Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.5.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing test: Jest Tests.src/core/utils - Poller executes a function on an interval
4 participants