Skip to content

Commit 7966a66

Browse files
committed
Cleanup code
Signed-off-by: Shiming Zhang <[email protected]>
1 parent 3aae93a commit 7966a66

5 files changed

Lines changed: 11 additions & 25 deletions

File tree

pkg/process/io.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,6 @@ func NewBinaryIO(ctx context.Context, id string, uri *url.URL) (_ runc.IO, err e
252252
return nil, err
253253
}
254254

255-
var args []string
256-
for k, vs := range uri.Query() {
257-
args = append(args, k)
258-
if len(vs) > 0 {
259-
args = append(args, vs[0])
260-
}
261-
}
262-
263255
var closers []func() error
264256
defer func() {
265257
if err == nil {
@@ -290,12 +282,7 @@ func NewBinaryIO(ctx context.Context, id string, uri *url.URL) (_ runc.IO, err e
290282
}
291283
closers = append(closers, r.Close, w.Close)
292284

293-
cmd := exec.Command(uri.Path, args...)
294-
cmd.Env = append(cmd.Env,
295-
"CONTAINER_ID="+id,
296-
"CONTAINER_NAMESPACE="+ns,
297-
)
298-
285+
cmd := NewBinaryCmd(uri, id, ns)
299286
cmd.ExtraFiles = append(cmd.ExtraFiles, out.r, serr.r, w)
300287
// don't need to register this with the reaper or wait when
301288
// running inside a shim

runtime/io.go renamed to pkg/process/io_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package runtime
17+
package process
1818

1919
import (
2020
"net/url"

runtime/v1/shim/service_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
"github.com/containerd/console"
2828
"github.com/containerd/containerd/namespaces"
29-
"github.com/containerd/containerd/runtime"
29+
"github.com/containerd/containerd/pkg/process"
3030
"github.com/containerd/fifo"
3131
"github.com/pkg/errors"
3232
)
@@ -75,14 +75,14 @@ func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console
7575
return nil, err
7676
}
7777

78-
cmd := runtime.NewBinaryCmd(uri, id, ns)
78+
cmd := process.NewBinaryCmd(uri, id, ns)
7979

8080
// In case of unexpected errors during logging binary start, close open pipes
8181
var filesToClose []*os.File
8282

8383
defer func() {
8484
if retErr != nil {
85-
runtime.CloseFiles(filesToClose...)
85+
process.CloseFiles(filesToClose...)
8686
}
8787
}()
8888

runtime/v1/shim/service_unix.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
"github.com/containerd/console"
3030
"github.com/containerd/containerd/namespaces"
31-
"github.com/containerd/containerd/runtime"
31+
"github.com/containerd/containerd/pkg/process"
3232
"github.com/containerd/fifo"
3333
"github.com/pkg/errors"
3434
)
@@ -63,15 +63,14 @@ func (p *unixPlatform) CopyConsole(ctx context.Context, console console.Console,
6363
if err != nil {
6464
return nil, err
6565
}
66-
67-
cmd := runtime.NewBinaryCmd(uri, id, ns)
66+
cmd := process.NewBinaryCmd(uri, id, ns)
6867

6968
// In case of unexpected errors during logging binary start, close open pipes
7069
var filesToClose []*os.File
7170

7271
defer func() {
7372
if retErr != nil {
74-
runtime.CloseFiles(filesToClose...)
73+
process.CloseFiles(filesToClose...)
7574
}
7675
}()
7776

runtime/v2/runc/platform.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import (
2828

2929
"github.com/containerd/console"
3030
"github.com/containerd/containerd/namespaces"
31+
"github.com/containerd/containerd/pkg/process"
3132
"github.com/containerd/containerd/pkg/stdio"
32-
"github.com/containerd/containerd/runtime"
3333
"github.com/containerd/fifo"
3434
"github.com/pkg/errors"
3535
)
@@ -99,14 +99,14 @@ func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console
9999
return nil, err
100100
}
101101

102-
cmd := runtime.NewBinaryCmd(uri, id, ns)
102+
cmd := process.NewBinaryCmd(uri, id, ns)
103103

104104
// In case of unexpected errors during logging binary start, close open pipes
105105
var filesToClose []*os.File
106106

107107
defer func() {
108108
if retErr != nil {
109-
runtime.CloseFiles(filesToClose...)
109+
process.CloseFiles(filesToClose...)
110110
}
111111
}()
112112

0 commit comments

Comments
 (0)