-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Normalize loggers and upgrade log4j 1.2 to log4j 2.19 #7131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normalize loggers and upgrade log4j 1.2 to log4j 2.19 #7131
Conversation
All classes that could have their loggers inherited from their fathers had their own loggers deleted; Most loggers didn't have to be static, so most of them were normalized so that they wouldn't be; All loggers are protected now; Static logger's name are now 'LOGGER'; Non-static logger's name are now 'logger'; New class DbUpgradeAbstractImpl created so that all Upgraders extend it and inherit its logger
|
@DaanHoogland @GutoVeronezi could you please review? |
…he last configuration files
|
@JoaoJandre , I didn´t yet review 2000 files, but on first sight it looks good. I hope you have scripts to regenerate the changes, because this PR will be a conflict magnet. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #7131 +/- ##
============================================
- Coverage 30.94% 30.77% -0.18%
+ Complexity 34219 33070 -1149
============================================
Files 5353 5352 -1
Lines 375914 374419 -1495
Branches 54634 54609 -25
============================================
- Hits 116338 115221 -1117
+ Misses 244301 243889 -412
- Partials 15275 15309 +34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
auch, I checked the security issues and marked them safe. @JoaoJandre can you go through the vulnerabilities and bugs, please. I think we must ignore the code smells for this PR. We can sample them but this is going to be a manyear of work to clear them all, even the more serious ones. |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
1 similar comment
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
shall we keep count @JoaoJandre ? first conflict. (/me joking, let's not!) |
I think it's best we don't keep :D. Sounds great, I'll try to be as fast as possible in completing this PR and addressing any reviews and conflicts.
Sure, I'll go through them. |
@DaanHoogland, as this PR touched a lot of lines, any "bugs" or "vulnerabilities" that already existed are now being reported by Sonarcloud. I fixed one of them that I deemed relevant to this PR; however, in order to avoid raising the complexity of this PR, I think it would be better to create another PR to fix the other bugs and vulnerabilities. What do you think? |
…variable that was mistakenly renamed on the normalization commit
Where it comes to code smells i would agree, but I would rather assess all bugs and vulnerabilities maybe even before merging this. |
|
I updated the SnpmTrapAppender to work with log4j2 and have already tested if it gets created, and if its append method is called; however I did not test the SNMP functionality as it was not changed. I removed the TestAppender, as it was only being used in a single test in a single class, and have rewritten the test. About the AlertSyslogAppender, I have spent some time analyzing it, and it just does not seem to work at all. It will only append if _syslogAppenders is not empty nor null, but as far as I know this attribute cannot be configured via XML, and it is not being set anywhere else in the code, aside from a test class. @DaanHoogland, do you know how to configure and use this appender? If indeed it has never worked properly, could we remove it entirely? |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
@blueorangutan package |
|
@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Seems that packaging got stuck on this one; running again: @blueorangutan package |
|
@GutoVeronezi a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
might have been just the github api @GutoVeronezi (but rebuilding works;) |
BO seems a bit under the weather today. At first, I thought it could be a problem with the PR; however, I built the packages normally, the tests ran successfully, and other PR's packaging tasks are not being reported as well (vide #8605 (comment)). Any clue if the problem is only with reporting the results? |
@GutoVeronezi @blueorangutan test matrix |
|
@weizhouapache a [SL] Trillian-Jenkins matrix job (centos7 mgmt + xenserver71, rocky8 mgmt + vmware67u3, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-9124)
|
I see, thanks @weizhouapache. |
|
[SF] Trillian test result (tid-9126)
|
|
[SF] Trillian test result (tid-9125)
|
|
Hello guys I checked the test that failed in #7131 (comment), and it seems not related to the PR; therefore, as the last run passed successfully, I will merge this one. If necessary, further improvements or fixes will be addressed in new PRs. A note was already sent in the mailing list notifying the users and devs regarding the next steps; however, if you find someone struggling with the logs or anything that needs adjusting, just ping me or @JoaoJandre, so we can act as fast as possible. |
* Normalize logs All classes that could have their loggers inherited from their fathers had their own loggers deleted; Most loggers didn't have to be static, so most of them were normalized so that they wouldn't be; All loggers are protected now; Static logger's name are now 'LOGGER'; Non-static logger's name are now 'logger'; New class DbUpgradeAbstractImpl created so that all Upgraders extend it and inherit its logger * Upgrade log4j * fix errors caused by the merge * Refactor cglibThrowableRenderer functionality to log4j2 and upgrade the last configuration files * fix sonarcloud bug * Fix errors caused by merge, remove some unused loggers, and rename a variable that was mistakenly renamed on the normalization commit * Readd snmpTrapAppender, remove TestAppender * Regenerate changes * regenerate changes * refactor last custom appender * fix systemvm configuration xml * Regenerate changes * Regenerate changes * regenerate changes * Regenerate changes * regenerate changes * regenerate changes * regenerate changes * Fix utils pom * fix some tests * regenerate changes * Fix jar being printed on exception * fix logging in system VMs, fix commands not having log4j2 classpath. * regenerate changes * Fix some unwanted renomeations * fix end of file * regenerate changes * regenerate changes * fix merge error * regenerate changes * fix tests * regenerate changes * regenerate changes * regenerate changes * regenerate changes * regenerate changes * regenerate changes * regenerate changes * readd reload4j to tungsten as juniper depends on it * Regenerate changes * regenerate changes * regenerate changes * regenerate changes * regenerate changes * re-add reload4j dependency to network-contrail, as juniper depends on it * regenerate changes * regenerate changes * regenerate changes * fix typo * regenerate changes * regenerate changes * Fix end of files * regenerate changes * add logj42 to cloud-utils-SHADED.jar * regenerate changes * regenerate changes * regenerate changes * regenerate changes * regenerate changes * regenerate changes * regenerate changes * regenerate changes * Regenerate changes * Regenerate changes * Regenerate changes * regenerate changes * Regenerate changes * regenerate changes * Regenerate changes * Regenerate changes * Regenerate changes * regenerate changes * Regenerate changes * Regenerate changes * fix some tests * Regenerate changes * Regenerate changes * fix test * Regenerate changes * Regenerate changes
Description
This PR normalizes ACS's loggers and upgrades log4j 1.2 to log4j 2.19. Back in 2015, PR #714 tried to normalize the loggers but, because that normalization caused some issues with the VMware module, it ended up being reverted. This PR intends to follow that PR's footsteps and normalize all of the loggers in ACS. The objective of reducing unnecessary logger declarations, and reduce the area of impact to upgrade ACS's logger framework from log4j 1.2 to log4 2.19.
The log4j upgrade was done similarly to the proposed here #2992 (comment), and is more detailed ahead.
The logger normalization includes:
BaseElement,PipelineImpl,AbstractRect,AbstractSmartLifeCycle,ManagedContextRunnable,Command,RuleApplier,VmWork,ModelObjectBase,SnapshotStrategyBase,VifDriver.To normalize all the loggers in ACS, the following steps were performed:
logger;*The ancestor list I created came from a previous iteration of this process, where I tried to simply remove logger instantiation from any class that extended any other class, the list was created while manually fixing the errors.
For the log4j upgrade, the following steps were performed:
If you need to fix conflicts because of this PR, you can try using this script to help you:
About the log4j upgrade:
Disclaimers:
The new log4j2 configuration file format is not backwards compatible with the old one, users must update their configuration files to match with the new format. I used the official apache documentation to upgrade the default configurations, available here.
If you call EncryptorCLI manually, you must also pass the log4j2 jar path (which should be in the same directory as cloud-utils).
The are still some points to address/discuss in order to make this PR ready:
Refactor the following classes so that they can be used in log4j2:;SnmpTrapAppender,AlertsSyslogAppender,TestAppender,SnmpEnhancedPatternLayoutConvert CglibThrowableRenderer functionality to log4j2;Test logging for management, agent, usage, SSVMs and CPVMsTypes of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
I tested if both the console and the file appenders were logging correctly in the management server, agents, and system VMs.