Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove swarm and plugin support #14

Merged
merged 9 commits into from
Aug 19, 2017
5 changes: 1 addition & 4 deletions api/server/router/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ package network

import (
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/daemon/cluster"
)

// networkRouter is a router to talk with the network controller
type networkRouter struct {
backend Backend
cluster *cluster.Cluster
routes []router.Route
}

// NewRouter initializes a new network router
func NewRouter(b Backend, c *cluster.Cluster) router.Router {
func NewRouter(b Backend) router.Router {
r := &networkRouter{
backend: b,
cluster: c,
}
r.initRoutes()
return r
Expand Down
69 changes: 1 addition & 68 deletions api/server/router/network/network_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,7 @@ func (n *networkRouter) getNetworksList(ctx context.Context, w http.ResponseWrit

list := []types.NetworkResource{}

if nr, err := n.cluster.GetNetworks(); err == nil {
list = append(list, nr...)
}

// Combine the network list returned by Docker daemon if it is not already
// returned by the cluster manager
SKIP:
for _, nw := range n.backend.GetNetworks() {
for _, nl := range list {
if nl.ID == nw.ID() {
continue SKIP
}
}

var nr *types.NetworkResource
// Versions < 1.28 fetches all the containers attached to a network
// in a network list api call. It is a heavy weight operation when
Expand Down Expand Up @@ -135,29 +122,6 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r
}
}

nr, _ := n.cluster.GetNetworks()
for _, network := range nr {
if network.ID == term && isMatchingScope(network.Scope, scope) {
return httputils.WriteJSON(w, http.StatusOK, network)
}
if network.Name == term && isMatchingScope(network.Scope, scope) {
// Check the ID collision as we are in swarm scope here, and
// the map (of the listByFullName) may have already had a
// network with the same ID (from local scope previously)
if _, ok := listByFullName[network.ID]; !ok {
listByFullName[network.ID] = network
}
}
if strings.HasPrefix(network.ID, term) && isMatchingScope(network.Scope, scope) {
// Check the ID collision as we are in swarm scope here, and
// the map (of the listByPartialID) may have already had a
// network with the same ID (from local scope previously)
if _, ok := listByPartialID[network.ID]; !ok {
listByPartialID[network.ID] = network
}
}
}

// Find based on full name, returns true only if no duplicates
if len(listByFullName) == 1 {
for _, v := range listByFullName {
Expand Down Expand Up @@ -196,33 +160,9 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
return err
}

if nws, err := n.cluster.GetNetworksByName(create.Name); err == nil && len(nws) > 0 {
return libnetwork.NetworkNameError(create.Name)
}

nw, err := n.backend.CreateNetwork(create)
if err != nil {
var warning string
if _, ok := err.(libnetwork.NetworkNameError); ok {
// check if user defined CheckDuplicate, if set true, return err
// otherwise prepare a warning message
if create.CheckDuplicate {
return libnetwork.NetworkNameError(create.Name)
}
warning = libnetwork.NetworkNameError(create.Name).Error()
}

if _, ok := err.(libnetwork.ManagerRedirectError); !ok {
return err
}
id, err := n.cluster.CreateNetwork(create)
if err != nil {
return err
}
nw = &types.NetworkCreateResponse{
ID: id,
Warning: warning,
}
return err
}

return httputils.WriteJSON(w, http.StatusCreated, nw)
Expand Down Expand Up @@ -266,13 +206,6 @@ func (n *networkRouter) deleteNetwork(ctx context.Context, w http.ResponseWriter
if err := httputils.ParseForm(r); err != nil {
return err
}
if _, err := n.cluster.GetNetwork(vars["id"]); err == nil {
if err = n.cluster.RemoveNetwork(vars["id"]); err != nil {
return err
}
w.WriteHeader(http.StatusNoContent)
return nil
}
if err := n.backend.DeleteNetwork(vars["id"]); err != nil {
return err
}
Expand Down
5 changes: 1 addition & 4 deletions api/server/router/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ package system
import (
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/builder/fscache"
"github.com/docker/docker/daemon/cluster"
)

// systemRouter provides information about the Docker system overall.
// It gathers information about host, daemon and container events.
type systemRouter struct {
backend Backend
cluster *cluster.Cluster
routes []router.Route
builder *fscache.FSCache
}

// NewRouter initializes a new system router
func NewRouter(b Backend, c *cluster.Cluster, fscache *fscache.FSCache) router.Router {
func NewRouter(b Backend, fscache *fscache.FSCache) router.Router {
r := &systemRouter{
backend: b,
cluster: c,
builder: fscache,
}

Expand Down
3 changes: 0 additions & 3 deletions api/server/router/system/system_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
if err != nil {
return err
}
if s.cluster != nil {
info.Swarm = s.cluster.Info()
}

if versions.LessThan(httputils.VersionFromContext(ctx), "1.25") {
// TODO: handle this conversion in engine-api
Expand Down
51 changes: 2 additions & 49 deletions cmd/dockerd/daemon.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dockerd

import (
"context"
"crypto/tls"
"fmt"
"os"
Expand All @@ -17,22 +16,18 @@ import (
"github.com/docker/docker/api/server/middleware"
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/api/server/router/build"
checkpointrouter "github.com/docker/docker/api/server/router/checkpoint"
"github.com/docker/docker/api/server/router/container"
distributionrouter "github.com/docker/docker/api/server/router/distribution"
"github.com/docker/docker/api/server/router/image"
"github.com/docker/docker/api/server/router/network"
pluginrouter "github.com/docker/docker/api/server/router/plugin"
sessionrouter "github.com/docker/docker/api/server/router/session"
swarmrouter "github.com/docker/docker/api/server/router/swarm"
systemrouter "github.com/docker/docker/api/server/router/system"
"github.com/docker/docker/api/server/router/volume"
"github.com/docker/docker/builder/dockerfile"
"github.com/docker/docker/builder/fscache"
"github.com/docker/docker/cli/debug"
"github.com/docker/docker/client/session"
"github.com/docker/docker/daemon"
"github.com/docker/docker/daemon/cluster"
"github.com/docker/docker/daemon/config"
"github.com/docker/docker/daemon/logger"
"github.com/docker/docker/dockerversion"
Expand All @@ -49,7 +44,6 @@ import (
"github.com/docker/docker/registry"
"github.com/docker/docker/runconfig"
"github.com/docker/go-connections/tlsconfig"
swarmapi "github.com/docker/swarmkit/api"
"github.com/pkg/errors"
"github.com/spf13/pflag"
)
Expand Down Expand Up @@ -242,36 +236,6 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
}
}

// TODO: createAndStartCluster()
name, _ := os.Hostname()

// Use a buffered channel to pass changes from store watch API to daemon
// A buffer allows store watch API and daemon processing to not wait for each other
watchStream := make(chan *swarmapi.WatchMessage, 32)

c, err := cluster.New(cluster.Config{
Root: cli.Config.Root,
Name: name,
Backend: d,
NetworkSubnetsProvider: d,
DefaultAdvertiseAddr: cli.Config.SwarmDefaultAdvertiseAddr,
RuntimeRoot: cli.getSwarmRunRoot(),
WatchStream: watchStream,
})
if err != nil {
logrus.Fatalf("Error creating cluster component: %v", err)
}
d.SetCluster(c)
err = c.Start()
if err != nil {
logrus.Fatalf("Error starting cluster component: %v", err)
}

// Restart all autostart containers which has a swarm endpoint
// and is not yet running now that we have successfully
// initialized the cluster.
d.RestartSwarmContainers()

logrus.Info("Daemon has completed initialization")

cli.d = d
Expand All @@ -281,15 +245,9 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
return err
}
routerOptions.api = cli.api
routerOptions.cluster = c

initRouter(routerOptions)

// process cluster change notifications
watchCtx, cancel := context.WithCancel(context.Background())
defer cancel()
go d.ProcessClusterNotifications(watchCtx, watchStream)

cli.setupConfigReloadTrap()

// The serve API routine never exits unless an error occurs
Expand All @@ -304,7 +262,6 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
// Daemon is fully initialized and handling API traffic
// Wait for serve API to complete
errAPI := <-serveAPIWait
c.Cleanup()
shutdownDaemon(d)
containerdRemote.Cleanup()
if errAPI != nil {
Expand All @@ -320,7 +277,6 @@ type routerOptions struct {
buildCache *fscache.FSCache
daemon *daemon.Daemon
api *apiserver.Server
cluster *cluster.Cluster
}

func newRouterOptions(config *config.Config, daemon *daemon.Daemon) (routerOptions, error) {
Expand Down Expand Up @@ -509,20 +465,17 @@ func initRouter(opts routerOptions) {

routers := []router.Router{
// we need to add the checkpoint router before the container router or the DELETE gets masked
checkpointrouter.NewRouter(opts.daemon, decoder),
container.NewRouter(opts.daemon, decoder),
image.NewRouter(opts.daemon, decoder),
systemrouter.NewRouter(opts.daemon, opts.cluster, opts.buildCache),
systemrouter.NewRouter(opts.daemon, opts.buildCache),
volume.NewRouter(opts.daemon),
build.NewRouter(opts.buildBackend, opts.daemon),
sessionrouter.NewRouter(opts.sessionManager),
swarmrouter.NewRouter(opts.cluster),
pluginrouter.NewRouter(opts.daemon.PluginManager()),
distributionrouter.NewRouter(opts.daemon),
}

if opts.daemon.NetworkControllerEnabled() {
routers = append(routers, network.NewRouter(opts.daemon, opts.cluster))
routers = append(routers, network.NewRouter(opts.daemon))
}

if opts.daemon.HasExperimental() {
Expand Down
3 changes: 1 addition & 2 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"github.com/docker/libnetwork/netlabel"
"github.com/docker/libnetwork/options"
"github.com/docker/libnetwork/types"
agentexec "github.com/docker/swarmkit/agent/exec"
"golang.org/x/net/context"
)

Expand Down Expand Up @@ -88,7 +87,7 @@ type Container struct {
MountPoints map[string]*volume.MountPoint
HostConfig *containertypes.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable
ExecCommands *exec.Store `json:"-"`
DependencyStore agentexec.DependencyGetter `json:"-"`
DependencyStore interface{} `json:"-"`
Copy link
Contributor

@zozo123 zozo123 Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it still allocates? I think these stuff are also defined in the protobuff. at containerd/containerd/api/grpc/types/api.pb.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will allocate a pointer, which is always nil. I don't see it defined anywhere else

SecretReferences []*swarmtypes.SecretReference
ConfigReferences []*swarmtypes.ConfigReference
// logDriver for closing
Expand Down
Loading