@@ -61,10 +61,10 @@ public ClusterState execute(ClusterState currentState) throws Exception {
6161 "]. Must be trial or basic." );
6262 }
6363 return updateWithLicense (currentState , type );
64- } else if (LicenseUtils .licenseNeedsExtended (currentLicensesMetaData .getLicense ())) {
65- return extendBasic (currentState , currentLicensesMetaData );
6664 } else if (LicenseUtils .signatureNeedsUpdate (currentLicensesMetaData .getLicense ())) {
6765 return updateLicenseSignature (currentState , currentLicensesMetaData );
66+ } else if (LicenseUtils .licenseNeedsExtended (currentLicensesMetaData .getLicense ())) {
67+ return extendBasic (currentState , currentLicensesMetaData );
6868 } else {
6969 return currentState ;
7070 }
@@ -75,11 +75,10 @@ private ClusterState updateLicenseSignature(ClusterState currentState, LicensesM
7575 MetaData .Builder mdBuilder = MetaData .builder (currentState .metaData ());
7676 String type = license .type ();
7777 long issueDate = license .issueDate ();
78- long expiryDate ;
79- if ("basic" .equals (type )) {
78+ long expiryDate = license .expiryDate ();
79+ // extend the basic license expiration date if needed since extendBasic will not be called now
80+ if ("basic" .equals (type ) && expiryDate != LicenseService .BASIC_SELF_GENERATED_LICENSE_EXPIRATION_MILLIS ) {
8081 expiryDate = LicenseService .BASIC_SELF_GENERATED_LICENSE_EXPIRATION_MILLIS ;
81- } else {
82- expiryDate = issueDate + LicenseService .NON_BASIC_SELF_GENERATED_LICENSE_DURATION .getMillis ();
8382 }
8483 License .Builder specBuilder = License .builder ()
8584 .uid (license .uid ())
@@ -92,6 +91,8 @@ private ClusterState updateLicenseSignature(ClusterState currentState, LicensesM
9291 Version trialVersion = currentLicenseMetaData .getMostRecentTrialVersion ();
9392 LicensesMetaData newLicenseMetadata = new LicensesMetaData (selfGeneratedLicense , trialVersion );
9493 mdBuilder .putCustom (LicensesMetaData .TYPE , newLicenseMetadata );
94+ logger .info ("Updating existing license to the new version.\n \n Old license:\n {}\n \n New license:\n {}" ,
95+ license , newLicenseMetadata .getLicense ());
9596 return ClusterState .builder (currentState ).metaData (mdBuilder ).build ();
9697 }
9798
0 commit comments