@@ -34,8 +34,8 @@ import (
34
34
type Sandbox interface {
35
35
// ID is a sandbox identifier
36
36
ID () string
37
- // PID returns sandbox's process PID or error if its not yet started.
38
- PID () ( uint32 , error )
37
+ // Metadata returns metadata of the sandbox
38
+ Metadata () api. Sandbox
39
39
// NewContainer creates new container that will belong to this sandbox
40
40
NewContainer (ctx context.Context , id string , opts ... NewContainerOpts ) (Container , error )
41
41
// Labels returns the labels set on the sandbox
@@ -51,7 +51,6 @@ type Sandbox interface {
51
51
}
52
52
53
53
type sandboxClient struct {
54
- pid * uint32
55
54
client * Client
56
55
metadata api.Sandbox
57
56
}
@@ -60,12 +59,8 @@ func (s *sandboxClient) ID() string {
60
59
return s .metadata .ID
61
60
}
62
61
63
- func (s * sandboxClient ) PID () (uint32 , error ) {
64
- if s .pid == nil {
65
- return 0 , fmt .Errorf ("sandbox not started" )
66
- }
67
-
68
- return * s .pid , nil
62
+ func (s * sandboxClient ) Metadata () api.Sandbox {
63
+ return s .metadata
69
64
}
70
65
71
66
func (s * sandboxClient ) NewContainer (ctx context.Context , id string , opts ... NewContainerOpts ) (Container , error ) {
@@ -82,12 +77,11 @@ func (s *sandboxClient) Labels(ctx context.Context) (map[string]string, error) {
82
77
}
83
78
84
79
func (s * sandboxClient ) Start (ctx context.Context ) error {
85
- resp , err := s .client .SandboxController (s .metadata .Sandboxer ).Start (ctx , s .ID ())
80
+ _ , err := s .client .SandboxController (s .metadata .Sandboxer ).Start (ctx , s .ID ())
86
81
if err != nil {
87
82
return err
88
83
}
89
84
90
- s .pid = & resp .Pid
91
85
return nil
92
86
}
93
87
@@ -154,7 +148,6 @@ func (c *Client) NewSandbox(ctx context.Context, sandboxID string, opts ...NewSa
154
148
}
155
149
156
150
return & sandboxClient {
157
- pid : nil , // Not yet started
158
151
client : c ,
159
152
metadata : metadata ,
160
153
}, nil
@@ -167,13 +160,7 @@ func (c *Client) LoadSandbox(ctx context.Context, id string) (Sandbox, error) {
167
160
return nil , err
168
161
}
169
162
170
- status , err := c .SandboxController (sandbox .Sandboxer ).Status (ctx , id , false )
171
- if err != nil {
172
- return nil , fmt .Errorf ("failed to load sandbox %s, status request failed: %w" , id , err )
173
- }
174
-
175
163
return & sandboxClient {
176
- pid : & status .Pid ,
177
164
client : c ,
178
165
metadata : sandbox ,
179
166
}, nil
0 commit comments