Skip to content

fix: Write agent logs to "/tmp/coder-agent.log" for debugging #1239

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
merged 2 commits into from
May 2, 2022

Conversation

kylecarbs
Copy link
Member

It was difficult to obtain logs for the agent if it failed to
start for some reason. Now they'll go to a consistent spot!

It was difficult to obtain logs for the agent if it failed to
start for some reason. Now they'll go to a consistent spot!
@kylecarbs kylecarbs requested a review from bpmct April 30, 2022 04:42
@kylecarbs kylecarbs self-assigned this Apr 30, 2022
@codecov
Copy link

codecov bot commented Apr 30, 2022

Codecov Report

Merging #1239 (8b6b330) into main (c2b5009) will increase coverage by 0.09%.
The diff coverage is 87.50%.

@@            Coverage Diff             @@
##             main    #1239      +/-   ##
==========================================
+ Coverage   66.01%   66.10%   +0.09%     
==========================================
  Files         275      275              
  Lines       17949    17949              
  Branches      216      216              
==========================================
+ Hits        11849    11866      +17     
+ Misses       4859     4847      -12     
+ Partials     1241     1236       -5     
Flag Coverage Δ
unittest-go-macos-latest 53.30% <87.50%> (+0.09%) ⬆️
unittest-go-postgres- 64.96% <87.50%> (+0.01%) ⬆️
unittest-go-ubuntu-latest 55.80% <87.50%> (+0.08%) ⬆️
unittest-go-windows-2022 51.64% <87.50%> (-0.05%) ⬇️
unittest-js 70.69% <ø> (ø)
Impacted Files Coverage Δ
agent/agent.go 65.62% <50.00%> (-0.36%) ⬇️
cli/agent.go 85.71% <100.00%> (+0.71%) ⬆️
peerbroker/listen.go 84.03% <0.00%> (-3.37%) ⬇️
coderd/provisionerdaemons.go 62.98% <0.00%> (ø)
provisioner/terraform/provision.go 72.30% <0.00%> (+0.42%) ⬆️
provisionerd/provisionerd.go 76.30% <0.00%> (+0.53%) ⬆️
peer/conn.go 78.66% <0.00%> (+1.48%) ⬆️
coderd/httpapi/httpapi.go 72.50% <0.00%> (+6.25%) ⬆️
peerbroker/dial.go 83.60% <0.00%> (+6.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c2b5009...8b6b330. Read the comment docs.

@kylecarbs kylecarbs requested a review from coadler May 2, 2022 16:09
cli/agent.go Outdated
logger := slog.Make(sloghuman.Sink(cmd.OutOrStdout())).Leveled(slog.LevelDebug)

logPath := filepath.Join(os.TempDir(), "coder-agent.log")
logFile, err := os.OpenFile(logPath, os.O_CREATE|os.O_RDWR, 0600)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add some sort of log rolling for this file just in case? For workspaces that are on for a really long time it seems like this could slowly eat up your ram forever.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I shall add

@kylecarbs kylecarbs enabled auto-merge (squash) May 2, 2022 16:31
@kylecarbs kylecarbs merged commit e531c09 into main May 2, 2022
@kylecarbs kylecarbs deleted the agentlogs branch May 2, 2022 16:36
kylecarbs added a commit that referenced this pull request Jun 10, 2022
It was difficult to obtain logs for the agent if it failed to
start for some reason. Now they'll go to a consistent spot!
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