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

CBG-4236: Create SG log files on startup with 0644 permission bits set #7128

Merged
merged 4 commits into from
Oct 2, 2024

Conversation

bbrks
Copy link
Member

@bbrks bbrks commented Sep 24, 2024

CBG-4236

Creates log files on startup with 0644 permission bits set.

  • This restores pre-3.2.0 file permission behaviour. Existing files will retain their existing permission bits.
  • New behaviour with this PR: SG creates empty log files at startup time, rather than creating on-demand when the log file needs to be written to.
  • Removes now redundant '.SG_write_check' logic that ensures a given log_file_path directory is writable. We now use the log files directly, rather than this proxy.

Integration Tests

Copy link
Collaborator

@torcolvin torcolvin left a comment

Choose a reason for hiding this comment

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

Do you think it's worthwhile to write a test for the following circumstances? I'm specifically concerned that the errors will be opaque if Sync Gateway is started with invalid configuration since each logger will error separately. If this is unclear, separating the directory creation from log file validation might be worthwhile.

  • logFilePath is specified as a file instead of a directory
  • logFilePath is not actually writeable. This test might only work on linux by changing permissions to read only.

base/logging_config.go Outdated Show resolved Hide resolved
@bbrks
Copy link
Member Author

bbrks commented Oct 1, 2024

Added test for 'not a directory', non-writable test already covered with TestLogFilePathWritable.

Real-world error at startup time:

2024-10-01T18:47:03.040+01:00 [ERR] Couldn't start Sync Gateway: error setting up logging: invalid log file path: mkdir /tmp/sglog/thisisafile: not a directory -- base.FatalfCtx() at logging.go:151

@bbrks bbrks requested a review from torcolvin October 1, 2024 18:02
@bbrks bbrks assigned torcolvin and unassigned bbrks Oct 1, 2024
Copy link
Collaborator

@torcolvin torcolvin left a comment

Choose a reason for hiding this comment

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

This is fine, but the tests need to pass on windows - the "not a directory" message is different and the file descriptor from os.Create needs to be closed so the temporary directory can be removed.

Will approve after that is done.

@torcolvin torcolvin assigned bbrks and unassigned torcolvin Oct 2, 2024
@bbrks bbrks assigned torcolvin and unassigned bbrks Oct 2, 2024
@torcolvin torcolvin merged commit 9ce7f7b into main Oct 2, 2024
36 of 38 checks passed
@torcolvin torcolvin deleted the CBG-4236 branch October 2, 2024 15:08
bbrks added a commit that referenced this pull request Oct 4, 2024
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