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

Support "enterprise" license types #49223

Merged
merged 4 commits into from
Nov 20, 2019

Conversation

tvernum
Copy link
Contributor

@tvernum tvernum commented Nov 18, 2019

This adds "enterprise" as an acceptable type for a license loaded
through the PUT _license API.

Internally an enterprise license is treated as having a "platinum"
operating mode.

The handling of License types was refactored to have a new explicit
"LicenseType" enum in addition to the existing "OperatingMode" enum.

Relates: #48510

This adds "enterprise" as an acceptable type for a license loaded
through the PUT _license API.

Internally an enterprise license is treated as having a "platinum"
operating mode.

The handling of License types was refactored to have a new explicit
"LicenseType" enum in addition to the existing "OperatingMode" enum.
@tvernum tvernum added >enhancement :Security/License License functionality for commercial features v8.0.0 v7.6.0 labels Nov 18, 2019
@elasticmachine
Copy link
Collaborator

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

@tvernum
Copy link
Contributor Author

tvernum commented Nov 18, 2019

Notes:

  1. This does not include support for reading the ECE license structure (which is labelled "enterprise" but is a different JSON format)
  2. This maps to the "platinum" operating mode, so as currently implemented, it is not possible to tie any ES functionality to the enterprise license type.
  3. This does not have a compatibility mode that would return "platinum" for older clients (but we will need to add one).

Copy link
Member

