Merge pull request #7499 from Iceber/cleanup_shim_flag
runtime/v2/shim: clean up the use of containerdBinary
This commit is contained in:
commit
96a39ad53b
@ -70,7 +70,7 @@ type manager struct {
|
|||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCommand(ctx context.Context, id, containerdBinary, containerdAddress, containerdTTRPCAddress string, debug bool) (*exec.Cmd, error) {
|
func newCommand(ctx context.Context, id, containerdAddress, containerdTTRPCAddress string, debug bool) (*exec.Cmd, error) {
|
||||||
ns, err := namespaces.NamespaceRequired(ctx)
|
ns, err := namespaces.NamespaceRequired(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -118,7 +118,7 @@ func (m manager) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (manager) Start(ctx context.Context, id string, opts shim.StartOpts) (_ string, retErr error) {
|
func (manager) Start(ctx context.Context, id string, opts shim.StartOpts) (_ string, retErr error) {
|
||||||
cmd, err := newCommand(ctx, id, opts.ContainerdBinary, opts.Address, opts.TTRPCAddress, opts.Debug)
|
cmd, err := newCommand(ctx, id, opts.Address, opts.TTRPCAddress, opts.Debug)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ type service struct {
|
|||||||
cancel func()
|
cancel func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCommand(ctx context.Context, id, containerdBinary, containerdAddress, containerdTTRPCAddress string) (*exec.Cmd, error) {
|
func newCommand(ctx context.Context, id, containerdAddress, containerdTTRPCAddress string) (*exec.Cmd, error) {
|
||||||
ns, err := namespaces.NamespaceRequired(ctx)
|
ns, err := namespaces.NamespaceRequired(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -131,7 +131,7 @@ func newCommand(ctx context.Context, id, containerdBinary, containerdAddress, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) StartShim(ctx context.Context, opts shim.StartOpts) (_ string, retErr error) {
|
func (s *service) StartShim(ctx context.Context, opts shim.StartOpts) (_ string, retErr error) {
|
||||||
cmd, err := newCommand(ctx, opts.ID, opts.ContainerdBinary, opts.Address, opts.TTRPCAddress)
|
cmd, err := newCommand(ctx, opts.ID, opts.Address, opts.TTRPCAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ type Publisher interface {
|
|||||||
// StartOpts describes shim start configuration received from containerd
|
// StartOpts describes shim start configuration received from containerd
|
||||||
type StartOpts struct {
|
type StartOpts struct {
|
||||||
ID string // TODO(2.0): Remove ID, passed directly to start for call symmetry
|
ID string // TODO(2.0): Remove ID, passed directly to start for call symmetry
|
||||||
ContainerdBinary string
|
ContainerdBinary string // TODO(2.0): Remove ContainerdBinary, use the TTRPC_ADDRESS env to forward events
|
||||||
Address string
|
Address string
|
||||||
TTRPCAddress string
|
TTRPCAddress string
|
||||||
Debug bool
|
Debug bool
|
||||||
@ -148,7 +148,9 @@ func parseFlags() {
|
|||||||
flag.StringVar(&bundlePath, "bundle", "", "path to the bundle if not workdir")
|
flag.StringVar(&bundlePath, "bundle", "", "path to the bundle if not workdir")
|
||||||
|
|
||||||
flag.StringVar(&addressFlag, "address", "", "grpc address back to main containerd")
|
flag.StringVar(&addressFlag, "address", "", "grpc address back to main containerd")
|
||||||
flag.StringVar(&containerdBinaryFlag, "publish-binary", "containerd", "path to publish binary (used for publishing events)")
|
flag.StringVar(&containerdBinaryFlag, "publish-binary", "",
|
||||||
|
fmt.Sprintf("path to publish binary (used for publishing events), but %s will ignore this flag, please use the %s env", os.Args[0], ttrpcAddressEnv),
|
||||||
|
)
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
action = flag.Arg(0)
|
action = flag.Arg(0)
|
||||||
@ -333,10 +335,9 @@ func run(ctx context.Context, manager Manager, initFunc Init, name string, confi
|
|||||||
return nil
|
return nil
|
||||||
case "start":
|
case "start":
|
||||||
opts := StartOpts{
|
opts := StartOpts{
|
||||||
ContainerdBinary: containerdBinaryFlag,
|
Address: addressFlag,
|
||||||
Address: addressFlag,
|
TTRPCAddress: ttrpcAddress,
|
||||||
TTRPCAddress: ttrpcAddress,
|
Debug: debugFlag,
|
||||||
Debug: debugFlag,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
address, err := manager.Start(ctx, id, opts)
|
address, err := manager.Start(ctx, id, opts)
|
||||||
|
Loading…
Reference in New Issue
Block a user