Skip to content

Commit

Permalink
Better LM status reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
kevpar committed Nov 7, 2024
1 parent 0048e73 commit f13faf6
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions internal/taskserver/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/netip"
"os"
"path/filepath"
"time"

runhcsopts "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
"github.com/Microsoft/hcsshim/internal/cmd"
Expand All @@ -19,6 +20,7 @@ import (
"golang.org/x/sys/windows"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/timestamppb"
)

type migrationState struct {
Expand Down Expand Up @@ -149,22 +151,49 @@ func (s *service) TransferSandbox(ctx context.Context, req *lmproto.TransferSand
if s.migState.c == 0 {
return fmt.Errorf("must set up channel before transferring")
}
start := time.Now()
if err := stream.Send(&lmproto.TransferSandboxResponse{
MessageId: 1,
Status: lmproto.TransferSandboxResponse_STATUS_BROWNOUT_IN_PROGRESS,
StartTime: timestamppb.New(start),
UpdateTime: timestamppb.Now(),
}); err != nil {
logrus.WithError(err).Error("failed stream send")
return fmt.Errorf("send brownout status: %w", err)
}
if err := s.migState.sandbox.LMTransfer(ctx, uintptr(s.migState.c)); err != nil {
if err := stream.Send(&lmproto.TransferSandboxResponse{
MessageId: 1,
MessageId: 2,
Status: lmproto.TransferSandboxResponse_STATUS_FAILED,
ErrorMessage: err.Error(),
StartTime: timestamppb.New(start),
UpdateTime: timestamppb.Now(),
}); err != nil {
logrus.WithError(err).Error("failed stream send")
return fmt.Errorf("send failed status: %w", err)
}
return err
}
logrus.Info("LM transfer complete")
if err := stream.Send(&lmproto.TransferSandboxResponse{
MessageId: 1,
Status: lmproto.TransferSandboxResponse_STATUS_CONMPLETE,
MessageId: 2,
Status: lmproto.TransferSandboxResponse_STATUS_BLACKOUT_IN_PROGRESS,
StartTime: timestamppb.New(start),
UpdateTime: timestamppb.Now(),
Progress: 0.5,
}); err != nil {
logrus.WithError(err).Error("failed stream send")
return fmt.Errorf("send blackout status: %w", err)
}
if err := stream.Send(&lmproto.TransferSandboxResponse{
MessageId: 3,
Status: lmproto.TransferSandboxResponse_STATUS_CONMPLETE,
StartTime: timestamppb.New(start),
UpdateTime: timestamppb.Now(),
Progress: 1,
}); err != nil {
logrus.WithError(err).Error("failed stream send")
return fmt.Errorf("send complete status: %w", err)
}
return nil
}
Expand Down

0 comments on commit f13faf6

Please sign in to comment.