@jkakavas jkakavas left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -88,6 +88,9 @@ protected void execute(Terminal terminal, OptionSet options) throws Exception {
ExitCodes.USAGE,
"Must specify either --license or --licenseFile");
}
if (licenseSpec == null) {
throw new UserException(ExitCodes.DATA_ERROR, "Could parse license spec");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
throw new UserException(ExitCodes.DATA_ERROR, "Could parse license spec");
throw new UserException(ExitCodes.DATA_ERROR, "Could not parse license spec");

case "cloud_internal":
case "internal": // bwc for 1.x subscription_type field
case PLATINUM:
case ENTERPRISE: // TODO Add an explicit platinum operating mode
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
case ENTERPRISE: // TODO Add an explicit platinum operating mode
case ENTERPRISE: // TODO Add an explicit enterprise operating mode


private static boolean licenseIsCompatible(License license, Version version) {
if (License.LicenseType.ENTERPRISE.getTypeName().equalsIgnoreCase(license.type())) {
return version.onOrAfter(Version.V_8_0_0);
Copy link
Member

Choose a reason for hiding this comment

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

IIRC the suggested approach is to use the targeted version here and set bwc_enabled to false in build.gradle until the backporting PR is merged

@@ -337,9 +346,10 @@ private LicensesMetaData getLicensesMetaData() {
}

void startTrialLicense(PostStartTrialRequest request, final ActionListener<PostStartTrialResponse> listener) {
if (VALID_TRIAL_TYPES.contains(request.getType()) == false) {
License.LicenseType requestedType = License.LicenseType.parse(request.getType());
if (VALID_TRIAL_TYPES.contains(requestedType) == false) {
throw new IllegalArgumentException("Cannot start trial of type [" + request.getType() + "]. Valid trial types are "
Copy link
Member

Choose a reason for hiding this comment

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

request.getType() to requestedType.getTypeName() ?

@jkakavas
Copy link
Member

Do we really need LicenceType and OperatingMode nowadays? Should we merge those in a followup?

@tvernum
Copy link
Contributor Author

tvernum commented Nov 20, 2019

Do we really need LicenceType and OperatingMode nowadays?

No, I don't think we do, but all this BWC stuff in licensing is getting a bit crazy. We ought to look at cleaning up a bunch of stuff for 8.0

@tvernum tvernum merged commit 31512fb into elastic:master Nov 20, 2019
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Nov 22, 2019
This adds "enterprise" as an acceptable type for a license loaded
through the PUT _license API.

Internally an enterprise license is treated as having a "platinum"
operating mode.

The handling of License types was refactored to have a new explicit
"LicenseType" enum in addition to the existing "OperatingMode" enum.

Backport of: elastic#49223
@pebrc pebrc mentioned this pull request Dec 1, 2019
2 tasks
@six5532one
Copy link

six5532one commented Dec 10, 2019

@tvernum I'm planning to add the changes to ECE to install the new "enterprise" stack license in ECE clusters with stack version >= 7.6 (https://github.com/elastic/cloud/issues/43639). I have a few questions to make sure we're on the same page.

You mentioned in a comment above:

This does not include support for reading the ECE license structure (which is labelled "enterprise" but is a different JSON format)

My understanding is the Elasticsearch API supports PUT requests with a payload like

{
                "license": {
                    "uid": "55ec27dc-b2d6-455c-b985-1e06fa77062a",
                    "type": "platinum",
                    "issue_date_in_millis": 1559779200000,
                    "expiry_date_in_millis": 1591574399999,
                    "max_nodes": 100,
                    "issued_to": "Elastic - INTERNAL",
                    "issuer": "Shane Connelly",
                    "signature": "redacted",
                    "start_date_in_millis": 1590969600000
                }
            }

The ECE license bundles stack licenses with this format. Currently, ECE installs stack licenses by making a PUT request against the ES API with a payload that has the same structure as the JSON pasted above. My understanding is, in order for ECE to support the new "enterprise" stack license on v7.6+, it will continue to install stack licenses with the payload structure shown above, but the value of the "type" field will be "enterprise". According to my understanding, license update requests from ECE will not be using a different JSON format. I wanted to make sure there isn't a misunderstanding on my end.

For reference, here is a sample ECE license (which at some point will include an enterprise stack license in "cluster_licenses":

{
    "license": {
        "uid": "748f2afe-ec9c-4b93-a04f-0d3588e1ee68",
        "type": "enterprise",
        "issue_date_in_millis": 1559779200000,
        "start_date_in_millis": 1559779200000,
        "expiry_date_in_millis": 1591574399999,
        "max_instances": 100,
        "issued_to": "Elastic - INTERNAL",
        "issuer": "Shane Connelly",
        "signature": "redacted",
        "cluster_licenses": [
            {
                "license": {
                    "uid": "17641883-1229-4494-ac1c-66bd3ddb6b76",
                    "type": "standard",
                    "issue_date_in_millis": 1559779200000,
                    "expiry_date_in_millis": 1601510399999,
                    "max_nodes": 100,
                    "issued_to": "Elastic - INTERNAL",
                    "issuer": "Shane Connelly",
                    "signature": "redacted",
                    "start_date_in_millis": 1559779200000
                }
            },
            {
                "license": {
                    "uid": "1ef5250f-5068-49fc-8a7b-86755a3635d3",
                    "type": "gold",
                    "issue_date_in_millis": 1559779200000,
                    "expiry_date_in_millis": 1601510399999,
                    "max_nodes": 100,
                    "issued_to": "Elastic - INTERNAL",
                    "issuer": "Shane Connelly",
                    "signature": "redacted",
                    "start_date_in_millis": 1559779200000
                }
            },
            {
                "license": {
                    "uid": "6c3d2bb1-dee1-4946-b41c-0fdce75990e9",
                    "type": "platinum",
                    "issue_date_in_millis": 1559779200000,
                    "expiry_date_in_millis": 1601510399999,
                    "max_nodes": 100,
                    "issued_to": "Elastic - INTERNAL",
                    "issuer": "Shane Connelly",
                    "signature": "redacted",
                    "start_date_in_millis": 1559779200000
                }
            },
            {
                "license": {
                    "uid": "05d83147-d2b2-43fe-8087-fecddf34ca85",
                    "type": "standard",
                    "issue_date_in_millis": 1559779200000,
                    "expiry_date_in_millis": 1591574399999,
                    "max_nodes": 100,
                    "issued_to": "Elastic - INTERNAL",
                    "issuer": "Shane Connelly",
                    "signature": "redacted",
                    "start_date_in_millis": 1590969600000
                }
            },
            {
                "license": {
                    "uid": "55ec27dc-b2d6-455c-b985-1e06fa77062a",
                    "type": "gold",
                    "issue_date_in_millis": 1559779200000,
                    "expiry_date_in_millis": 1591574399999,
                    "max_nodes": 100,
                    "issued_to": "Elastic - INTERNAL",
                    "issuer": "Shane Connelly",
                    "signature": "redacted",
                    "start_date_in_millis": 1590969600000
                }
            },
            {
                "license": {
                    "uid": "6080ab72-75e1-4d3f-911c-237928c8dfa6",
                    "type": "platinum",
                    "issue_date_in_millis": 1559779200000,
                    "expiry_date_in_millis": 1591574399999,
                    "max_nodes": 100,
                    "issued_to": "Elastic - INTERNAL",
                    "issuer": "Shane Connelly",
                    "signature": "redacted",
                    "start_date_in_millis": 1590969600000
                }
            }
        ]
    }
}```

@six5532one
Copy link

ECE currently makes a PUT /_xpack/license request. Should we migrate to PUT /_license instead? Do you know which ES versions support PUT /_license?

tvernum added a commit that referenced this pull request Dec 12, 2019
This adds "enterprise" as an acceptable type for a license loaded
through the PUT _license API.

Internally an enterprise license is treated as having a "platinum"
operating mode.

The handling of License types was refactored to have a new explicit
"LicenseType" enum in addition to the existing "OperatingMode" enum.

By default (in 7.x) the GET license API will return "platinum" when an
enterprise license is active in order to be compatible with existing
consumers of that API.
A new "accept_enterprise" flag has been introduced to allow clients to
opt-in to receive the correct "enterprise" type.

Backport of: #49223
russcam added a commit to elastic/elasticsearch-net that referenced this pull request Feb 21, 2020
Relates: #4341, elastic/elasticsearch#49223, elastic/elasticsearch#50735

This commit adds support for Enterprise LicenseType,
and adds max_resource_units to GetLicenseResponse.
Mpdreamz pushed a commit to elastic/elasticsearch-net that referenced this pull request Feb 21, 2020
Relates: #4341, elastic/elasticsearch#49223, elastic/elasticsearch#50735

This commit adds support for Enterprise LicenseType,
and adds max_resource_units to GetLicenseResponse.
github-actions bot pushed a commit to elastic/elasticsearch-net that referenced this pull request Feb 21, 2020
Relates: #4341, elastic/elasticsearch#49223, elastic/elasticsearch#50735

This commit adds support for Enterprise LicenseType,
and adds max_resource_units to GetLicenseResponse.
Mpdreamz pushed a commit to elastic/elasticsearch-net that referenced this pull request Feb 21, 2020
Relates: #4341, elastic/elasticsearch#49223, elastic/elasticsearch#50735

This commit adds support for Enterprise LicenseType,
and adds max_resource_units to GetLicenseResponse.

Co-authored-by: Russ Cam <russ.cam@elastic.co>
russcam added a commit to elastic/elasticsearch-net that referenced this pull request Feb 23, 2020
Relates: #4341, elastic/elasticsearch#49223, elastic/elasticsearch#50735

This commit adds support for Enterprise LicenseType,
and adds max_resource_units to GetLicenseResponse.

(cherry picked from commit c737df6)
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.6.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants