Skip to content

Agent logs are sometimes empty from api/v2/workspaceagents/<agent>/logs?follow&after=0 #10576

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

Closed
spikecurtis opened this issue Nov 8, 2023 · 12 comments
Assignees
Labels
s2 Broken use cases or features (with a workaround). Only humans may set this.

Comments

@spikecurtis
Copy link
Contributor

no-build-logs

Results in blank logs on Front End. Rebuilding generally seems to help.

@spikecurtis spikecurtis added s2 Broken use cases or features (with a workaround). Only humans may set this. bug labels Nov 8, 2023
@spikecurtis
Copy link
Contributor Author

Well, the logs aren't in the database...

@mafredri
Copy link
Member

mafredri commented Nov 8, 2023

That's peculiar. AFAIK we only delete logs if the agent hasn't connected for >7 days. 🤔

@spikecurtis
Copy link
Contributor Author

Yeah, my current suspicion is some agent problem where it doesn't send any...

@mafredri
Copy link
Member

mafredri commented Nov 8, 2023

If this happens again, can you verify if there are script logs in /tmp and if the agent logs contain anything interesting? It feels unlikely that all startup scripts would fail to send logs (each module usually adds its own script with log output, and each script output is handled separately).

@spikecurtis
Copy link
Contributor Author

Oh snap!, we're deleting them. My logs where there yesterday and I refreshed the page this morning and they're gone.

@bpmct
Copy link
Member

bpmct commented Apr 26, 2024

We should at least add a message that logs are only being persisted for n days instead of it being blank. +1 for this being a (hidden) server flag

Screenshot 2024-04-26 at 9 33 58 AM

@mafredri
Copy link
Member

We could also just retain latest build logs indefinitely, should fully solve the issue and is a simple query change.

@bpmct
Copy link
Member

bpmct commented Apr 28, 2024

Unsure what the overhead is for this exactly and what our recommendation would be for large deployments with large scripts, but generally open to having these persisted.

@mafredri
Copy link
Member

@bpmct, if we always keep the log from latest build, and retain the behavior that we otherwise keep logs for up to 7 days. I don't think this changes much in terms of recommendations for customers.

Why? I believe it's fairly uncommon that workspaces are kept alive indefinitely. So once a workspace is stopped, the logs are eligible for deletion (after 7 days from start).

There's another protection in place, too, currently we cut off the logs at 1 MB written to DB, so the logs won't grow indefinitely either.

@kylecarbs
Copy link
Member

I think we should just notify the users that logs are gone, that seems fine to me.

We could also always persist logs for the latest build, that doesn't seem too bad.

@mafredri
Copy link
Member

mafredri commented Jun 1, 2024

We could also always persist logs for the latest build, that doesn't seem too bad.

This seems like the simplest option to me (easy win and doesn't require notifying the user).

@johnstcn johnstcn self-assigned this Aug 27, 2024
johnstcn added a commit that referenced this issue Aug 30, 2024
…14480)

Related to #10576

This PR introduces quartz to coderd/database/dbpurge and updates the following unit tests to make use of Quartz's functionality:

- TestPurge
- TestDeleteOldWorkspaceAgentLogs

Additionally, updates DeleteOldWorkspaceAgentLogs to replace the hard-coded interval with a parameter passed into the query. This aids in testing and brings us a step towards allowing operators to configure the cutoff interval for workspace agent logs.
@johnstcn
Copy link
Member

#14460 should hopefully address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s2 Broken use cases or features (with a workaround). Only humans may set this.
Projects
None yet
Development

No branches or pull requests

5 participants