Skip to content

Conversation

savil
Copy link
Collaborator

@savil savil commented Jan 27, 2023

Summary

This PR employs the lumberjack library to do log file rotation and size limiting.

Previously, the log file would get truncated on each sshshim command execution.

Now, it acts like a sane log file:

  1. logs get added to it across multiple command executions
  2. when it hits the 2MB size limit, it gets rotated:
    • rotation copies to a backup file and the log file is truncated.

This will help us in debugging issues with premature mutagen session termination. We can inspect the logs to understand why sshshim thought that it should terminate the connections for the VM.

How was it tested?

  1. created a 2MB fake log file: yes "this is test file" | head -c 2000000 > test.file and copied it to ~/.config/devbox/ssh/shims/logs.txt
  2. triggered an ssh shim command (devbox cloud shell) a few times.
  3. observed the file get rotated:
❯ ls -al ~/.config/devbox/ssh/shims/
total 24
drwxr--r--  6 savil  staff   192 Jan 27 14:48 .
drwx------  8 savil  staff   256 Jan 27 14:48 ..
-rw-r--r--  1 savil  staff  4901 Jan 27 14:48 logs-2023-01-27T22-48-47.703.txt.gz
-rw-r--r--  1 savil  staff  1085 Jan 27 14:48 logs.txt
lrwxr-xr-x  1 savil  staff    30 Jan 27 14:48 scp -> /Users/savil/golang/bin/devbox
lrwxr-xr-x  1 savil  staff    30 Jan 27 14:48 ssh -> /Users/savil/golang/bin/devbox

Copy link
Collaborator Author

savil commented Jan 27, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@savil savil force-pushed the savil/sshshim-lumberjack-logs branch 2 times, most recently from d65a5af to b87309b Compare January 27, 2023 23:12
@savil savil force-pushed the savil/sshshim-lumberjack-logs branch from b87309b to fbd576f Compare January 27, 2023 23:15
Copy link
Contributor

@mikeland73 mikeland73 left a comment

Choose a reason for hiding this comment

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

This looks good to me but I know we're always cautious about introducing new dependencies. cc: @gcurtis

@@ -9,6 +9,7 @@ import (
"os"
"path/filepath"

"github.com/natefinch/lumberjack"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be gopkg.in/natefinch/lumberjack.v2. no?

(from readme in https://github.com/natefinch/lumberjack)

@savil
Copy link
Collaborator Author

savil commented Jan 28, 2023

Going to land but if some alternative library is better, let me know @gcurtis , and I'll be happy to switch.

@savil savil merged commit 76a2d23 into main Jan 28, 2023
@savil savil deleted the savil/sshshim-lumberjack-logs branch January 28, 2023 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants