diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java index a1d15800a6181..effcbaf782386 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java @@ -77,11 +77,6 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste static final Set VALID_TRIAL_TYPES = Set.of( License.LicenseType.GOLD, License.LicenseType.PLATINUM, License.LicenseType.ENTERPRISE, License.LicenseType.TRIAL); - /** - * Duration of grace period after a license has expired - */ - static final TimeValue GRACE_PERIOD_DURATION = days(7); - /** * Period before the license expires when warning starts being added to the response header */ @@ -192,16 +187,9 @@ public void on(License license) { logExpirationWarning(license.expiryDate(), false); } }); - expirationCallbacks.add(new ExpirationCallback.Pre(days(0), days(7), TimeValue.timeValueMinutes(10)) { - @Override - public void on(License license) { - logExpirationWarning(license.expiryDate(), false); - } - }); expirationCallbacks.add(new ExpirationCallback.Post(days(0), null, TimeValue.timeValueMinutes(10)) { @Override public void on(License license) { - // logged when grace period begins logExpirationWarning(license.expiryDate(), true); } }); @@ -486,22 +474,16 @@ protected void updateLicenseState(final License license, Version mostRecentTrial } if (license != null) { long time = clock.millis(); - boolean active; + final boolean active; if (license.expiryDate() == BASIC_SELF_GENERATED_LICENSE_EXPIRATION_MILLIS) { active = true; } else { - // We subtract the grace period from the current time to avoid overflowing on an expiration - // date that is near Long.MAX_VALUE - active = time >= license.issueDate() && time - GRACE_PERIOD_DURATION.getMillis() < license.expiryDate(); + active = time >= license.issueDate() && time < license.expiryDate(); } licenseState.update(license.operationMode(), active, license.expiryDate(), mostRecentTrialVersion); if (active) { - if (time < license.expiryDate()) { - logger.debug("license [{}] - valid", license.uid()); - } else { - logger.warn("license [{}] - grace", license.uid()); - } + logger.debug("license [{}] - valid", license.uid()); } else { logger.warn("license [{}] - expired", license.uid()); } @@ -552,8 +534,6 @@ static SchedulerEngine.Schedule nextLicenseCheck(License license) { return license.issueDate(); } else if (time < license.expiryDate()) { return license.expiryDate(); - } else if (time < license.expiryDate() + GRACE_PERIOD_DURATION.getMillis()) { - return license.expiryDate() + GRACE_PERIOD_DURATION.getMillis(); } return -1; // license is expired, no need to check again }; diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseScheduleTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseScheduleTests.java index 2fba2358a281c..d607f27069313 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseScheduleTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseScheduleTests.java @@ -30,16 +30,8 @@ public void testEnabledLicenseSchedule() throws Exception { assertThat(schedule.nextScheduledTimeAfter(license.issueDate(), triggeredTime), equalTo(license.expiryDate())); } - public void testGraceLicenseSchedule() throws Exception { - long triggeredTime = license.expiryDate() + between(1, - ((int) LicenseService.GRACE_PERIOD_DURATION.getMillis())); - assertThat(schedule.nextScheduledTimeAfter(license.issueDate(), triggeredTime), - equalTo(license.expiryDate() + LicenseService.GRACE_PERIOD_DURATION.getMillis())); - } - public void testExpiredLicenseSchedule() throws Exception { - long triggeredTime = license.expiryDate() + LicenseService.GRACE_PERIOD_DURATION.getMillis() + - randomIntBetween(1, 1000); + long triggeredTime = license.expiryDate() + randomIntBetween(1, 1000); assertThat(schedule.nextScheduledTimeAfter(license.issueDate(), triggeredTime), equalTo(-1L)); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java index 77bb09958513c..e23aab25e7bc3 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseServiceClusterTests.java @@ -121,26 +121,12 @@ public void testClusterRestartWhileEnabled() throws Exception { assertLicenseActive(true); } - public void testClusterRestartWhileGrace() throws Exception { - wipeAllLicenses(); - internalCluster().startNode(); - assertLicenseActive(true); - putLicense(TestUtils.generateSignedLicense(TimeValue.timeValueMillis(0))); - ensureGreen(); - assertLicenseActive(true); - logger.info("--> restart node"); - internalCluster().fullRestart(); - ensureYellow(); - logger.info("--> await node for grace_period"); - assertLicenseActive(true); - } - public void testClusterRestartWhileExpired() throws Exception { wipeAllLicenses(); internalCluster().startNode(); ensureGreen(); assertLicenseActive(true); - putLicense(TestUtils.generateExpiredNonBasicLicense(System.currentTimeMillis() - LicenseService.GRACE_PERIOD_DURATION.getMillis())); + putLicense(TestUtils.generateExpiredNonBasicLicense(System.currentTimeMillis())); assertLicenseActive(false); logger.info("--> restart node"); internalCluster().fullRestart();