diff --git a/ctrd/container.go b/ctrd/container.go index bad29d987..53efb66e0 100644 --- a/ctrd/container.go +++ b/ctrd/container.go @@ -32,8 +32,7 @@ import ( ) var ( - runtimeRoot = "/run" - defaultTrylockTimeout = 5 * time.Second + runtimeRoot = "/run" ) type containerPack struct { diff --git a/ctrd/utils.go b/ctrd/utils.go index 1c14f2d75..9ba4e7d0b 100644 --- a/ctrd/utils.go +++ b/ctrd/utils.go @@ -3,14 +3,12 @@ package ctrd import ( "context" "crypto/tls" - "encoding/json" "net" "net/http" "time" "github.com/alibaba/pouch/apis/types" "github.com/alibaba/pouch/pkg/errtypes" - "github.com/alibaba/pouch/pkg/utils" "github.com/containerd/containerd/containers" "github.com/containerd/containerd/errdefs" @@ -18,9 +16,8 @@ import ( "github.com/containerd/containerd/oci" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" - "github.com/opencontainers/go-digest" "github.com/opencontainers/image-spec/specs-go/v1" - specs "github.com/opencontainers/runtime-spec/specs-go" + "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" ) @@ -80,19 +77,6 @@ func resolver(authConfig *types.AuthConfig) (remotes.Resolver, error) { return docker.NewResolver(options), nil } -// generateID generates image's ID by the SHA256 hash of its configuration JSON. -func generateID(config *types.ImageInfo) (digest.Digest, error) { - var ID digest.Digest - - b, err := json.Marshal(config) - if err != nil { - return ID, err - } - - ID = digest.FromBytes(b) - return ID, nil -} - // rootFSToAPIType transfer the rootfs from OCI format to Pouch format. func rootFSToAPIType(rootFs *v1.RootFS) types.ImageInfoRootFS { var layers []string @@ -105,39 +89,6 @@ func rootFSToAPIType(rootFs *v1.RootFS) types.ImageInfoRootFS { } } -// ociImageToPouchImage transfer the image from OCI format to Pouch format. -func ociImageToPouchImage(ociImage v1.Image) (types.ImageInfo, error) { - imageConfig := ociImage.Config - - volumes := make(map[string]interface{}) - for k, obj := range imageConfig.Volumes { - volumes[k] = obj - } - cfg := &types.ContainerConfig{ - // TODO: add more fields - User: imageConfig.User, - Env: imageConfig.Env, - Entrypoint: imageConfig.Entrypoint, - Cmd: imageConfig.Cmd, - WorkingDir: imageConfig.WorkingDir, - Labels: imageConfig.Labels, - StopSignal: imageConfig.StopSignal, - Volumes: volumes, - } - - rootFs := rootFSToAPIType(&ociImage.RootFS) - - // FIXME need to refactor it and the ociImage's list interface. - imageInfo := types.ImageInfo{ - Architecture: ociImage.Architecture, - Config: cfg, - CreatedAt: ociImage.Created.Format(utils.TimeLayout), - Os: ociImage.OS, - RootFS: &rootFs, - } - return imageInfo, nil -} - // toLinuxResources transfers Pouch Resources to LinuxResources. func toLinuxResources(resources types.Resources) (*specs.LinuxResources, error) { r := &specs.LinuxResources{} diff --git a/daemon/daemon.go b/daemon/daemon.go index 6f29704bb..5a18e8713 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -5,7 +5,6 @@ import ( "fmt" "path" "path/filepath" - "plugin" "reflect" "github.com/alibaba/pouch/apis/server" @@ -24,8 +23,6 @@ import ( systemddaemon "github.com/coreos/go-systemd/daemon" systemdutil "github.com/coreos/go-systemd/util" - "github.com/gorilla/mux" - "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -52,12 +49,6 @@ type Daemon struct { eventsService *events.Events } -// router represents the router of daemon. -type router struct { - daemon *Daemon - *mux.Router -} - // NewDaemon constructs a brand new server. func NewDaemon(cfg *config.Config) *Daemon { containerStore, err := meta.NewStore(meta.Config{ @@ -117,14 +108,6 @@ func NewDaemon(cfg *config.Config) *Daemon { } } -func loadSymbolByName(p *plugin.Plugin, name string) (plugin.Symbol, error) { - s, err := p.Lookup(name) - if err != nil { - return nil, errors.Wrapf(err, "lookup plugin with name %s error", name) - } - return s, nil -} - func (d *Daemon) loadPlugin() error { var err error diff --git a/daemon/mgr/spec_linux.go b/daemon/mgr/spec_linux.go index 5be7425b8..14806a99a 100644 --- a/daemon/mgr/spec_linux.go +++ b/daemon/mgr/spec_linux.go @@ -373,45 +373,17 @@ func setupNamespaces(ctx context.Context, c *Container, specWrapper *SpecWrapper return setupUtsNamespace(ctx, c, specWrapper) } -// isEmpty indicates whether namespace mode is empty. -func isEmpty(mode string) bool { - return mode == "" -} - -// isNone indicates whether container's namespace mode is set to "none". -func isNone(mode string) bool { - return mode == "none" -} - // isHost indicates whether the container shares the host's corresponding namespace. func isHost(mode string) bool { return mode == "host" } -// isShareable indicates whether the containers namespace can be shared with another container. -func isShareable(mode string) bool { - return mode == "shareable" -} - // isContainer indicates whether the container uses another container's corresponding namespace. func isContainer(mode string) bool { parts := strings.SplitN(mode, ":", 2) return len(parts) > 1 && parts[0] == "container" } -// isPrivate indicates whether the container uses its own namespace. -func isPrivate(ns specs.LinuxNamespaceType, mode string) bool { - switch ns { - case specs.IPCNamespace: - return mode == "private" - case specs.NetworkNamespace, specs.PIDNamespace: - return !(isHost(mode) || isContainer(mode)) - case specs.UserNamespace, specs.UTSNamespace: - return !(isHost(mode)) - } - return false -} - // connectedContainer is the id or name of the container whose namespace this container share with. func connectedContainer(mode string) string { parts := strings.SplitN(mode, ":", 2) diff --git a/main.go b/main.go index f04f1ef6f..cb7b4b234 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,6 @@ import ( "github.com/alibaba/pouch/daemon/config" "github.com/alibaba/pouch/lxcfs" "github.com/alibaba/pouch/pkg/debug" - "github.com/alibaba/pouch/pkg/exec" "github.com/alibaba/pouch/pkg/utils" "github.com/alibaba/pouch/storage/quota" "github.com/alibaba/pouch/version" @@ -258,23 +257,6 @@ func initLog() { logrus.SetFormatter(formatter) } -// define lxcfs processe. -func setLxcfsProcess(processes exec.Processes) exec.Processes { - if !cfg.IsLxcfsEnabled { - return processes - } - - p := &exec.Process{ - Path: cfg.LxcfsBinPath, - Args: []string{ - cfg.LxcfsHome, - }, - } - processes = append(processes, p) - - return processes -} - // check lxcfs config func checkLxcfsCfg() error { if !cfg.IsLxcfsEnabled { diff --git a/pkg/utils/metrics/unit.go b/pkg/utils/metrics/unit.go index 97d407f61..5ad3aa9bc 100644 --- a/pkg/utils/metrics/unit.go +++ b/pkg/utils/metrics/unit.go @@ -5,8 +5,6 @@ package metrics type Unit string const ( - nanoseconds Unit = "nanoseconds" - seconds Unit = "seconds" - bytes Unit = "bytes" - total Unit = "total" + seconds Unit = "seconds" + total Unit = "total" ) diff --git a/registry/auth.go b/registry/auth.go index 6a1396c3f..26bd9b95c 100644 --- a/registry/auth.go +++ b/registry/auth.go @@ -70,11 +70,6 @@ func genRegistryEndpoints(addr string) (endpoints []registryEndpoint) { return endpoints } -// TODO: generate v2 registry endpoint for login -func genV1Endpoints(addr string) registryEndpoint { - return registryEndpoint{} -} - func genV2Endpoints(addr string) registryEndpoint { if addr == "" { addr = defaultV2Registry diff --git a/storage/quota/grpquota.go b/storage/quota/grpquota.go index 7cb8f6a16..e3af71506 100644 --- a/storage/quota/grpquota.go +++ b/storage/quota/grpquota.go @@ -18,10 +18,6 @@ import ( "github.com/sirupsen/logrus" ) -var ( - grpQuotaType = "grpquota" -) - // GrpQuotaDriver represents group quota driver. type GrpQuotaDriver struct { lock sync.Mutex diff --git a/storage/quota/prjquota.go b/storage/quota/prjquota.go index c69be0fc9..13dbb5095 100644 --- a/storage/quota/prjquota.go +++ b/storage/quota/prjquota.go @@ -18,10 +18,6 @@ import ( "github.com/sirupsen/logrus" ) -var ( - prjQuotaType = "prjquota" -) - // PrjQuotaDriver represents project quota driver. type PrjQuotaDriver struct { lock sync.Mutex diff --git a/test/util_api.go b/test/util_api.go index 54788d9d4..05ffdd744 100644 --- a/test/util_api.go +++ b/test/util_api.go @@ -124,15 +124,6 @@ func CheckContainerRunning(c *check.C, cname string, isRunning bool) { c.Assert(gotRunning, check.Equals, isRunning) } -// DelContainerForceOk forcely deletes the container and asserts success. -func DelContainerForceOk(c *check.C, cname string) { - resp, err := delContainerForce(cname) - c.Assert(err, check.IsNil) - - defer resp.Body.Close() - CheckRespStatus(c, resp, 204) -} - func delContainerForce(cname string) (*http.Response, error) { q := url.Values{} q.Add("force", "true") @@ -154,7 +145,6 @@ func PauseContainerOk(c *check.C, cname string) { func UnpauseContainerOk(c *check.C, cname string) { resp, err := request.Post("/containers/" + cname + "/unpause") c.Assert(err, check.IsNil) - defer resp.Body.Close() CheckRespStatus(c, resp, 204) } diff --git a/test/util_daemon.go b/test/util_daemon.go index 2ecdae7bb..f64aa4740 100644 --- a/test/util_daemon.go +++ b/test/util_daemon.go @@ -64,13 +64,6 @@ func StartDefaultDaemon(args ...string) (*daemon.Config, error) { return &cfg, cfg.StartDaemon() } -// StartDaemonBareWithArgs starts a deamon with all user specified parameter. -func StartDaemonBareWithArgs(cfg *daemon.Config, args ...string) error { - cfg.NewArgs(args...) - - return cfg.StartDaemon() -} - // RestartDaemon restart daemon func RestartDaemon(cfg *daemon.Config) error { cfg.KillDaemon()