Skip to content

Container logs - #13

Merged
BenasB merged 7 commits into
mainfrom
container_logs
Jul 24, 2025
Merged

Container logs#13
BenasB merged 7 commits into
mainfrom
container_logs

Conversation

@BenasB

@BenasB BenasB commented Jul 24, 2025

Copy link
Copy Markdown
Owner

Introduce functionality for storing and retrieving container logs

  • Each container sets its stdout and stderr to a file in /var/log/bx2cloud/<container_id>
    • The log file is deleted once a container is deleted
    • The log file is retained when a container is stopped
    • The log file is truncated when a container is started again
  • New rpc Logs (ContainerLogsRequest) returns (stream ContainerLogsResponse); definition in container service protobuf
    • Normally, the API just reads the full text file and streams it back to the gRPC client
    • Additionally, in ContainerLogsRequest the user can request to follow the logs, so in addition to returning the full text file, the API does not close the stream and instead tails the log file, sending any new logs to the gRPC client. This is implemented with inotify
  • Added container logs <id> command to the CLI
$ bx2cloud container logs -h
bx2cloud container logs: Retrieves the logs of a specified container resource
usage: bx2cloud container logs [flags] <id>
flags:
  -f    follow the log file

$ bx2cloud container logs 1
<redacted>
Thu Jul 24 18:58:10 UTC 2025
Thu Jul 24 18:58:11 UTC 2025
Thu Jul 24 18:58:12 UTC 2025
$
  • If a container is deleted when someone is performing container logs -f <id>, the stream exits and returns log file no longer exists.
image

Unrelated changes

  • Bump docusaurus to non-canary version
  • Adjust CLI flag docs generation to better display types and default values
  • Append [flags] to usage description of all CLI commands with flags
  • Perform subnetwork existence check (non mutating operation) before stopping the container during container destroy

@BenasB
BenasB merged commit 9853a45 into main Jul 24, 2025
19 checks passed
@BenasB
BenasB deleted the container_logs branch July 24, 2025 19:13
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.

1 participant