-
Notifications
You must be signed in to change notification settings - Fork 1k
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
create the log file along with its parent directory if not present #12675
create the log file along with its parent directory if not present #12675
Conversation
* Use Epoch boundary cache to retrieve balances * save boundary states before inserting to forkchoice * move up last block save * remove boundary checks on balances * fix ordering --------- Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
8e84507
to
967d7d3
Compare
io/logs/logutil.go
Outdated
if err := os.MkdirAll(filepath.Dir(logFileName), params.BeaconIoConfig().ReadWriteExecutePermissions); err != nil { | ||
return err | ||
} | ||
f, err := os.OpenFile(logFileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, params.BeaconIoConfig().ReadWriteExecutePermissions) // #nosec G304 |
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 changes the file permissions. Does the log file need +x?
f, err := os.OpenFile(logFileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, params.BeaconIoConfig().ReadWriteExecutePermissions) // #nosec G304 | |
f, err := os.OpenFile(logFileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, params.BeaconIoConfig().ReadWritePermissions) // #nosec G304 |
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.
will fix this. that was not an intended change. The ReadWriteExecute is mainly for the directory to create a file within it.
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.
the log file doesnt require +x
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.
should be resolved now
io/logs/logutil.go
Outdated
@@ -20,6 +21,9 @@ func addLogWriter(w io.Writer) { | |||
// ConfigurePersistentLogging adds a log-to-file writer. File content is identical to stdout. | |||
func ConfigurePersistentLogging(logFileName string) error { | |||
logrus.WithField("logFileName", logFileName).Info("Logs will be made persistent") | |||
if err := os.MkdirAll(filepath.Dir(logFileName), params.BeaconIoConfig().ReadWriteExecutePermissions); err != nil { |
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.
please use from our io/file
package to create these paths, it is the standard method we use across prysm for our file i/o operations
1ccc121
to
386c186
Compare
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.
Can you add a regression test for this ?
… create-log-file
4caf378
to
2920247
Compare
@@ -24,3 +27,58 @@ func TestMaskCredentialsLogging(t *testing.T) { | |||
require.Equal(t, MaskCredentialsLogging(test.url), test.maskedUrl) | |||
} | |||
} | |||
|
|||
func TestConfigurePersistantLogging(t *testing.T) { |
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.
For temporary directories for tests use t.TempDir()
, this gets cleaned up by the test runner after the test is executed.
2920247
to
c52cd9e
Compare
…create-log-file
… create-log-file
… create-log-file
… create-log-file
… create-log-file
… create-log-file
…into create-log-file
What type of PR is this?
Enhancement
What does this PR do? Why is it needed?
Currently, when we specify a log file for the beacon chain node and if the log file parent directories are not present then we don't create the directory and error out. This PR adds support to create the parent directories if not present.
Which issues(s) does this PR fix?
Fixes (#12496)
Other notes for review