- Notifications
You must be signed in to change notification settings - Fork914
chore: add parent PID to coder ssh log file name#16080
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -124,18 +124,26 @@ func (r *RootCmd) ssh() *serpent.Command { | ||
if err != nil { | ||
return xerrors.Errorf("generate nonce: %w", err) | ||
} | ||
logFileBaseName := fmt.Sprintf( | ||
"coder-ssh-%s-%s", | ||
// The time portion makes it easier to find the right | ||
// log file. | ||
time.Now().Format("20060102-150405"), | ||
// The nonce prevents collisions, as SSH invocations | ||
// frequently happen in parallel. | ||
nonce, | ||
) | ||
if stdio { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. In Should we just include it in either case here as well? Trying to get a handle on how these files relate I suppose. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. For now I think this is good for compatibility though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I was thinking we only want it for stdio mode because including the parent PID is only meaningful when There isn't a use case where we would use | ||
// The VS Code extension obtains the PID of the SSH process to | ||
// find the log file associated with a SSH session. | ||
// | ||
// We get the parent PID because it's assumed `ssh` is calling this | ||
// command via the ProxyCommand SSH option. | ||
logFileBaseName += fmt.Sprintf("-%d", os.Getppid()) | ||
} | ||
logFileBaseName += ".log" | ||
logFilePath := filepath.Join(logDirPath, logFileBaseName) | ||
logFile, err := os.OpenFile( | ||
logFilePath, | ||
os.O_CREATE|os.O_APPEND|os.O_WRONLY|os.O_EXCL, | ||
Uh oh!
There was an error while loading.Please reload this page.