Skip to content

Conversation

zk2k2
Copy link

@zk2k2 zk2k2 commented Jul 15, 2025

Summary

This pull request adds support for tracking and exposing the container startedAt timestamp throughout the container lifecycle.

Fixes apple/container#302.

Changes

  • Added startedAt: Date? to:
    • ContainerSnapshot
    • ClientContainer
    • PrintableContainer
  • Timestamp is assigned in ContainersService.containerStartHandler using Date()
  • Propagated the value through Item.asSnapshot()
  • Included startedAt in:
    • container list --format json output
    • Optionally included in asRow for table display (ISO 8601 format)

@jglogan
Copy link
Contributor

jglogan commented Jul 16, 2025

@zk2k2 Can you run make fmt on your end and push the changes? Right now your PRB breaks because format checks are failing.

@@ -41,6 +41,7 @@ actor ContainersService {
struct Item: Sendable {
let bundle: ContainerClient.Bundle
var state: State
var startedAt: Date?
Copy link
Contributor

Choose a reason for hiding this comment

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

startedAt is really only relevant when the container is alive, isn't it? We might want to consider associating this value with State.alive.

Copy link
Contributor

Choose a reason for hiding this comment

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

The thing seems a bit awkward on the SandboxService side of things (no fault of yours, you're just having to work with it) is that we have a model for runtime state that uses different types on the client (RuntimeStatus) and server (State) side.

The approach in the NetworkService is to have a NetworkState enum type that has an associated value for configuration data for the non-running states, and both config and runtime state values for the running states, and NetworkState is used on both client and server.

Let me look into whether we can take this approach here and I'll offer some guidance.

Copy link
Contributor

Choose a reason for hiding this comment

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

@zk2k2 If you're still interested in moving this forward, have a look at the ContainersService now. The ContainersService.Item type has now been eliminated which should make adding this field a lot simpler.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @jglogan, sure I'll check it out

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.

[Request]: add started date in containers metadata
2 participants