-
Notifications
You must be signed in to change notification settings - Fork 13
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
CA-389176: Fix missing xcp-rrdd-plugin logs (preserve directory collection order) #88
CA-389176: Fix missing xcp-rrdd-plugin logs (preserve directory collection order) #88
Conversation
For the external bugtool plugin `xcp-rrdd-plugins`, the order of the directory traversal of the trees it collects is important: File `/etc/xensource/bugtool/xcp-rrdd-plugins.xml`: ```xml <capability pii="maybe" max_size="1638400" max_time="60" mime="text/plain" checked="true"/> ``` File `/etc/xensource/bugtool/xcp-rrdd-plugins/stuff.xml`: ```xml <collect> <directory pattern=".*xcp-rrdd-plugins\.log.*">/var/log</directory> <directory label="rrdd_shm">/dev/shm/metrics</directory> </collect> ``` `/dev/shm/metrics/xcp-rrdd-iostat` is a sparse file that may hold just 8k of actual data, but its apparent size is ~8 MB. Using the current algorithm, the large, sparse file gets added nonetheless. But after it, the max_size limit of 1.6 MB set by the plugin's `.xml` is exceeded, and file_output then rejects further files in the same cap. When `xen-bugtool --all` is used, Python2 no longer preserves the order of the directories in the directory_specifications variable. Then, /dev/shm/metrics is collected before /var/log/xcp-rrdd-plugins, which means that -rrdd-plugins log files are NOT collected. Of course, as described, also other factors are to blame: - Not getting the actual, but the apparent sparse file size - Collecting too large files that exceed the limits instead of rejecting them (which would allow small files after them). But the immediate trigger for this regression is not preserving the directory order in Python 2. Fix it by using OrderedDict() (like Python 3 always does anyway) for the directory_specifications dictionary (only two dozen entries). Signed-off-by: Bernhard Kaindl <[email protected]>
Pull Request Test Coverage Report for Build 8015564219Details
💛 - Coveralls |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #88 +/- ##
=======================================
Coverage 88.29% 88.29%
=======================================
Files 18 18
Lines 2195 2196 +1
=======================================
+ Hits 1938 1939 +1
Misses 257 257
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python3.7+ maintains insertion order using builtin dictionary {} where ,older versions of python less than 3.7 would require ordered dictionary(OrderedDict()). Since this is would be python 2.x the change holds good here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is available in both 3.1+ and 2.7, so it should bring consistent behaviour.
Thank you for your review and your analysis! And, just to complete the justification for this change:
|
This PR fixes a regression caused by #51 (Run commands before traversing directories):
The files listed in these messages are currently not collected, fix this regression:
For the external bugtool plugin
xcp-rrdd-plugins
, the order of the directory traversal of the trees it collects is important:File
/etc/xensource/bugtool/xcp-rrdd-plugins.xml
:File
/etc/xensource/bugtool/xcp-rrdd-plugins/stuff.xml
:/dev/shm/metrics/xcp-rrdd-iostat
is a sparse file that may hold just 8k of actual data, but its apparent size is ~8 MB. Using the current algorithm, the large, sparse file gets added nonetheless. But after it, the max_size limit of 1.6 MB set by the plugin's.xml
is exceeded, and file_output then rejects further files in the same cap.When
xen-bugtool --all
is used, Python2 no longer preserves the order of the directories in the directory_specifications variable.Then, /dev/shm/metrics is collected before /var/log/xcp-rrdd-plugins, which means that -rrdd-plugins log files are NOT collected.
Of course, as described, also other factors are to blame:
But the immediate trigger for this regression is not preserving the directory order in Python 2.
Fix it by using OrderedDict() (like Python 3 always does anyway) for the directory_specifications dictionary (only two dozen entries).