Skip to content

Upgrade vminitd API to use grpc-swift-2.#578

Merged
jglogan merged 3 commits intoapple:mainfrom
jglogan:grpc-v2
Mar 13, 2026
Merged

Upgrade vminitd API to use grpc-swift-2.#578
jglogan merged 3 commits intoapple:mainfrom
jglogan:grpc-v2

Conversation

@jglogan
Copy link
Copy Markdown
Contributor

@jglogan jglogan commented Mar 12, 2026

  • No real notable API changes. The largest change code-wise is in Vminitd. The connection loop is set up immediately in the new API by calling runConnections() on the client, and this blocks until either the task it's running on is cancelled or beginGracefulShutdown is called. Because of this, either we'd have to modify our API to have VirtualMachineAgent implementations call some run() method, or we just put runConnections in an internal task on Vminitd. This change uses the latter approach as it's simpler.
  • Updated dependencies to pick up latest protobuf and grpc-swift-2 fixes.
  • ClientBootstrap.withConnectedSocket(fd).wait() registers the vsock fd with epoll/kqueue immediately. vminitd sends its HTTP/2 SETTINGS frame right away upon accepting the connection, so those bytes can arrive on the fd — and be read by NIO — before the gRPC pipeline is installed. With a bare pipeline, NIO has nowhere to send the bytes and discards them.
  • Buffer until ClientConnectionHandler is in the pipeline so it can process the SETTINGS frame and fire .ready, then schedule delivery of the buffered data with assumeIsolatedUnsafeUnchecked().execute.
  • To help produce more accurate merged logs, defines a StderrLogHandler in the vminitd Application.swift that writes timestamps to the boot log with millisecond precision and format identical to that of the log files created using the --log-root arg on container.
  • Updates hawkeye to latest version (v6.5.1).

- No real notable API changes. The largest change
  code-wise is in Vminitd. The connection loop is
  set up immediately in the new API by calling
  runConnections() on the client, and this blocks
  until either the task it's running on is cancelled
  or beginGracefulShutdown is called. Because of
  this, either we'd have to modify our API to have
  VirtualMachineAgent implementations call some
  run() method, or we just put runConnections in
  an internal task on Vminitd. This change uses
  the latter approach as it's simpler.
- Updated dependencies to pick up latest protobuf
  and grpc-swift-2 fixes.
- ClientBootstrap.withConnectedSocket(fd).wait()
  registers the vsock fd with epoll/kqueue immediately.
  vminitd sends its HTTP/2 SETTINGS frame right away
  upon accepting the connection, so those bytes can
  arrive on the fd — and be read by NIO — before the
  gRPC pipeline is installed. With a bare pipeline,
  NIO has nowhere to send the bytes and discards them.
- Buffer until ClientConnectionHandler is in the
  pipeline so it can process the SETTINGS frame and
  fire .ready, then schedule delivery of the buffered
  data with assumeIsolatedUnsafeUnchecked().execute.

Co-authored-by: Danny Canter <danny_canter@apple.com>
@dcantah
Copy link
Copy Markdown
Member

dcantah commented Mar 12, 2026

Based off of #379 which we can close

jglogan added a commit to jglogan/container that referenced this pull request Mar 12, 2026
- Closes apple#1308.
- Applies dependency and code changes similar
  to apple/containerization#578.
- Upgrades hawkeye to latest version.
- Update StderrLogHandler not to create a
  (non-Sendable) Swift time formatter object
  for every log message.
jglogan added a commit to jglogan/container that referenced this pull request Mar 12, 2026
- Closes apple#1308.
- Applies dependency and code changes similar
  to apple/containerization#578.
- Upgrades hawkeye to latest version.
- Update StderrLogHandler not to create a
  (non-Sendable) Swift time formatter object
  for every log message.
@jglogan jglogan requested a review from dcantah March 12, 2026 20:44
@jglogan jglogan merged commit 7ffe6d2 into apple:main Mar 13, 2026
3 checks passed
@jglogan jglogan deleted the grpc-v2 branch March 13, 2026 19:26
@jglogan jglogan mentioned this pull request Mar 13, 2026
jglogan added a commit to apple/container that referenced this pull request Mar 16, 2026
- Closes #1308.
- Applies dependency and code changes similar to
apple/containerization#578.
- Upgrades hawkeye to latest version.
- Update StderrLogHandler not to create a (non-Sendable) Swift time
formatter object for every log message.
crosbymichael added a commit to crosbymichael/containerization that referenced this pull request Mar 17, 2026
crosbymichael added a commit to crosbymichael/containerization that referenced this pull request Mar 17, 2026
jglogan pushed a commit that referenced this pull request Mar 17, 2026
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