Skip to content

Commit

Permalink
fixing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
steiler committed Jun 2, 2021
1 parent 78772e1 commit 9c5dc68
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions runtime/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func (c *ContainerdRuntime) CreateContainer(ctx context.Context, node *types.Nod
case "none":
// Done!
default:

cnic = libcni.NewCNIConfigWithCacheDir([]string{cniBin}, cniCache, nil)

cncl, err = libcni.ConfListFromFile(cniConfigFile)
Expand All @@ -152,13 +151,11 @@ func (c *ContainerdRuntime) CreateContainer(ctx context.Context, node *types.Nod
}

cnirc = &libcni.RuntimeConf{
ContainerID: node.ShortName,
IfName: "eth0",
NetNS: node.NSPath,
ContainerID: node.LongName,
IfName: "eth0",
//// NetNS must be set later, can just be determined after cotnainer start
//NetNS: node.NSPath,
CapabilityArgs: make(map[string]interface{}),
//"portMappings": []portMapping{
// {HostPort: 8080, ContainerPort: 80, Protocol: "tcp"},
//},
}

// set mac if defined in node
Expand Down Expand Up @@ -187,26 +184,26 @@ func (c *ContainerdRuntime) CreateContainer(ctx context.Context, node *types.Nod

_, err = c.client.NewContainer(
ctx,
node.ShortName,
containerd.WithNewSnapshot(node.ShortName+"-snapshot", img),
node.LongName,
containerd.WithNewSnapshot(node.LongName+"-snapshot", img),
containerd.WithNewSpec(opts...),
containerd.WithAdditionalContainerLabels(node.Labels),
)
if err != nil {
return err
}

log.Debugf("Container '%s' created", node.ShortName)
log.Debugf("Container '%s' created", node.LongName)
log.Debugf("Start container: %s", node.LongName)

err = c.StartContainer(ctx, node.ShortName)
err = c.StartContainer(ctx, node.LongName)
if err != nil {
return err
}

log.Debugf("Container started: %s", node.LongName)

node.NSPath, err = c.GetNSPath(ctx, node.ShortName)
node.NSPath, err = c.GetNSPath(ctx, node.LongName)
if err != nil {
return err
}
Expand All @@ -220,6 +217,7 @@ func (c *ContainerdRuntime) CreateContainer(ctx context.Context, node *types.Nod
// we have prepared a lot of stuff further up, which
// is now to be applied
if cnic != nil {
cnirc.NetNS = node.NSPath
res, err := cnic.AddNetworkList(ctx, cncl, cnirc)
if err != nil {
return err
Expand Down

0 comments on commit 9c5dc68

Please sign in to comment.