Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 64c03ec

Browse files
fupanlifupan
authored andcommitted
clean up the codes
Signed-off-by: fupan <fupan@fupandeMacBook-Pro.local>
1 parent cfa4183 commit 64c03ec

File tree

4 files changed

+3
-114
lines changed

4 files changed

+3
-114
lines changed

daemon/pod/container.go

Lines changed: 2 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ import (
55
"fmt"
66
"io"
77
"os"
8+
"path"
89
"path/filepath"
910
"strings"
1011
"sync"
1112
"syscall"
1213
"time"
1314

15+
"encoding/json"
1416
"github.com/docker/docker/daemon/logger"
1517
"github.com/docker/docker/daemon/logger/jsonfilelog"
1618
"github.com/docker/docker/pkg/stdcopy"
1719
"github.com/docker/docker/pkg/version"
1820
dockertypes "github.com/docker/engine-api/types"
1921
"github.com/docker/engine-api/types/container"
2022
"github.com/docker/engine-api/types/strslice"
21-
22-
"encoding/json"
2323
"github.com/hyperhq/hypercontainer-utils/hlog"
2424
"github.com/hyperhq/hyperd/errors"
2525
apitypes "github.com/hyperhq/hyperd/types"
@@ -31,7 +31,6 @@ import (
3131
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
3232
"github.com/moby/oci"
3333
"github.com/opencontainers/runtime-spec/specs-go"
34-
"path"
3534
)
3635

3736
var epocZero = time.Time{}
@@ -673,108 +672,6 @@ func (c *Container) containerConfig(cjson *dockertypes.ContainerJSON) (*vc.Conta
673672
return containerConfig, nil
674673
}
675674

676-
/*
677-
func (c *Container) describeContainer(cjson *dockertypes.ContainerJSON) (*runv.ContainerDescription, error) {
678-
679-
c.Log(TRACE, "container info config %#v, Cmd %v, Args %v", cjson.Config, cjson.Config.Cmd.Slice(), cjson.Args)
680-
681-
if c.spec.Image == "" {
682-
c.spec.Image = cjson.Config.Image
683-
}
684-
c.Log(INFO, "describe container")
685-
686-
mountId, err := GetMountIdByContainer(c.p.factory.sd.Type(), c.spec.Id)
687-
if err != nil {
688-
err = fmt.Errorf("Cannot find mountID for container %s : %s", c.spec.Id, err)
689-
c.Log(ERROR, "Cannot find mountID for container %s", err)
690-
return nil, err
691-
}
692-
c.Log(DEBUG, "mount id: %s", mountId)
693-
694-
cdesc := &runv.ContainerDescription{
695-
Id: c.spec.Id,
696-
697-
Name: cjson.Name, // will have a "/"
698-
Image: cjson.Image,
699-
700-
Labels: c.spec.Labels,
701-
Tty: c.spec.Tty,
702-
703-
RootVolume: &runv.VolumeDescription{},
704-
MountId: mountId,
705-
RootPath: "rootfs",
706-
707-
Envs: make(map[string]string),
708-
Workdir: cjson.Config.WorkingDir,
709-
Path: cjson.Path,
710-
Args: cjson.Args,
711-
Rlimits: make([]*runv.Rlimit, 0, len(c.spec.Ulimits)),
712-
713-
StopSignal: strings.ToUpper(cjson.Config.StopSignal),
714-
}
715-
716-
//make sure workdir has an initial val
717-
if cdesc.Workdir == "" {
718-
cdesc.Workdir = "/"
719-
}
720-
721-
for _, l := range c.spec.Ulimits {
722-
ltype := strings.ToLower(l.Name)
723-
cdesc.Rlimits = append(cdesc.Rlimits, &runv.Rlimit{
724-
Type: ltype,
725-
Hard: l.Hard,
726-
Soft: l.Soft,
727-
})
728-
}
729-
730-
if c.spec.StopSignal != "" {
731-
cdesc.StopSignal = c.spec.StopSignal
732-
}
733-
if strings.HasPrefix(cdesc.StopSignal, "SIG") {
734-
cdesc.StopSignal = cdesc.StopSignal[len("SIG"):]
735-
}
736-
if cdesc.StopSignal == "" {
737-
cdesc.StopSignal = "TERM"
738-
}
739-
740-
if c.spec.User != nil && c.spec.User.Name != "" {
741-
cdesc.UGI = &runv.UserGroupInfo{
742-
User: c.spec.User.Name,
743-
Group: c.spec.User.Group,
744-
AdditionalGroups: c.spec.User.AdditionalGroups,
745-
}
746-
} else if cjson.Config.User != "" {
747-
users := strings.Split(cjson.Config.User, ":")
748-
if len(users) > 2 {
749-
return nil, fmt.Errorf("container %s invalid user group config: %s", cjson.Name, cjson.Config.User)
750-
}
751-
if len(users) == 2 {
752-
cdesc.UGI = &runv.UserGroupInfo{
753-
User: users[0],
754-
Group: users[1],
755-
}
756-
} else {
757-
cdesc.UGI = &runv.UserGroupInfo{
758-
User: cjson.Config.User,
759-
}
760-
}
761-
}
762-
763-
for _, v := range cjson.Config.Env {
764-
pair := strings.SplitN(v, "=", 2)
765-
if len(pair) == 2 {
766-
cdesc.Envs[pair[0]] = pair[1]
767-
} else if len(pair) == 1 {
768-
cdesc.Envs[pair[0]] = ""
769-
}
770-
}
771-
772-
c.Log(TRACE, "Container Info is \n%#v", cdesc)
773-
774-
return cdesc, nil
775-
}
776-
*/
777-
778675
func (c *Container) parseVolumes() map[string]*runv.VolumeReference {
779676
refs := make(map[string]*runv.VolumeReference)
780677
for _, vol := range c.spec.Volumes {

daemon/pod/decommission.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
"github.com/hyperhq/hyperd/utils"
1313
vc "github.com/kata-containers/runtime/virtcontainers"
14-
// "github.com/hyperhq/runv/hypervisor"
1514
)
1615

1716
type sandboxOp func(sb *vc.Sandbox) error
@@ -178,7 +177,6 @@ func (p *XPod) KillContainer(id string, sig int64) error {
178177
c.setKill()
179178
return p.protectedSandboxOperation(
180179
func(sb *vc.Sandbox) error {
181-
// return sb.KillContainer(id, syscall.Signal(sig))
182180
return vc.KillContainer(sb.ID(), id, syscall.Signal(sig), true)
183181
},
184182
time.Second*5,
@@ -459,8 +457,6 @@ func (p *XPod) stopContainers(cList []string, graceful int) error {
459457
}
460458

461459
forceKill := graceful == 0
462-
//
463-
//
464460
go func(retch chan int32, c *Container) {
465461
ret, _ := p.sandbox.WaitProcess(c.Id(), c.Id())
466462
retch <- ret

daemon/pod/pod.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ import (
88
"time"
99

1010
"github.com/docker/docker/daemon/logger"
11-
1211
"github.com/hyperhq/hypercontainer-utils/hlog"
13-
apitypes "github.com/hyperhq/hyperd/types"
1412
"github.com/hyperhq/hyperd/utils"
15-
// "github.com/hyperhq/runv/hypervisor"
13+
apitypes "github.com/hyperhq/hyperd/types"
1614
vc "github.com/kata-containers/runtime/virtcontainers"
17-
// runvtypes "github.com/hyperhq/runv/hypervisor/types"
1815
)
1916

2017
const (

daemon/pod/portmappings.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package pod
22

33
import (
4-
// "fmt"
54
"github.com/hyperhq/hypercontainer-utils/hlog"
65
"github.com/hyperhq/hyperd/networking/portmapping"
76
apitypes "github.com/hyperhq/hyperd/types"

0 commit comments

Comments
 (0)