Skip to content

Commit 3c4d76a

Browse files
committed
Remove grace period from license expiration check (#67316)
License expiration checking currently has a 7 day grace period. When a license expires, the licensing code acts as if it is not yet expired. This was originally intended to protect users who may accidentally end up letting their license expire from the pain of their licensed features ceasing to work. However, the grace period effectively shifts the license expiration by a week, resulting in confusion since the actual license expiration date is not accurate. It also is less of a concern now as not only do we emit several warnings for upcoming license expiration, but the new license can be downloaded and installed quickly by the user through the support portal. This commit removes the license grace period altogether.
1 parent 2fde28e commit 3c4d76a

File tree

3 files changed

+5
-47
lines changed

3 files changed

+5
-47
lines changed

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

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste
7878
static final Set<License.LicenseType> VALID_TRIAL_TYPES = Collections.unmodifiableSet(Sets.newHashSet(
7979
License.LicenseType.GOLD, License.LicenseType.PLATINUM, License.LicenseType.ENTERPRISE, License.LicenseType.TRIAL));
8080

81-
/**
82-
* Duration of grace period after a license has expired
83-
*/
84-
static final TimeValue GRACE_PERIOD_DURATION = days(7);
85-
8681
/**
8782
* Period before the license expires when warning starts being added to the response header
8883
*/
@@ -193,16 +188,9 @@ public void on(License license) {
193188
logExpirationWarning(license.expiryDate(), false);
194189
}
195190
});
196-
expirationCallbacks.add(new ExpirationCallback.Pre(days(0), days(7), TimeValue.timeValueMinutes(10)) {
197-
@Override
198-
public void on(License license) {
199-
logExpirationWarning(license.expiryDate(), false);
200-
}
201-
});
202191
expirationCallbacks.add(new ExpirationCallback.Post(days(0), null, TimeValue.timeValueMinutes(10)) {
203192
@Override
204193
public void on(License license) {
205-
// logged when grace period begins
206194
logExpirationWarning(license.expiryDate(), true);
207195
}
208196
});
@@ -487,22 +475,16 @@ protected void updateLicenseState(final License license, Version mostRecentTrial
487475
}
488476
if (license != null) {
489477
long time = clock.millis();
490-
boolean active;
478+
final boolean active;
491479
if (license.expiryDate() == BASIC_SELF_GENERATED_LICENSE_EXPIRATION_MILLIS) {
492480
active = true;
493481
} else {
494-
// We subtract the grace period from the current time to avoid overflowing on an expiration
495-
// date that is near Long.MAX_VALUE
496-
active = time >= license.issueDate() && time - GRACE_PERIOD_DURATION.getMillis() < license.expiryDate();
482+
active = time >= license.issueDate() && time < license.expiryDate();
497483
}
498484
licenseState.update(license.operationMode(), active, license.expiryDate(), mostRecentTrialVersion);
499485

500486
if (active) {
501-
if (time < license.expiryDate()) {
502-
logger.debug("license [{}] - valid", license.uid());
503-
} else {
504-
logger.warn("license [{}] - grace", license.uid());
505-
}
487+
logger.debug("license [{}] - valid", license.uid());
506488
} else {
507489
logger.warn("license [{}] - expired", license.uid());
508490
}
@@ -553,8 +535,6 @@ static SchedulerEngine.Schedule nextLicenseCheck(License license) {
553535
return license.issueDate();
554536
} else if (time < license.expiryDate()) {
555537
return license.expiryDate();
556-
} else if (time < license.expiryDate() + GRACE_PERIOD_DURATION.getMillis()) {
557-
return license.expiryDate() + GRACE_PERIOD_DURATION.getMillis();
558538
}
559539
return -1; // license is expired, no need to check again
560540
};

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,8 @@ public void testEnabledLicenseSchedule() throws Exception {
3030
assertThat(schedule.nextScheduledTimeAfter(license.issueDate(), triggeredTime), equalTo(license.expiryDate()));
3131
}
3232

33-
public void testGraceLicenseSchedule() throws Exception {
34-
long triggeredTime = license.expiryDate() + between(1,
35-
((int) LicenseService.GRACE_PERIOD_DURATION.getMillis()));
36-
assertThat(schedule.nextScheduledTimeAfter(license.issueDate(), triggeredTime),
37-
equalTo(license.expiryDate() + LicenseService.GRACE_PERIOD_DURATION.getMillis()));
38-
}
39-
4033
public void testExpiredLicenseSchedule() throws Exception {
41-
long triggeredTime = license.expiryDate() + LicenseService.GRACE_PERIOD_DURATION.getMillis() +
42-
randomIntBetween(1, 1000);
34+
long triggeredTime = license.expiryDate() + randomIntBetween(1, 1000);
4335
assertThat(schedule.nextScheduledTimeAfter(license.issueDate(), triggeredTime),
4436
equalTo(-1L));
4537
}

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,12 @@ public void testClusterRestartWhileEnabled() throws Exception {
126126
assertLicenseActive(true);
127127
}
128128

129-
public void testClusterRestartWhileGrace() throws Exception {
130-
wipeAllLicenses();
131-
internalCluster().startNode();
132-
assertLicenseActive(true);
133-
putLicense(TestUtils.generateSignedLicense(TimeValue.timeValueMillis(0)));
134-
ensureGreen();
135-
assertLicenseActive(true);
136-
logger.info("--> restart node");
137-
internalCluster().fullRestart();
138-
ensureYellow();
139-
logger.info("--> await node for grace_period");
140-
assertLicenseActive(true);
141-
}
142-
143129
public void testClusterRestartWhileExpired() throws Exception {
144130
wipeAllLicenses();
145131
internalCluster().startNode();
146132
ensureGreen();
147133
assertLicenseActive(true);
148-
putLicense(TestUtils.generateExpiredNonBasicLicense(System.currentTimeMillis() - LicenseService.GRACE_PERIOD_DURATION.getMillis()));
134+
putLicense(TestUtils.generateExpiredNonBasicLicense(System.currentTimeMillis()));
149135
assertLicenseActive(false);
150136
logger.info("--> restart node");
151137
internalCluster().fullRestart();

0 commit comments

Comments
 (0)