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

[Merged by Bors] - Ensure logfile respects the validators-dir CLI flag #3003

Closed
wants to merge 3 commits into from

Conversation

macladson
Copy link
Member

@macladson macladson commented Feb 7, 2022

Issue Addressed

Closes #2990

Proposed Changes

Add a check to see if the --validators-dir CLI flag is set and if so store validator logs into it.
Ensure that if the log directory cannot be created, emit a WARN and disable file logging rather than panicking.

Additional Info

Panics associated with logfiles can still occur in these scenarios:

  1. The $datadir/validators/logs directory already exists with the wrong permissions (or was changed after creation).
  2. The logfile already exists with the wrong permissions (or was changed after creation).

These panics are cosmetic only since only the logfile thread panics. Following the panics, LH will continue to function as normal.

I believe this is due to the use of slog::Fuse when initializing the logger.
I'm not sure if there a better way of handling logfile errors?
I think ideally, rather than panicking, we would emit a WARN to the stdout logger with the panic reason, then exit the logfile thread gracefully.

@macladson macladson added the ready-for-review The code is ready for review label Feb 7, 2022
Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

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

Looking good! I just have a couple of minor nits. Feel free to include them if you wish.

lighthouse/environment/src/lib.rs Outdated Show resolved Hide resolved
lighthouse/src/main.rs Outdated Show resolved Hide resolved
@paulhauner paulhauner added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Feb 16, 2022
@macladson macladson added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Feb 21, 2022
lighthouse/src/main.rs Outdated Show resolved Hide resolved
@michaelsproul michaelsproul added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Feb 23, 2022
Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

LGTM!

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Feb 23, 2022
@michaelsproul
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Feb 24, 2022
## Issue Addressed

Closes #2990 

## Proposed Changes

Add a check to see if the `--validators-dir` CLI flag is set and if so store validator logs into it.
Ensure that if the log directory cannot be created, emit a `WARN` and disable file logging rather than panicking. 

## Additional Info

Panics associated with logfiles can still occur in these scenarios:
1. The `$datadir/validators/logs` directory already exists with the wrong permissions (or was changed after creation).
1. The logfile already exists with the wrong permissions (or was changed after creation).
> These panics are cosmetic only since only the logfile thread panics. Following the panics, LH will continue to function as normal. 

I believe this is due to the use of [`slog::Fuse`](https://docs.rs/slog/latest/slog/struct.Fuse.html) when initializing the logger.
I'm not sure if there a better way of handling logfile errors?
I think ideally, rather than panicking, we would emit a `WARN` to the stdout logger with the panic reason, then exit the logfile thread gracefully.
@bors bors bot changed the title Ensure logfile respects the validators-dir CLI flag [Merged by Bors] - Ensure logfile respects the validators-dir CLI flag Feb 24, 2022
@bors bors bot closed this Feb 24, 2022
@macladson macladson deleted the logfile-fix branch January 27, 2023 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants