Return exit status from Wait of stopped process
This changes Wait() from returning an error whenever you call wait on a stopped process/task to returning the exit status from the process. This also adds the exit status to the Status() call on a process/task so that a user can Wait(), check status, then cancel the wait to avoid races in event handling. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
0fa76584f8
commit
9f13b414b9
@ -43,6 +43,7 @@ const (
|
|||||||
StatusRunning Status = 2
|
StatusRunning Status = 2
|
||||||
StatusStopped Status = 3
|
StatusStopped Status = 3
|
||||||
StatusPaused Status = 4
|
StatusPaused Status = 4
|
||||||
|
StatusPausing Status = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
var Status_name = map[int32]string{
|
var Status_name = map[int32]string{
|
||||||
@ -51,6 +52,7 @@ var Status_name = map[int32]string{
|
|||||||
2: "RUNNING",
|
2: "RUNNING",
|
||||||
3: "STOPPED",
|
3: "STOPPED",
|
||||||
4: "PAUSED",
|
4: "PAUSED",
|
||||||
|
5: "PAUSING",
|
||||||
}
|
}
|
||||||
var Status_value = map[string]int32{
|
var Status_value = map[string]int32{
|
||||||
"UNKNOWN": 0,
|
"UNKNOWN": 0,
|
||||||
@ -58,6 +60,7 @@ var Status_value = map[string]int32{
|
|||||||
"RUNNING": 2,
|
"RUNNING": 2,
|
||||||
"STOPPED": 3,
|
"STOPPED": 3,
|
||||||
"PAUSED": 4,
|
"PAUSED": 4,
|
||||||
|
"PAUSING": 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x Status) String() string {
|
func (x Status) String() string {
|
||||||
@ -74,6 +77,7 @@ type Process struct {
|
|||||||
Stdout string `protobuf:"bytes,6,opt,name=stdout,proto3" json:"stdout,omitempty"`
|
Stdout string `protobuf:"bytes,6,opt,name=stdout,proto3" json:"stdout,omitempty"`
|
||||||
Stderr string `protobuf:"bytes,7,opt,name=stderr,proto3" json:"stderr,omitempty"`
|
Stderr string `protobuf:"bytes,7,opt,name=stderr,proto3" json:"stderr,omitempty"`
|
||||||
Terminal bool `protobuf:"varint,8,opt,name=terminal,proto3" json:"terminal,omitempty"`
|
Terminal bool `protobuf:"varint,8,opt,name=terminal,proto3" json:"terminal,omitempty"`
|
||||||
|
ExitStatus uint32 `protobuf:"varint,9,opt,name=exit_status,json=exitStatus,proto3" json:"exit_status,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Process) Reset() { *m = Process{} }
|
func (m *Process) Reset() { *m = Process{} }
|
||||||
@ -149,6 +153,11 @@ func (m *Process) MarshalTo(dAtA []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
if m.ExitStatus != 0 {
|
||||||
|
dAtA[i] = 0x48
|
||||||
|
i++
|
||||||
|
i = encodeVarintTask(dAtA, i, uint64(m.ExitStatus))
|
||||||
|
}
|
||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,6 +220,9 @@ func (m *Process) Size() (n int) {
|
|||||||
if m.Terminal {
|
if m.Terminal {
|
||||||
n += 2
|
n += 2
|
||||||
}
|
}
|
||||||
|
if m.ExitStatus != 0 {
|
||||||
|
n += 1 + sovTask(uint64(m.ExitStatus))
|
||||||
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +252,7 @@ func (this *Process) String() string {
|
|||||||
`Stdout:` + fmt.Sprintf("%v", this.Stdout) + `,`,
|
`Stdout:` + fmt.Sprintf("%v", this.Stdout) + `,`,
|
||||||
`Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`,
|
`Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`,
|
||||||
`Terminal:` + fmt.Sprintf("%v", this.Terminal) + `,`,
|
`Terminal:` + fmt.Sprintf("%v", this.Terminal) + `,`,
|
||||||
|
`ExitStatus:` + fmt.Sprintf("%v", this.ExitStatus) + `,`,
|
||||||
`}`,
|
`}`,
|
||||||
}, "")
|
}, "")
|
||||||
return s
|
return s
|
||||||
@ -484,6 +497,25 @@ func (m *Process) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Terminal = bool(v != 0)
|
m.Terminal = bool(v != 0)
|
||||||
|
case 9:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field ExitStatus", wireType)
|
||||||
|
}
|
||||||
|
m.ExitStatus = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowTask
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.ExitStatus |= (uint32(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipTask(dAtA[iNdEx:])
|
skippy, err := skipTask(dAtA[iNdEx:])
|
||||||
@ -615,33 +647,34 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorTask = []byte{
|
var fileDescriptorTask = []byte{
|
||||||
// 436 bytes of a gzipped FileDescriptorProto
|
// 462 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x3f, 0x6f, 0xd3, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xb1, 0x6e, 0xd3, 0x40,
|
||||||
0x18, 0xc6, 0x73, 0x4e, 0xeb, 0x84, 0xeb, 0x1f, 0xcc, 0x51, 0x55, 0x87, 0x41, 0x57, 0x8b, 0x29,
|
0x1c, 0xc6, 0x73, 0x4e, 0xe3, 0xa4, 0x97, 0xb6, 0x98, 0xa3, 0xaa, 0x8c, 0x41, 0x8e, 0xc5, 0x14,
|
||||||
0x62, 0xb0, 0x45, 0xbb, 0xb1, 0xb5, 0x71, 0x84, 0x22, 0x24, 0xd7, 0xba, 0x34, 0x62, 0x44, 0x4e,
|
0x31, 0xd8, 0xa2, 0xdd, 0xd8, 0xda, 0x38, 0x42, 0x11, 0x92, 0x6b, 0x39, 0x8d, 0x18, 0x2b, 0x27,
|
||||||
0xee, 0x30, 0xa7, 0xb6, 0x77, 0xd6, 0xf9, 0x0c, 0xea, 0xc6, 0x88, 0xfa, 0x1d, 0x3a, 0xc1, 0x67,
|
0x77, 0x98, 0x53, 0xdb, 0x3b, 0xeb, 0x7c, 0x06, 0xba, 0x31, 0xa2, 0xbe, 0x43, 0xc5, 0x00, 0x4f,
|
||||||
0x60, 0xe0, 0x13, 0x74, 0x64, 0x64, 0xaa, 0x88, 0x3f, 0x08, 0x42, 0x3e, 0x87, 0x90, 0xa1, 0x8b,
|
0xc1, 0x13, 0x74, 0x64, 0x42, 0x4c, 0x15, 0xf1, 0x93, 0xa0, 0x3b, 0x9b, 0xe0, 0x81, 0xc5, 0xfa,
|
||||||
0xf5, 0x3e, 0xcf, 0xef, 0xa7, 0xf7, 0xb5, 0x65, 0xf8, 0x2a, 0x17, 0xe6, 0x43, 0x35, 0x0b, 0xe7,
|
0x7f, 0xdf, 0xef, 0xf3, 0xe7, 0xff, 0x5f, 0x32, 0x7c, 0x99, 0x51, 0xf9, 0xae, 0x5c, 0xfa, 0x2b,
|
||||||
0xea, 0x32, 0x9a, 0x2b, 0x69, 0x32, 0x21, 0xb9, 0x66, 0xeb, 0x63, 0x56, 0x88, 0xc8, 0x5c, 0x15,
|
0x7e, 0x15, 0xac, 0x38, 0x93, 0x29, 0x65, 0x44, 0xe0, 0xf6, 0x98, 0xe6, 0x34, 0x90, 0xd7, 0x39,
|
||||||
0xbc, 0x8c, 0x4c, 0x56, 0x9e, 0xdb, 0x47, 0x58, 0x68, 0x65, 0x14, 0x7a, 0xfc, 0xdf, 0x0a, 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 0xa1, 0x19,
|
||||||
0x72, 0xe6, 0xef, 0x7e, 0xf9, 0x4a, 0x3a, 0x3f, 0xbe, 0x91, 0xe5, 0xdb, 0x9e, 0xe0, 0xdb, 0x05,
|
0x1f, 0x2f, 0xe6, 0xd3, 0xd0, 0xda, 0x72, 0xac, 0x9b, 0x5b, 0x6f, 0xa7, 0xc6, 0x71, 0x5a, 0x16,
|
||||||
0xe9, 0xfc, 0x5a, 0x90, 0xce, 0xe7, 0x9a, 0x80, 0xdb, 0x9a, 0x80, 0x9f, 0x35, 0x01, 0xbf, 0x6b,
|
0x75, 0xbb, 0xa2, 0xaa, 0xbd, 0xd7, 0x7e, 0x5b, 0x61, 0xca, 0x32, 0x67, 0xef, 0xf3, 0x57, 0xb7,
|
||||||
0x02, 0x66, 0xae, 0xfd, 0xb5, 0x47, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x82, 0xe5, 0xdf,
|
0xf3, 0xfd, 0x9b, 0xdb, 0x5c, 0x73, 0x62, 0xdf, 0xad, 0xdd, 0xce, 0xaf, 0xb5, 0xdb, 0xf9, 0x54,
|
||||||
0x5e, 0x02, 0x00, 0x00,
|
0xb9, 0xe0, 0xae, 0x72, 0xc1, 0x8f, 0xca, 0x05, 0xbf, 0x2b, 0x17, 0x2c, 0x4d, 0xfd, 0x6f, 0x1c,
|
||||||
|
0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0x22, 0xfa, 0xb5, 0x46, 0x9f, 0x02, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ enum Status {
|
|||||||
RUNNING = 2 [(gogoproto.enumvalue_customname) = "StatusRunning"];
|
RUNNING = 2 [(gogoproto.enumvalue_customname) = "StatusRunning"];
|
||||||
STOPPED = 3 [(gogoproto.enumvalue_customname) = "StatusStopped"];
|
STOPPED = 3 [(gogoproto.enumvalue_customname) = "StatusStopped"];
|
||||||
PAUSED = 4 [(gogoproto.enumvalue_customname) = "StatusPaused"];
|
PAUSED = 4 [(gogoproto.enumvalue_customname) = "StatusPaused"];
|
||||||
|
PAUSING = 5 [(gogoproto.enumvalue_customname) = "StatusPausing"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message Process {
|
message Process {
|
||||||
@ -25,4 +26,5 @@ message Process {
|
|||||||
string stdout = 6;
|
string stdout = 6;
|
||||||
string stderr = 7;
|
string stderr = 7;
|
||||||
bool terminal = 8;
|
bool terminal = 8;
|
||||||
|
uint32 exit_status = 9;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ func TestCheckpointLeaveRunning(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if status != Running {
|
if status.Status != Running {
|
||||||
t.Errorf("expected status %q but received %q", Running, status)
|
t.Errorf("expected status %q but received %q", Running, status)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func deleteContainer(ctx context.Context, client *containerd.Client, id string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if status == containerd.Stopped || status == containerd.Created {
|
if status.Status == containerd.Stopped || status.Status == containerd.Created {
|
||||||
if _, err := task.Delete(ctx); err != nil {
|
if _, err := task.Delete(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1028,13 +1028,13 @@ func TestWaitStoppedTask(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// wait for the task to stop then call wait again
|
// wait for the task to stop then call wait again
|
||||||
<-statusC
|
<-statusC
|
||||||
_, err = task.Wait(ctx)
|
status, err := task.Wait(ctx)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Error("Wait after task exits should return an error")
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !errdefs.IsUnavailable(err) {
|
if status != 7 {
|
||||||
t.Errorf("Wait should return %q when task Stopped: %v", errdefs.ErrUnavailable, err)
|
t.Errorf("exit status from stopped task should be 7 but received %d", status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1119,13 +1119,13 @@ func TestWaitStoppedProcess(t *testing.T) {
|
|||||||
// wait for the exec to return
|
// wait for the exec to return
|
||||||
<-processStatusC
|
<-processStatusC
|
||||||
// try to wait on the process after it has stopped
|
// try to wait on the process after it has stopped
|
||||||
_, err = process.Wait(ctx)
|
status, err := process.Wait(ctx)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Error("Wait after process exits should return an error")
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !errdefs.IsUnavailable(err) {
|
if status != 6 {
|
||||||
t.Errorf("Wait should return %q when process has exited: %v", errdefs.ErrUnavailable, err)
|
t.Errorf("exit status from stopped process should be 6 but received %d", status)
|
||||||
}
|
}
|
||||||
if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
|
if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
@ -49,7 +49,8 @@ func (p *Process) State(ctx context.Context) (runtime.State, error) {
|
|||||||
status = runtime.StoppedStatus
|
status = runtime.StoppedStatus
|
||||||
case task.StatusPaused:
|
case task.StatusPaused:
|
||||||
status = runtime.PausedStatus
|
status = runtime.PausedStatus
|
||||||
// TODO: containerd.DeletedStatus
|
case task.StatusPausing:
|
||||||
|
status = runtime.PausingStatus
|
||||||
}
|
}
|
||||||
return runtime.State{
|
return runtime.State{
|
||||||
Pid: response.Pid,
|
Pid: response.Pid,
|
||||||
@ -58,6 +59,7 @@ func (p *Process) State(ctx context.Context) (runtime.State, error) {
|
|||||||
Stdout: response.Stdout,
|
Stdout: response.Stdout,
|
||||||
Stderr: response.Stderr,
|
Stderr: response.Stderr,
|
||||||
Terminal: response.Terminal,
|
Terminal: response.Terminal,
|
||||||
|
ExitStatus: response.ExitStatus,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +247,8 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.
|
|||||||
status = task.StatusStopped
|
status = task.StatusStopped
|
||||||
case "paused":
|
case "paused":
|
||||||
status = task.StatusPaused
|
status = task.StatusPaused
|
||||||
|
case "pausing":
|
||||||
|
status = task.StatusPausing
|
||||||
}
|
}
|
||||||
sio := p.Stdio()
|
sio := p.Stdio()
|
||||||
return &shimapi.StateResponse{
|
return &shimapi.StateResponse{
|
||||||
@ -258,6 +260,7 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.
|
|||||||
Stdout: sio.stdout,
|
Stdout: sio.stdout,
|
||||||
Stderr: sio.stderr,
|
Stderr: sio.stderr,
|
||||||
Terminal: sio.terminal,
|
Terminal: sio.terminal,
|
||||||
|
ExitStatus: uint32(p.ExitStatus()),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +157,7 @@ type StateResponse struct {
|
|||||||
Stdout string `protobuf:"bytes,6,opt,name=stdout,proto3" json:"stdout,omitempty"`
|
Stdout string `protobuf:"bytes,6,opt,name=stdout,proto3" json:"stdout,omitempty"`
|
||||||
Stderr string `protobuf:"bytes,7,opt,name=stderr,proto3" json:"stderr,omitempty"`
|
Stderr string `protobuf:"bytes,7,opt,name=stderr,proto3" json:"stderr,omitempty"`
|
||||||
Terminal bool `protobuf:"varint,8,opt,name=terminal,proto3" json:"terminal,omitempty"`
|
Terminal bool `protobuf:"varint,8,opt,name=terminal,proto3" json:"terminal,omitempty"`
|
||||||
|
ExitStatus uint32 `protobuf:"varint,9,opt,name=exit_status,json=exitStatus,proto3" json:"exit_status,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *StateResponse) Reset() { *m = StateResponse{} }
|
func (m *StateResponse) Reset() { *m = StateResponse{} }
|
||||||
@ -1183,6 +1184,11 @@ func (m *StateResponse) MarshalTo(dAtA []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
if m.ExitStatus != 0 {
|
||||||
|
dAtA[i] = 0x48
|
||||||
|
i++
|
||||||
|
i = encodeVarintShim(dAtA, i, uint64(m.ExitStatus))
|
||||||
|
}
|
||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1660,6 +1666,9 @@ func (m *StateResponse) Size() (n int) {
|
|||||||
if m.Terminal {
|
if m.Terminal {
|
||||||
n += 2
|
n += 2
|
||||||
}
|
}
|
||||||
|
if m.ExitStatus != 0 {
|
||||||
|
n += 1 + sovShim(uint64(m.ExitStatus))
|
||||||
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1895,6 +1904,7 @@ func (this *StateResponse) String() string {
|
|||||||
`Stdout:` + fmt.Sprintf("%v", this.Stdout) + `,`,
|
`Stdout:` + fmt.Sprintf("%v", this.Stdout) + `,`,
|
||||||
`Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`,
|
`Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`,
|
||||||
`Terminal:` + fmt.Sprintf("%v", this.Terminal) + `,`,
|
`Terminal:` + fmt.Sprintf("%v", this.Terminal) + `,`,
|
||||||
|
`ExitStatus:` + fmt.Sprintf("%v", this.ExitStatus) + `,`,
|
||||||
`}`,
|
`}`,
|
||||||
}, "")
|
}, "")
|
||||||
return s
|
return s
|
||||||
@ -3331,6 +3341,25 @@ func (m *StateResponse) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Terminal = bool(v != 0)
|
m.Terminal = bool(v != 0)
|
||||||
|
case 9:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field ExitStatus", wireType)
|
||||||
|
}
|
||||||
|
m.ExitStatus = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowShim
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.ExitStatus |= (uint32(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipShim(dAtA[iNdEx:])
|
skippy, err := skipShim(dAtA[iNdEx:])
|
||||||
@ -4311,72 +4340,73 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptorShim = []byte{
|
var fileDescriptorShim = []byte{
|
||||||
// 1072 bytes of a gzipped FileDescriptorProto
|
// 1078 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x5f, 0x6f, 0xe3, 0x44,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4f, 0x6f, 0xe3, 0x44,
|
||||||
0x10, 0xaf, 0xf3, 0xbf, 0x13, 0x52, 0xda, 0xa5, 0x57, 0x7c, 0x39, 0x29, 0x8d, 0xfc, 0x50, 0x05,
|
0x14, 0xaf, 0xf3, 0x3f, 0x2f, 0xa4, 0xb4, 0x43, 0xb7, 0x78, 0xb3, 0x52, 0x1a, 0xf9, 0x50, 0x05,
|
||||||
0xa1, 0x73, 0x68, 0x8a, 0xee, 0x38, 0x90, 0x90, 0xda, 0xde, 0x09, 0x55, 0x50, 0x5d, 0xe5, 0xf6,
|
0xa1, 0x75, 0x68, 0x8a, 0x76, 0x59, 0x90, 0x90, 0xda, 0xee, 0x0a, 0x55, 0x50, 0x6d, 0xe5, 0x76,
|
||||||
0x00, 0x81, 0x50, 0xe5, 0xc6, 0xdb, 0x64, 0xd5, 0xc4, 0xeb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 0x76, 0xe5, 0xe0, 0xd7, 0x11, 0x66, 0x1c, 0x6d, 0x41,
|
0xeb, 0x07, 0x21, 0x76, 0x39, 0x3e, 0x75, 0xd9, 0xa5, 0x83, 0x5f, 0x47, 0x98, 0x71, 0xb4, 0x09,
|
||||||
0x8e, 0x78, 0xa6, 0xd1, 0x34, 0x5a, 0xab, 0x07, 0xa5, 0xd1, 0x9b, 0xed, 0xdc, 0xd1, 0x73, 0x27,
|
0x39, 0xe2, 0x99, 0x46, 0xcb, 0x68, 0x57, 0xf7, 0x4b, 0x77, 0x6f, 0xb6, 0x72, 0x87, 0xcf, 0x9d,
|
||||||
0x47, 0x3c, 0xb4, 0x05, 0xa5, 0x8b, 0xc8, 0xf7, 0x06, 0xd8, 0xcc, 0x89, 0x33, 0x47, 0x4b, 0xc8,
|
0x1c, 0xf1, 0xd0, 0x26, 0x94, 0xce, 0x23, 0xdf, 0x1b, 0x62, 0x33, 0x27, 0xd6, 0x1c, 0x6d, 0x21,
|
||||||
0x84, 0xb2, 0xce, 0xa0, 0x99, 0x97, 0x07, 0x63, 0x11, 0xb5, 0xa1, 0x14, 0x52, 0xca, 0x2f, 0x99,
|
0x13, 0xca, 0x3a, 0x83, 0x66, 0x5e, 0x2e, 0x8c, 0x4d, 0xd4, 0x81, 0x52, 0x48, 0x29, 0xbf, 0x60,
|
||||||
0x59, 0x68, 0xe6, 0x5b, 0xd5, 0xce, 0xfb, 0x76, 0x2c, 0xeb, 0xd2, 0x25, 0xfb, 0x58, 0x84, 0xe2,
|
0x66, 0xa1, 0x95, 0x6f, 0xd7, 0xba, 0xef, 0xdb, 0xb1, 0xac, 0xcb, 0x90, 0xec, 0x23, 0x71, 0x15,
|
||||||
0x68, 0x18, 0xaa, 0x43, 0x85, 0xe3, 0x70, 0x48, 0x7c, 0x77, 0x60, 0x16, 0x9b, 0x46, 0xab, 0xe2,
|
0x47, 0xc3, 0x50, 0x03, 0x2a, 0x1c, 0x87, 0x23, 0xe2, 0xbb, 0x43, 0xb3, 0xd8, 0x32, 0xda, 0x15,
|
||||||
0x4c, 0x64, 0xb4, 0x09, 0x45, 0xc6, 0x3d, 0xe2, 0x9b, 0x25, 0x79, 0x89, 0x12, 0x84, 0x53, 0x8c,
|
0x67, 0x62, 0xa3, 0x0d, 0x28, 0x32, 0xee, 0x11, 0xdf, 0x2c, 0xc9, 0x43, 0x94, 0x21, 0x82, 0x62,
|
||||||
0x7b, 0x34, 0xe2, 0x66, 0x59, 0x39, 0xa5, 0x24, 0xbd, 0x8f, 0xc3, 0xd0, 0xac, 0x4c, 0xf6, 0x71,
|
0xdc, 0xa3, 0x11, 0x37, 0xcb, 0x2a, 0x28, 0x65, 0xe9, 0x79, 0x1c, 0x86, 0x66, 0x65, 0x32, 0x8f,
|
||||||
0x18, 0xa2, 0x06, 0x40, 0xb7, 0x8f, 0xbb, 0x57, 0x01, 0x25, 0x3e, 0x37, 0x57, 0xe5, 0x59, 0x6c,
|
0xc3, 0x10, 0x35, 0x01, 0x7a, 0x03, 0xdc, 0xbb, 0x0c, 0x28, 0xf1, 0xb9, 0x59, 0x95, 0x6b, 0xb1,
|
||||||
0x07, 0x7d, 0x08, 0x1b, 0x81, 0x1b, 0x62, 0x9f, 0x9f, 0xc7, 0x60, 0x20, 0x61, 0xeb, 0xea, 0xe0,
|
0x19, 0xf4, 0x21, 0xac, 0x07, 0x6e, 0x88, 0x7d, 0x7e, 0x16, 0x83, 0x81, 0x84, 0xad, 0xa9, 0x85,
|
||||||
0x70, 0x0a, 0xb6, 0xa1, 0x4c, 0x03, 0x4e, 0xa8, 0xcf, 0xcc, 0x6a, 0xd3, 0x68, 0x55, 0x3b, 0x9b,
|
0x83, 0x29, 0xd8, 0x86, 0x32, 0x0d, 0x38, 0xa1, 0x3e, 0x33, 0x6b, 0x2d, 0xa3, 0x5d, 0xeb, 0x6e,
|
||||||
0xb6, 0xa2, 0xd9, 0x1e, 0xd3, 0x6c, 0xef, 0xfb, 0xb7, 0xce, 0x18, 0x64, 0x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3b, 0x1c, 0xca, 0x44,
|
||||||
0xc3, 0xda, 0xe1, 0x80, 0x32, 0x7c, 0xf4, 0x32, 0x03, 0x77, 0x2a, 0x38, 0x55, 0x87, 0x4a, 0xb0,
|
0x54, 0x1c, 0x31, 0xb4, 0x3e, 0x87, 0xd5, 0x83, 0x21, 0x65, 0xf8, 0xf0, 0x65, 0x06, 0x72, 0xd5,
|
||||||
0x3e, 0x80, 0x77, 0xbf, 0x22, 0x8c, 0x9f, 0x10, 0x2f, 0xb5, 0xf4, 0x77, 0x60, 0x7d, 0x0a, 0xd5,
|
0xed, 0x95, 0x50, 0x95, 0x61, 0x7d, 0x00, 0xef, 0x7e, 0x45, 0x18, 0x3f, 0x26, 0x5e, 0xea, 0xdb,
|
||||||
0x44, 0x21, 0x28, 0x04, 0xc4, 0x63, 0xa6, 0xd1, 0xcc, 0xb7, 0x6a, 0x8e, 0x5c, 0x5b, 0xdf, 0xc3,
|
0xd8, 0x86, 0xb5, 0x29, 0x54, 0x33, 0x89, 0xa0, 0x10, 0x10, 0x8f, 0x99, 0x46, 0x2b, 0xdf, 0xae,
|
||||||
0x83, 0x69, 0x07, 0x89, 0xb7, 0x5d, 0x01, 0x76, 0x79, 0x5f, 0x99, 0x76, 0xe4, 0x3a, 0xde, 0x60,
|
0x3b, 0x72, 0x6c, 0x7d, 0x0f, 0x0f, 0xa6, 0x25, 0x26, 0x5e, 0x97, 0x05, 0xd8, 0xe5, 0x03, 0xb5,
|
||||||
0x72, 0x59, 0x1a, 0xcc, 0x63, 0x58, 0x3f, 0xed, 0x93, 0xe1, 0x91, 0x7f, 0x49, 0x27, 0x4e, 0x3c,
|
0xb5, 0x23, 0xc7, 0xf1, 0x0a, 0x94, 0xcb, 0x52, 0x81, 0x1e, 0xc3, 0xda, 0xc9, 0x80, 0x8c, 0x0e,
|
||||||
0x84, 0x8a, 0x18, 0x69, 0xe7, 0xd3, 0xf6, 0x51, 0x16, 0xf2, 0x09, 0xf1, 0xac, 0x2f, 0x60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0xe5, 0x8f, 0xb7, 0x8d, 0x95, 0x9f, 0x47, 0x0d, 0xe3, 0x6e, 0xd4, 0x30, 0x7e, 0x1f, 0x35,
|
0x85, 0xbb, 0x7f, 0x74, 0xfb, 0xb6, 0xb9, 0xf2, 0xe7, 0xdb, 0xe6, 0xca, 0xcf, 0x77, 0x4d, 0xe3,
|
||||||
0x8c, 0xbf, 0x46, 0x0d, 0xe3, 0xbb, 0xbd, 0xe5, 0xfe, 0xdb, 0xfa, 0x4c, 0xfc, 0x5e, 0x94, 0xa4,
|
0xf6, 0xae, 0x69, 0xfc, 0x71, 0xd7, 0x34, 0xfe, 0xbe, 0x6b, 0x1a, 0xdf, 0xed, 0x2e, 0xf7, 0xef,
|
||||||
0xf9, 0xbd, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x05, 0x95, 0x8a, 0x43, 0xab, 0x0d, 0x00, 0x00,
|
0xd8, 0x67, 0xe2, 0xf7, 0xbc, 0x24, 0xb7, 0xdf, 0xfd, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x53, 0xf2,
|
||||||
|
0x71, 0x3d, 0xcc, 0x0d, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,7 @@ message StateResponse {
|
|||||||
string stdout = 6;
|
string stdout = 6;
|
||||||
string stderr = 7;
|
string stderr = 7;
|
||||||
bool terminal = 8;
|
bool terminal = 8;
|
||||||
|
uint32 exit_status = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message KillRequest {
|
message KillRequest {
|
||||||
|
@ -66,6 +66,8 @@ func (t *Task) State(ctx context.Context) (runtime.State, error) {
|
|||||||
status = runtime.StoppedStatus
|
status = runtime.StoppedStatus
|
||||||
case task.StatusPaused:
|
case task.StatusPaused:
|
||||||
status = runtime.PausedStatus
|
status = runtime.PausedStatus
|
||||||
|
case task.StatusPausing:
|
||||||
|
status = runtime.PausingStatus
|
||||||
}
|
}
|
||||||
return runtime.State{
|
return runtime.State{
|
||||||
Pid: response.Pid,
|
Pid: response.Pid,
|
||||||
@ -74,6 +76,7 @@ func (t *Task) State(ctx context.Context) (runtime.State, error) {
|
|||||||
Stdout: response.Stdout,
|
Stdout: response.Stdout,
|
||||||
Stderr: response.Stderr,
|
Stderr: response.Stderr,
|
||||||
Terminal: response.Terminal,
|
Terminal: response.Terminal,
|
||||||
|
ExitStatus: response.ExitStatus,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
process.go
15
process.go
@ -76,8 +76,12 @@ func (p *process) Wait(ctx context.Context) (uint32, error) {
|
|||||||
return UnknownExitStatus, err
|
return UnknownExitStatus, err
|
||||||
}
|
}
|
||||||
// first check if the task has exited
|
// first check if the task has exited
|
||||||
if status, _ := p.Status(ctx); status == Stopped {
|
status, err := p.Status(ctx)
|
||||||
return UnknownExitStatus, errdefs.ErrUnavailable
|
if err != nil {
|
||||||
|
return UnknownExitStatus, errdefs.FromGRPC(err)
|
||||||
|
}
|
||||||
|
if status.Status == Stopped {
|
||||||
|
return status.ExitStatus, nil
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
evt, err := eventstream.Recv()
|
evt, err := eventstream.Recv()
|
||||||
@ -146,7 +150,10 @@ func (p *process) Status(ctx context.Context) (Status, error) {
|
|||||||
ExecID: p.id,
|
ExecID: p.id,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errdefs.FromGRPC(err)
|
return Status{}, errdefs.FromGRPC(err)
|
||||||
}
|
}
|
||||||
return Status(strings.ToLower(r.Process.Status.String())), nil
|
return Status{
|
||||||
|
Status: ProcessStatus(strings.ToLower(r.Process.Status.String())),
|
||||||
|
ExitStatus: r.Process.ExitStatus,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ const (
|
|||||||
StoppedStatus
|
StoppedStatus
|
||||||
DeletedStatus
|
DeletedStatus
|
||||||
PausedStatus
|
PausedStatus
|
||||||
|
PausingStatus
|
||||||
)
|
)
|
||||||
|
|
||||||
type State struct {
|
type State struct {
|
||||||
@ -75,6 +76,9 @@ type State struct {
|
|||||||
Status Status
|
Status Status
|
||||||
// Pid is the main process id for the container
|
// Pid is the main process id for the container
|
||||||
Pid uint32
|
Pid uint32
|
||||||
|
// ExitStatus of the process
|
||||||
|
// Only vaid if the Status is Stopped
|
||||||
|
ExitStatus uint32
|
||||||
Stdin string
|
Stdin string
|
||||||
Stdout string
|
Stdout string
|
||||||
Stderr string
|
Stderr string
|
||||||
|
@ -227,6 +227,8 @@ func processFromContainerd(ctx context.Context, p runtime.Process) (*task.Proces
|
|||||||
status = task.StatusStopped
|
status = task.StatusStopped
|
||||||
case runtime.PausedStatus:
|
case runtime.PausedStatus:
|
||||||
status = task.StatusPaused
|
status = task.StatusPaused
|
||||||
|
case runtime.PausingStatus:
|
||||||
|
status = task.StatusPausing
|
||||||
default:
|
default:
|
||||||
log.G(ctx).WithField("status", state.Status).Warn("unknown status")
|
log.G(ctx).WithField("status", state.Status).Warn("unknown status")
|
||||||
}
|
}
|
||||||
@ -238,6 +240,7 @@ func processFromContainerd(ctx context.Context, p runtime.Process) (*task.Proces
|
|||||||
Stdout: state.Stdout,
|
Stdout: state.Stdout,
|
||||||
Stderr: state.Stderr,
|
Stderr: state.Stderr,
|
||||||
Terminal: state.Terminal,
|
Terminal: state.Terminal,
|
||||||
|
ExitStatus: state.ExitStatus,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
task.go
33
task.go
@ -28,14 +28,19 @@ import (
|
|||||||
|
|
||||||
const UnknownExitStatus = 255
|
const UnknownExitStatus = 255
|
||||||
|
|
||||||
type Status string
|
type Status struct {
|
||||||
|
Status ProcessStatus
|
||||||
|
ExitStatus uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProcessStatus string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Running Status = "running"
|
Running ProcessStatus = "running"
|
||||||
Created Status = "created"
|
Created ProcessStatus = "created"
|
||||||
Stopped Status = "stopped"
|
Stopped ProcessStatus = "stopped"
|
||||||
Paused Status = "paused"
|
Paused ProcessStatus = "paused"
|
||||||
Pausing Status = "pausing"
|
Pausing ProcessStatus = "pausing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IOCloseInfo struct {
|
type IOCloseInfo struct {
|
||||||
@ -146,12 +151,14 @@ func (t *task) Status(ctx context.Context) (Status, error) {
|
|||||||
ContainerID: t.id,
|
ContainerID: t.id,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errdefs.FromGRPC(err)
|
return Status{}, errdefs.FromGRPC(err)
|
||||||
}
|
}
|
||||||
return Status(strings.ToLower(r.Process.Status.String())), nil
|
return Status{
|
||||||
|
Status: ProcessStatus(strings.ToLower(r.Process.Status.String())),
|
||||||
|
ExitStatus: r.Process.ExitStatus,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait is a blocking call that will wait for the task to exit and return the exit status
|
|
||||||
func (t *task) Wait(ctx context.Context) (uint32, error) {
|
func (t *task) Wait(ctx context.Context) (uint32, error) {
|
||||||
eventstream, err := t.client.EventService().Subscribe(ctx, &eventsapi.SubscribeRequest{
|
eventstream, err := t.client.EventService().Subscribe(ctx, &eventsapi.SubscribeRequest{
|
||||||
Filters: []string{"topic==" + runtime.TaskExitEventTopic},
|
Filters: []string{"topic==" + runtime.TaskExitEventTopic},
|
||||||
@ -160,8 +167,12 @@ func (t *task) Wait(ctx context.Context) (uint32, error) {
|
|||||||
return UnknownExitStatus, errdefs.FromGRPC(err)
|
return UnknownExitStatus, errdefs.FromGRPC(err)
|
||||||
}
|
}
|
||||||
// first check if the task has exited
|
// first check if the task has exited
|
||||||
if status, _ := t.Status(ctx); status == Stopped {
|
status, err := t.Status(ctx)
|
||||||
return UnknownExitStatus, errdefs.ErrUnavailable
|
if err != nil {
|
||||||
|
return UnknownExitStatus, errdefs.FromGRPC(err)
|
||||||
|
}
|
||||||
|
if status.Status == Stopped {
|
||||||
|
return status.ExitStatus, nil
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
evt, err := eventstream.Recv()
|
evt, err := eventstream.Recv()
|
||||||
|
@ -45,6 +45,7 @@ func (p *process) State(ctx context.Context) (runtime.State, error) {
|
|||||||
Stdout: p.io.src.Stdout,
|
Stdout: p.io.src.Stdout,
|
||||||
Stderr: p.io.src.Stderr,
|
Stderr: p.io.src.Stderr,
|
||||||
Terminal: p.io.src.Terminal,
|
Terminal: p.io.src.Terminal,
|
||||||
|
ExitStatus: p.exitCode,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,14 @@ func (t *task) ID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *task) State(ctx context.Context) (runtime.State, error) {
|
func (t *task) State(ctx context.Context) (runtime.State, error) {
|
||||||
var status runtime.Status
|
var (
|
||||||
|
status runtime.Status
|
||||||
|
exitStatus uint32
|
||||||
|
)
|
||||||
|
|
||||||
if p := t.getProcess(t.id); p != nil {
|
if p := t.getProcess(t.id); p != nil {
|
||||||
status = p.Status()
|
status = p.Status()
|
||||||
|
exitStatus = p.exitCode
|
||||||
} else {
|
} else {
|
||||||
status = t.getStatus()
|
status = t.getStatus()
|
||||||
}
|
}
|
||||||
@ -59,6 +63,7 @@ func (t *task) State(ctx context.Context) (runtime.State, error) {
|
|||||||
Stdout: t.io.src.Stdout,
|
Stdout: t.io.src.Stdout,
|
||||||
Stderr: t.io.src.Stderr,
|
Stderr: t.io.src.Stderr,
|
||||||
Terminal: t.io.src.Terminal,
|
Terminal: t.io.src.Terminal,
|
||||||
|
ExitStatus: exitStatus,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user