liquidmetal-dev / flintlock

Lock, Stock, and Two Smoking MicroVMs. Create and manage the lifecycle of MicroVMs backed by containerd.
https://flintlock.liquidmetal.dev/
Mozilla Public License 2.0
605 stars 36 forks source link

Add API endpoint to retrieve stdout/stderr #302

Open richardcase opened 2 years ago

richardcase commented 2 years ago

Describe the solution you'd like: It would be good if there was an API endpoint that would be called to get the stdout/stderr of the Firecracker instance.

Why do you want this feature: Its handy for debugging and operational reasons. And also in the future we could expose this via a UI.

Anything else you would like to add: [Miscellaneous information that will assist in solving the issue.]

yitsushi commented 2 years ago

It's clear it has to be a stream because it can be huge. How should the stream behave? Close the connection on EOF (option A) or keep the file open (option B) and send new content and the connection is closed on error or when the client closes it?

So simplified version without propagating the error or anything fancy checking:

go func() {
  for {
    select {
    case <-ctx.Done():
      return
    default:
    }

    bytes := make([]byte, 2014)

    length, err := file.Read(bytes)
    if err != nil {
      if err != io.EOF {
        logrus.Error(err.Error())

        return
      }

      // Options A:
      //select {
      //case end <- true:
      //default:
      //}
      //return

      // Option B:
      time.Sleep(time.Microsecond * 100)
      continue
    }

    stream.Send(&api.TailResponse{Data: bytes[:length]})
  }
}()

Or add a "keep reading" flag on the request.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity.

yitsushi commented 1 year ago

Still valid.

github-actions[bot] commented 5 months ago

This issue was closed because it has been stalled for 365 days with no activity.