Skip to content
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

Add random 6-character suffix to log file names #1041

Merged
merged 5 commits into from
Oct 3, 2024

Conversation

dannycjones
Copy link
Contributor

@dannycjones dannycjones commented Sep 30, 2024

Description of change

Before this change, Mountpoint can write to the same log file if multiple Mountpoint processes spawn within the same second. This can cause log entries to be interleaved and reduces the effectiveness of debug logging since its impossible to tell which log entries relate to which Mountpoint process.

This change updates the log file creation logic to now include a six-character suffix between the timestamp and the .log suffix. An example of a new log file name: mountpoint-s3-2024-10-02T10-26-57Z.961grx.log.

We update the log config logic so that it can be defined before the fork, and then persists after fork. We know this is safe as it contains no state unsafe to share over forks.

This change also updates the logging documentation to indicate that log file names could always change in the future and shouldn't be considered stable. It also clarifies this behavior, since customers may only infrequently run into this scenario.

Relevant issues: N/A

Alternatives considered

  • Include PID in log entries.
    • This would add additional bytes/noise to all logs to cover a case which for most customers will not occur.
    • In background mode, what is 'the PID of Mountpoint'? It should probably be the child process ID.
  • Include subseconds in the file name.
    • This one doesn't really have much advantage over always include the PID, and still leaves us open to the (hopefully far less likely) possibility of two Mountpoints spawning in the same subsecond.

Does this change impact existing behavior?

Yes. We now include a random suffix in the name of log files.

Before: mountpoint-s3-2024-10-02T10-26-57Z.log
After: mountpoint-s3-2024-10-02T10-26-57Z.961grx.log

Does this change need a changelog entry in any of the crates?

Yes, the main Mountpoint change log has been updated.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the Developer Certificate of Origin (DCO).

@dannycjones
Copy link
Contributor Author

I was just testing this, it doesn't cover running in the background yet.

Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>
…he timestamp

Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>
@dannycjones dannycjones temporarily deployed to PR integration tests October 2, 2024 10:45 — with GitHub Actions Inactive
mountpoint-s3/src/cli.rs Outdated Show resolved Hide resolved
@dannycjones dannycjones marked this pull request as ready for review October 2, 2024 10:54
Copy link
Contributor

@passaro passaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One minor suggestion.

mountpoint-s3/src/cli.rs Outdated Show resolved Hide resolved
Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>
@dannycjones dannycjones had a problem deploying to PR integration tests October 3, 2024 09:46 — with GitHub Actions Failure
@dannycjones dannycjones had a problem deploying to PR integration tests October 3, 2024 09:47 — with GitHub Actions Failure
@dannycjones dannycjones had a problem deploying to PR integration tests October 3, 2024 09:47 — with GitHub Actions Failure
@dannycjones dannycjones had a problem deploying to PR integration tests October 3, 2024 09:47 — with GitHub Actions Failure
@dannycjones dannycjones had a problem deploying to PR integration tests October 3, 2024 09:47 — with GitHub Actions Failure
@dannycjones dannycjones had a problem deploying to PR integration tests October 3, 2024 09:47 — with GitHub Actions Failure
@dannycjones dannycjones had a problem deploying to PR integration tests October 3, 2024 09:47 — with GitHub Actions Failure
@dannycjones dannycjones marked this pull request as draft October 3, 2024 09:47
Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>
@dannycjones dannycjones temporarily deployed to PR integration tests October 3, 2024 09:54 — with GitHub Actions Inactive
@dannycjones dannycjones temporarily deployed to PR integration tests October 3, 2024 09:54 — with GitHub Actions Inactive
@dannycjones dannycjones temporarily deployed to PR integration tests October 3, 2024 09:54 — with GitHub Actions Inactive
@dannycjones dannycjones temporarily deployed to PR integration tests October 3, 2024 09:54 — with GitHub Actions Inactive
@dannycjones dannycjones temporarily deployed to PR integration tests October 3, 2024 09:54 — with GitHub Actions Inactive
@dannycjones dannycjones temporarily deployed to PR integration tests October 3, 2024 09:54 — with GitHub Actions Inactive
@dannycjones dannycjones temporarily deployed to PR integration tests October 3, 2024 09:54 — with GitHub Actions Inactive
@dannycjones dannycjones marked this pull request as ready for review October 3, 2024 10:27
@dannycjones dannycjones requested a review from passaro October 3, 2024 10:27
@dannycjones dannycjones enabled auto-merge October 3, 2024 10:28
@dannycjones dannycjones added this pull request to the merge queue Oct 3, 2024
Merged via the queue into awslabs:main with commit 8c14475 Oct 3, 2024
23 checks passed
@dannycjones dannycjones deleted the add-pid-to-log-file-on-fail branch October 3, 2024 10:51
rajdchak pushed a commit to rajdchak/mountpoint-s3-fork that referenced this pull request Oct 4, 2024
* Add PID to log file names if log file already exists

Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>

* Update log filenames to always include some random string following the timestamp

Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>

* Rename logging_config fn to make_logging_config

Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>

* Move make_logging_config back to method of CliArgs

Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>

---------

Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants