-
Notifications
You must be signed in to change notification settings - Fork 148
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
internal/pkg/diagnostics - Fix creation of sub-directories in logs/ #2523
internal/pkg/diagnostics - Fix creation of sub-directories in logs/ #2523
Conversation
Prior to this change sub-directories within logs/ were not created properly and resulted in unexpected directories within diagnostics files. A path separator was missing. Before the change the new test was failing with - Name: (string) (len=13) "logs/sub-dir/", + Name: (string) (len=12) "logssub-dir/",
dcf6a92
to
f83ea6c
Compare
This pull request does not have a backport label. Could you fix it @andrewkroh? 🙏
NOTE: |
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.
LGTM. Thanks for the fix and the tests.
🌐 Coverage report
|
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.
LGTM
can you pull latest main, I made some changes in this area and want to avoid some silent conflicts |
I made the test pass, but this these exposes a problem with the newly added elastic-agent-{commit} directory in that the zip file is missing a directory entry for it.
48d6ca1
to
eea8a87
Compare
|
||
// Verify the results. | ||
expected := []zippedItem{ | ||
{"logs/", true}, |
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.
@michalpristas I pulled in the latest code and this test points out a problem with the newly added elastic-agent-{commit}
directory in that it is missing a directory entry within the Zip file.
These directory entries may not be required, but IIRC depending on how robust a particular unzip tool used is, this can lead to problems when unzipping. Sometimes a tool will try to write files into a directory that doesn't exist and fail (or worse, silently ignore the problem and not write any of the files under that dir).
The test is passing as is (at least on posix), so this could be followed up in a separate change. Fixed everything I found here.
On Windows the test appears to have detected another issue:
I think this value needs to be
That's based on the comment and code at elastic-agent/internal/pkg/diagnostics/diagnostics.go Lines 332 to 333 in 383752b
And according to https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
|
The zip file did not contain a directory entry for the elastic-agent-{commit} directory. Relates elastic#2518
This calls filepath.ToSlash on any names used in zip entries. Relates elastic#2518
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.
thanks again for handling the issues
…2523) * internal/pkg/diagnostics - Fix creation of sub-directories in logs/ Prior to this change sub-directories within logs/ were not created properly and resulted in unexpected directories within diagnostics files. A path separator was missing. Before the change the new test was failing with - Name: (string) (len=13) "logs/sub-dir/", + Name: (string) (len=12) "logssub-dir/", * Update test to include the versioned sub-directory I made the test pass, but this these exposes a problem with the newly added elastic-agent-{commit} directory in that the zip file is missing a directory entry for it. * Add missing directory entry for logs/elastic-agent-{commit} The zip file did not contain a directory entry for the elastic-agent-{commit} directory. Relates #2518 * All files within the zip must use forward slash This calls filepath.ToSlash on any names used in zip entries. Relates #2518 (cherry picked from commit 91a3122)
What does this PR do?
Prior to this change sub-directories within
logs/
were not created properly and resulted in unexpected directories within diagnostics files. A path separator was missing. Before the change the new test was failing withWhy is it important?
It makes the diag zip file layout match what's on the agent host filesystem. The diag file should be correct to be trustworthy.
Checklist
./changelog/fragments
using the changelog tool