Skip to content

Commit 4735260

Browse files
authored
Bump TrialLicenseVersion to allow starting new trial on 9.0 (elastic#120198)
You are allowed to initiate a trial only if your cluster has not already activated a trial for the current major product version. For example, if you have already activated a trial for v6.0, you cannot start a new trial until v7.0. `LicensesMetadata` is a ClusterState custom that contains the license information for a cluster. If the cluster has exercised a trial there is a trial version field populated. During a major upgrade, we want to allow users to run a new trial to test the features on the new major. This PR updates the trial version in the license to allow to start a new trial on 9.0. When 9.0 is released we'll have no clusters that has already exercised the trial so this PR also removes some of the BWC handling that was added when [trial license version was decoupled from stack version](elastic#100169).
1 parent 0317c1c commit 4735260

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

docs/changelog/120198.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 120198
2+
summary: Bump `TrialLicenseVersion` to allow starting new trial on 9.0
3+
area: License
4+
type: enhancement
5+
issues: []

x-pack/plugin/core/src/main/java/org/elasticsearch/license/internal/TrialLicenseVersion.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ public class TrialLicenseVersion implements ToXContentFragment, Writeable {
2727
// generic Elasticsearch version. While it's derived from the Elasticsearch version formula for BWC, it is independent of it going
2828
// forward. When we want users to be able to start a new trial, increment this number.
2929
// Pkg-private for testing only.
30-
static final int TRIAL_VERSION_CUTOVER = 8_12_00_99;
31-
public static final TrialLicenseVersion CURRENT = new TrialLicenseVersion(TRIAL_VERSION_CUTOVER);
32-
33-
// The most recently released major version when we cut over. Here for maintaining BWC behavior.
34-
static final int TRIAL_VERSION_CUTOVER_MAJOR = 8;
30+
static final int CURRENT_TRIAL_VERSION = 9_00_00_00;
31+
public static final TrialLicenseVersion CURRENT = new TrialLicenseVersion(CURRENT_TRIAL_VERSION);
3532

3633
private final int trialVersion;
3734

@@ -84,10 +81,6 @@ int asInt() {
8481
public boolean ableToStartNewTrial() {
8582
assert trialVersion <= CURRENT.trialVersion
8683
: "trial version [" + trialVersion + "] cannot be greater than CURRENT [" + CURRENT.trialVersion + "]";
87-
if (trialVersion < TRIAL_VERSION_CUTOVER) {
88-
int sinceMajorVersion = trialVersion / 1_000_000; // integer division is intentional
89-
return sinceMajorVersion < TRIAL_VERSION_CUTOVER_MAJOR;
90-
}
9184
return trialVersion != CURRENT.trialVersion;
9285
}
9386

x-pack/plugin/core/src/test/java/org/elasticsearch/license/internal/TrialLicenseVersionTests.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,17 @@
1111
import org.elasticsearch.test.ESTestCase;
1212

1313
import static org.elasticsearch.license.internal.TrialLicenseVersion.CURRENT;
14-
import static org.elasticsearch.license.internal.TrialLicenseVersion.TRIAL_VERSION_CUTOVER;
15-
import static org.elasticsearch.license.internal.TrialLicenseVersion.TRIAL_VERSION_CUTOVER_MAJOR;
14+
import static org.elasticsearch.license.internal.TrialLicenseVersion.CURRENT_TRIAL_VERSION;
1615
import static org.hamcrest.Matchers.equalTo;
1716

1817
public class TrialLicenseVersionTests extends ESTestCase {
1918

2019
public void testCanParseAllVersions() {
2120
for (var version : Version.getDeclaredVersions(Version.class)) {
2221
// Only consider versions before the cut-over; the comparison becomes meaningless after the cut-over point
23-
if (version.onOrBefore(Version.fromId(TRIAL_VERSION_CUTOVER))) {
22+
if (version.onOrBefore(Version.fromId(CURRENT_TRIAL_VERSION))) {
2423
TrialLicenseVersion parsedVersion = TrialLicenseVersion.fromXContent(version.toString());
25-
if (version.major < TRIAL_VERSION_CUTOVER_MAJOR) {
26-
assertTrue(parsedVersion.ableToStartNewTrial());
27-
} else {
28-
assertFalse(parsedVersion.ableToStartNewTrial());
29-
}
24+
assertTrue(parsedVersion.ableToStartNewTrial());
3025
}
3126
}
3227
}
@@ -38,9 +33,10 @@ public void testRoundTripParsing() {
3833

3934
public void testNewTrialAllowed() {
4035
assertTrue(new TrialLicenseVersion(randomIntBetween(7_00_00_00, 7_99_99_99)).ableToStartNewTrial());
36+
assertTrue(new TrialLicenseVersion(randomIntBetween(8_00_00_00, 8_99_99_99)).ableToStartNewTrial());
4137
assertFalse(new TrialLicenseVersion(CURRENT.asInt()).ableToStartNewTrial());
42-
assertFalse(new TrialLicenseVersion(randomIntBetween(8_00_00_00, TRIAL_VERSION_CUTOVER)).ableToStartNewTrial());
43-
final int trialVersion = randomIntBetween(TRIAL_VERSION_CUTOVER, CURRENT.asInt());
38+
assertFalse(new TrialLicenseVersion(randomIntBetween(9_00_00_00, CURRENT_TRIAL_VERSION)).ableToStartNewTrial());
39+
final int trialVersion = randomIntBetween(CURRENT_TRIAL_VERSION, CURRENT.asInt());
4440
if (trialVersion < CURRENT.asInt()) {
4541
assertTrue(new TrialLicenseVersion(trialVersion).ableToStartNewTrial());
4642
} else {

0 commit comments

Comments
 (0)