core icon indicating copy to clipboard operation
core copied to clipboard

Need to refactor license validation code

Open brentgriffin opened this issue 10 years ago • 6 comments

We have had several clients reporting licensed servers suddenly loosing their licenses. Things are running smoothly for weeks or months and then suddenly and without warning the licenses seem to be lost and all non-community features stop working.

Support engineers have spent several man days trying to understand how this could possibly happen. It seems like this could possibly be triggered by some type of disruption in the connection to the file storage that holds the license and server files. A few of our clients have customized license and ee jars deployed with additional logging added around these areas of code; however, at this point our clients have not been able to log any additional information about these occurrences.

Expected Behavior

Once a server has started in a valid licensed state, the only time that license state should change is:

  • License expires
  • User directly initiates a change in license - i.e. drops license or applies a new license

Current Behavior

See description above - Servers start in a valid licensed state and then suddenly appear to be unlicensed without any licensing changes initiated by the administrator.

Possible Solution

Store license and server information in memory at runtime - utilize that information as the default information so that if there is some type of failure, that is the default rather than the current hardcoded default - https://github.com/dotCMS/license/blob/master-3.6/src/com/dotcms/enterprise/license/LicenseManager.java#L188-L217 .

Known Workarounds

Server has to be relicensed

Steps to Reproduce (for bugs)

Engineers have not been able to identify the specific steps or situations that cause this to occur which is why I am suggesting that this code be refactored and its basic assumptions changed.

These clients have all documented this problem happening to them:

  • https://my.dotcms.com/tickets/detail.dot?id=597df86e-ca56-4333-a977-8194f649907e
  • https://my.dotcms.com/tickets/detail.dot?id=c7afdbda-c963-4399-bd31-10d7a172d856
  • https://my.dotcms.com/tickets/detail.dot?id=57e93cd3-6d4b-45bf-b1ca-9ea4b01ad257
  • https://my.dotcms.com/tickets/detail.dot?id=c0fb3d72-40ba-4c57-8de7-7cdbbd351424

Context

Significantly undermines confidence in the product knowing that at any time their production servers could shut down because of this licensing problem. For example, when using an enterprise only db, if the server looses its license, it will not longer respond successfully to requests for content. If it is in a cluster, it drops out of the cluster, etc.

Your Environment

  • dotCMS version used: 3.2.4 to 3.5.1
  • Operating System and version: various versions of Linux
  • Application Server and version: embedded and standalone Tomcat
  • Java Brand and version: various
  • Database and version: MySQL, MS SQL, Oracle

brentgriffin avatar Sep 29 '16 13:09 brentgriffin

I was able to reproduce the license disappear issue following these steps:

  1. Startup a dotcms instance
  2. Apply an enterprise license (I applied the trial.jsp)
  3. Shutdown the DB
  4. Restart dotcms (with the DB still off)
  5. Check the license.dat disappear
  6. Startup the DB
  7. Restart dotcms
  8. Community license is shown

PS: If I tried with a license pack is gonna auto-apply the license if one is available

This scenario was provided by client https://my.dotcms.com/tickets/detail.dot?id=597df86e-ca56-4333-a977-8194f649907e

erickgonzalez avatar Sep 29 '16 21:09 erickgonzalez

PR (Enterprise): https://github.com/dotCMS/enterprise-2.x/pull/389 PR (License): https://github.com/dotCMS/license/pull/29

agomez-dotcms avatar Oct 05 '16 17:10 agomez-dotcms

Code is definitely an improvement. I would like to see some additional logging - especially in setupDefaultLicense - maybe an info message right at the top to make it clear that a default license is being generated and then maybe a debug message that shows the stack and the value of the “cleanup” variable - the debug message could be an easy way to help us debug any other issues that may occur.

brentgriffin avatar Nov 01 '16 12:11 brentgriffin

Thanks Brent for your comments! I just committed a couple of changes on setupDefaultLicense to take into account your feedback. Here is the commit: https://github.com/dotCMS/license/pull/29/commits/94989e28650f1a3d8845afeb7763d6d79cd597cb.

Guys, I wonder if the PRs are now ready to be merged? Is there anything else that we are missing/requiring? Thanks!

agomez-dotcms avatar Nov 01 '16 18:11 agomez-dotcms

Thanks! Looks good!

brentgriffin avatar Nov 01 '16 18:11 brentgriffin

Passed QA. Followed Steps to Reproduce to verify fix and also checked the scenarios below:

  • Verified that initial start with no license works
  • Checked that community license works between continuos startups
  • Made sure license packs keep working between continuos startups
  • Verified that community license does not disappear when you shutdown, turn off the server and a restart a dotCMS instance with the server down
  • Configured cluster environment and verified that license is persistent between continuos startups
  • Checked that you can reapply a license and have it persist
  • Verified that if the license files are missing when the server starts up, the system uses the default / dev license

Tested in master-3.7 distro / OS 10.10 / MySQL 5.6.23 / Firefox v45.0.1 / Tomcat 8 / Java 8

shaydotcms avatar Nov 18 '16 21:11 shaydotcms