Skip to content

Commit

Permalink
Register TaskState after LMFinalize. New drop for Apurv
Browse files Browse the repository at this point in the history
  • Loading branch information
kevpar committed Nov 15, 2024
1 parent 4eec37e commit e940475
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
29 changes: 28 additions & 1 deletion cmd/task/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ var execCommand = cli.Command{
Usage: "Named pipe path",
},
cli.BoolFlag{
Name: "terminal",
Name: "tty",
Usage: "Enable terminal mode for task IO",
},
},
Expand Down Expand Up @@ -443,6 +443,33 @@ var waitCommand = cli.Command{
},
}

var connectCommand = cli.Command{
Name: "connect",
ArgsUsage: "<pipe> <task id>",
SkipArgReorder: true,
Before: appargs.Validate(appargs.String, appargs.String),
Action: func(clictx *cli.Context) error {
args := clictx.Args()
address := args[0]
id := args[1]

conn, err := winio.DialPipe(address, nil)
if err != nil {
return fmt.Errorf("dial %s: %w", address, err)
}

client := ttrpc.NewClient(conn)
svc := task.NewTaskClient(client)

ctx := context.Background()

if _, err := svc.Connect(ctx, &task.ConnectRequest{ID: id}); err != nil {
return err
}
return nil
},
}

var shutdownCommand = cli.Command{
Name: "shutdown",
ArgsUsage: "<pipe> <task id>",
Expand Down
1 change: 1 addition & 0 deletions cmd/task/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func main() {
execCommand,
closeIOCommand,
waitCommand,
connectCommand,
shutdownCommand,
// Extra
pipeCommand,
Expand Down
5 changes: 5 additions & 0 deletions internal/taskserver/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type migrationState struct {
c windows.Handle
sandbox core.Migratable
taskState map[string]*statepkg.TaskState
newID string
}

var _ (lmproto.MigrationService) = (*service)(nil)
Expand Down Expand Up @@ -86,6 +87,7 @@ func (s *service) newSandboxLM(ctx context.Context, shimOpts *runhcsopts.Options
return err
}
s.migState = &migrationState{
newID: req.ID,
sandbox: sandbox,
taskState: config.Tasks,
}
Expand Down Expand Up @@ -205,6 +207,9 @@ func (s *service) FinalizeSandbox(ctx context.Context, req *lmproto.FinalizeSand
return nil, err
}
s.sandbox = &Sandbox{
State: &State{
TaskID: s.migState.newID,
},
Sandbox: s.migState.sandbox.(core.Sandbox),
Tasks: make(map[string]*Task),
}
Expand Down
3 changes: 2 additions & 1 deletion internal/vm2/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ func convertConfig(config *Config) (*hcsschema.ComputeSystem, error) {
LinuxKernelDirect: &hcsschema.LinuxKernelDirect{
KernelFilePath: filepath.Join(bootFilesDir, "vmlinux"),
InitRdPath: filepath.Join(bootFilesDir, "initrd.img"),
KernelCmdLine: fmt.Sprintf("init=/init 8250_core.nr_uarts=1 8250_core.skip_txen_test=1 console=ttyS0,115200 panic=-1 debug pci=off nr_cpus=%d brd.rd_nr=0 pmtmr=0 printk.devkmsg=on -- -e 1 /bin/gcs -v4 /log-format json -loglevel debug", config.ProcessorCount),
// KernelCmdLine: fmt.Sprintf("init=/init 8250_core.nr_uarts=1 8250_core.skip_txen_test=1 console=ttyS0,115200 panic=-1 debug pci=off nr_cpus=%d brd.rd_nr=0 pmtmr=0 printk.devkmsg=on -- -e 1 sh -c \"/bin/gcs -v4 /log-format json -loglevel debug & exec sh\"", config.ProcessorCount),
KernelCmdLine: fmt.Sprintf("init=/init 8250_core.nr_uarts=1 8250_core.skip_txen_test=1 console=ttyS0,115200 panic=-1 debug pci=off nr_cpus=%d brd.rd_nr=0 pmtmr=0 printk.devkmsg=on -- -e 1 /bin/gcs -v4 /log-format json -loglevel debug", config.ProcessorCount),
},
},
ComputeTopology: &hcsschema.Topology{
Expand Down

0 comments on commit e940475

Please sign in to comment.