@@ -61,10 +61,10 @@ public ClusterState execute(ClusterState currentState) throws Exception {
61
61
"]. Must be trial or basic." );
62
62
}
63
63
return updateWithLicense (currentState , type );
64
- } else if (LicenseUtils .licenseNeedsExtended (currentLicensesMetaData .getLicense ())) {
65
- return extendBasic (currentState , currentLicensesMetaData );
66
64
} else if (LicenseUtils .signatureNeedsUpdate (currentLicensesMetaData .getLicense ())) {
67
65
return updateLicenseSignature (currentState , currentLicensesMetaData );
66
+ } else if (LicenseUtils .licenseNeedsExtended (currentLicensesMetaData .getLicense ())) {
67
+ return extendBasic (currentState , currentLicensesMetaData );
68
68
} else {
69
69
return currentState ;
70
70
}
@@ -75,11 +75,10 @@ private ClusterState updateLicenseSignature(ClusterState currentState, LicensesM
75
75
MetaData .Builder mdBuilder = MetaData .builder (currentState .metaData ());
76
76
String type = license .type ();
77
77
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 ) {
80
81
expiryDate = LicenseService .BASIC_SELF_GENERATED_LICENSE_EXPIRATION_MILLIS ;
81
- } else {
82
- expiryDate = issueDate + LicenseService .NON_BASIC_SELF_GENERATED_LICENSE_DURATION .getMillis ();
83
82
}
84
83
License .Builder specBuilder = License .builder ()
85
84
.uid (license .uid ())
@@ -92,6 +91,8 @@ private ClusterState updateLicenseSignature(ClusterState currentState, LicensesM
92
91
Version trialVersion = currentLicenseMetaData .getMostRecentTrialVersion ();
93
92
LicensesMetaData newLicenseMetadata = new LicensesMetaData (selfGeneratedLicense , trialVersion );
94
93
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 ());
95
96
return ClusterState .builder (currentState ).metaData (mdBuilder ).build ();
96
97
}
97
98
0 commit comments