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

License removal leads back to a basic license #52407

Merged
merged 9 commits into from
Feb 21, 2020

Conversation

ywangd
Copy link
Member

@ywangd ywangd commented Feb 17, 2020

A new basic license will be generated when existing license is deleted.
In addition, deleting an existing basic license is a no-op.

Resolves: #45022

@ywangd ywangd added >enhancement :Security/License License functionality for commercial features v8.0.0 v7.7.0 labels Feb 17, 2020
@ywangd ywangd requested a review from tvernum February 17, 2020 12:19
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security (:Security/License)

@tvernum
Copy link
Contributor

tvernum commented Feb 18, 2020

@bytebilly FYI

License selfGeneratedLicense = SelfGeneratedLicense.create(specBuilder, currentState.nodes());
LicensesMetaData newLicensesMetadata = new LicensesMetaData(selfGeneratedLicense,
currentLicensesMetadata == null ? null : currentLicensesMetadata.getMostRecentTrialVersion());
mdBuilder.putCustom(LicensesMetaData.TYPE, newLicensesMetadata);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we merge this code and the duplicate from StartBasicClusterTask into a single generateNewBasicLicense() method?

@ywangd ywangd requested a review from tvernum February 18, 2020 21:37
final StartBasicClusterTask startBasicClusterTask =
new StartBasicClusterTask(logger, clusterService.getClusterName().value(), clock,
new PostStartBasicRequest().acknowledge(true), null);
return startBasicClusterTask.execute(currentState);
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels weird to me.
We run a task, that just creates another task and executes that, and it feels like that's just so we can change the response object.

Why not change this to something like:

public void removeLicense(final DeleteLicenseRequest request, final ActionListener<PostStartBasicResponse> listener) {
      PostStartBasicRequest startBasicRequest = new PostStartBasicRequest().acknowledge(true);
      startBasicLicense(startBasicRequest, listener); 
}

and then have the Transport action translate the PostStartBasicResponse into the AcknowledgedResponse it needs to keep compatibilty with the API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. I'll update it with a small change: instead of delegating to startBasicLicense() method, I'll keep the task submission part so that the context is not lost, i.e. clusterService.submitStateUpdateTask("delete license", new StartBasicClusterTask(...))

@ywangd ywangd requested a review from tvernum February 21, 2020 02:50
@ywangd ywangd merged commit 0d62213 into elastic:master Feb 21, 2020
ywangd added a commit to ywangd/elasticsearch that referenced this pull request Feb 23, 2020
A new basic license will be generated when existing license is deleted.
In addition, deleting an existing basic license is a no-op.

Resolves: elastic#45022
ywangd added a commit that referenced this pull request Feb 24, 2020
A new basic license will be generated when existing license is deleted.
In addition, deleting an existing basic license is a no-op.

Resolves: #45022
@ywangd
Copy link
Member Author

ywangd commented Feb 24, 2020

backported:

  • v7.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Security/License License functionality for commercial features v7.7.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revert to Basic license when license is deleted
4 participants