mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #30332 from anusha-ragunathan/1.13.x
Cherry pick docker #30145 and vendor corresponding swarmkit #1883
This commit is contained in:
commit
0b27583f82
13 changed files with 66 additions and 23 deletions
|
@ -332,6 +332,7 @@ func (c *Cluster) startNewNode(conf nodeStartConfig) (*node, error) {
|
|||
ElectionTick: 3,
|
||||
UnlockKey: conf.lockKey,
|
||||
AutoLockManagers: conf.autolock,
|
||||
PluginGetter: c.config.Backend.PluginGetter(),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -56,4 +56,5 @@ type Backend interface {
|
|||
GetRepository(context.Context, reference.NamedTagged, *types.AuthConfig) (distribution.Repository, bool, error)
|
||||
LookupImage(name string) (*types.ImageInspect, error)
|
||||
PluginManager() *plugin.Manager
|
||||
PluginGetter() *plugin.Store
|
||||
}
|
||||
|
|
|
@ -1272,6 +1272,11 @@ func (daemon *Daemon) PluginManager() *plugin.Manager { // set up before daemon
|
|||
return daemon.pluginManager
|
||||
}
|
||||
|
||||
// PluginGetter returns current pluginStore associated with the daemon
|
||||
func (daemon *Daemon) PluginGetter() *plugin.Store {
|
||||
return daemon.PluginStore
|
||||
}
|
||||
|
||||
// CreateDaemonRoot creates the root for the daemon
|
||||
func CreateDaemonRoot(config *Config) error {
|
||||
// get the canonical path to the Docker root directory
|
||||
|
|
|
@ -677,8 +677,9 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *check.C) {
|
|||
|
||||
d := s.AddDaemon(c, true, true)
|
||||
|
||||
_, err := d.Cmd("network", "create", "-d", globalNetworkPlugin, "foo")
|
||||
out, err := d.Cmd("network", "create", "-d", globalNetworkPlugin, "foo")
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(out, checker.Contains, "not supported in swarm mode")
|
||||
}
|
||||
|
||||
// Test case for #24712
|
||||
|
|
|
@ -100,7 +100,7 @@ github.com/docker/containerd 03e5862ec0d8d3b3f750e19fca3ee367e13c090e
|
|||
github.com/tonistiigi/fifo 1405643975692217d6720f8b54aeee1bf2cd5cf4
|
||||
|
||||
# cluster
|
||||
github.com/docker/swarmkit 296fcfcf1e86a26a3f52aa84d638fbf80f9a8443
|
||||
github.com/docker/swarmkit 335561b66a44bf214224afe879e4368204e7fa45
|
||||
github.com/golang/mock bd3c8e81be01eef76d4b503f5e687d2d1354d2d9
|
||||
github.com/gogo/protobuf v0.3
|
||||
github.com/cloudflare/cfssl 7fb22c8cba7ecaf98e4082d22d65800cf45e042a
|
||||
|
|
7
vendor/github.com/docker/swarmkit/manager/allocator/allocator.go
generated
vendored
7
vendor/github.com/docker/swarmkit/manager/allocator/allocator.go
generated
vendored
|
@ -3,6 +3,7 @@ package allocator
|
|||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/go-events"
|
||||
"github.com/docker/swarmkit/manager/state"
|
||||
"github.com/docker/swarmkit/manager/state/store"
|
||||
|
@ -27,6 +28,9 @@ type Allocator struct {
|
|||
stopChan chan struct{}
|
||||
// doneChan is closed when the allocator is finished running.
|
||||
doneChan chan struct{}
|
||||
|
||||
// pluginGetter provides access to docker's plugin inventory.
|
||||
pluginGetter plugingetter.PluginGetter
|
||||
}
|
||||
|
||||
// taskBallot controls how the voting for task allocation is
|
||||
|
@ -67,7 +71,7 @@ type allocActor struct {
|
|||
|
||||
// New returns a new instance of Allocator for use during allocation
|
||||
// stage of the manager.
|
||||
func New(store *store.MemoryStore) (*Allocator, error) {
|
||||
func New(store *store.MemoryStore, pg plugingetter.PluginGetter) (*Allocator, error) {
|
||||
a := &Allocator{
|
||||
store: store,
|
||||
taskBallot: &taskBallot{
|
||||
|
@ -75,6 +79,7 @@ func New(store *store.MemoryStore) (*Allocator, error) {
|
|||
},
|
||||
stopChan: make(chan struct{}),
|
||||
doneChan: make(chan struct{}),
|
||||
pluginGetter: pg,
|
||||
}
|
||||
|
||||
return a, nil
|
||||
|
|
2
vendor/github.com/docker/swarmkit/manager/allocator/network.go
generated
vendored
2
vendor/github.com/docker/swarmkit/manager/allocator/network.go
generated
vendored
|
@ -73,7 +73,7 @@ type networkContext struct {
|
|||
}
|
||||
|
||||
func (a *Allocator) doNetworkInit(ctx context.Context) (err error) {
|
||||
na, err := networkallocator.New()
|
||||
na, err := networkallocator.New(a.pluginGetter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
12
vendor/github.com/docker/swarmkit/manager/allocator/networkallocator/networkallocator.go
generated
vendored
12
vendor/github.com/docker/swarmkit/manager/allocator/networkallocator/networkallocator.go
generated
vendored
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/docker/docker/pkg/plugins"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/libnetwork/datastore"
|
||||
"github.com/docker/libnetwork/driverapi"
|
||||
"github.com/docker/libnetwork/drvregistry"
|
||||
|
@ -69,7 +69,7 @@ type initializer struct {
|
|||
}
|
||||
|
||||
// New returns a new NetworkAllocator handle
|
||||
func New() (*NetworkAllocator, error) {
|
||||
func New(pg plugingetter.PluginGetter) (*NetworkAllocator, error) {
|
||||
na := &NetworkAllocator{
|
||||
networks: make(map[string]*network),
|
||||
services: make(map[string]struct{}),
|
||||
|
@ -79,7 +79,7 @@ func New() (*NetworkAllocator, error) {
|
|||
|
||||
// There are no driver configurations and notification
|
||||
// functions as of now.
|
||||
reg, err := drvregistry.New(nil, nil, nil, nil, nil)
|
||||
reg, err := drvregistry.New(nil, nil, nil, nil, pg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -657,7 +657,11 @@ func (na *NetworkAllocator) resolveDriver(n *api.Network) (driverapi.Driver, str
|
|||
}
|
||||
|
||||
func (na *NetworkAllocator) loadDriver(name string) error {
|
||||
_, err := plugins.Get(name, driverapi.NetworkPluginEndpointType)
|
||||
pg := na.drvRegistry.GetPluginGetter()
|
||||
if pg == nil {
|
||||
return fmt.Errorf("plugin store is unintialized")
|
||||
}
|
||||
_, err := pg.Get(name, driverapi.NetworkPluginEndpointType, plugingetter.LOOKUP)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
19
vendor/github.com/docker/swarmkit/manager/controlapi/common.go
generated
vendored
19
vendor/github.com/docker/swarmkit/manager/controlapi/common.go
generated
vendored
|
@ -4,7 +4,10 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/libnetwork/ipamapi"
|
||||
"github.com/docker/swarmkit/api"
|
||||
"github.com/docker/swarmkit/manager/allocator/networkallocator"
|
||||
"github.com/docker/swarmkit/manager/state/store"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
@ -76,7 +79,7 @@ func validateAnnotations(m api.Annotations) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func validateDriver(driver *api.Driver, defName string) error {
|
||||
func validateDriver(driver *api.Driver, pg plugingetter.PluginGetter, pluginType string) error {
|
||||
if driver == nil {
|
||||
// It is ok to not specify the driver. We will choose
|
||||
// a default driver.
|
||||
|
@ -87,8 +90,18 @@ func validateDriver(driver *api.Driver, defName string) error {
|
|||
return grpc.Errorf(codes.InvalidArgument, "driver name: if driver is specified name is required")
|
||||
}
|
||||
|
||||
if driver.Name != defName {
|
||||
return grpc.Errorf(codes.InvalidArgument, "invalid driver (%s) specified", driver.Name)
|
||||
if strings.ToLower(driver.Name) == networkallocator.DefaultDriver || strings.ToLower(driver.Name) == ipamapi.DefaultIPAM {
|
||||
return nil
|
||||
}
|
||||
|
||||
p, err := pg.Get(driver.Name, pluginType, plugingetter.LOOKUP)
|
||||
if err != nil {
|
||||
return grpc.Errorf(codes.InvalidArgument, "error during lookup of plugin %s", driver.Name)
|
||||
}
|
||||
|
||||
if p.IsV1() {
|
||||
return grpc.Errorf(codes.InvalidArgument, "legacy plugin %s of type %s is not supported in swarm mode", driver.Name, pluginType)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
15
vendor/github.com/docker/swarmkit/manager/controlapi/network.go
generated
vendored
15
vendor/github.com/docker/swarmkit/manager/controlapi/network.go
generated
vendored
|
@ -4,10 +4,11 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/libnetwork/driverapi"
|
||||
"github.com/docker/libnetwork/ipamapi"
|
||||
"github.com/docker/swarmkit/api"
|
||||
"github.com/docker/swarmkit/identity"
|
||||
"github.com/docker/swarmkit/manager/allocator/networkallocator"
|
||||
"github.com/docker/swarmkit/manager/state/store"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
@ -49,14 +50,14 @@ func validateIPAMConfiguration(ipamConf *api.IPAMConfig) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func validateIPAM(ipam *api.IPAMOptions) error {
|
||||
func validateIPAM(ipam *api.IPAMOptions, pg plugingetter.PluginGetter) error {
|
||||
if ipam == nil {
|
||||
// It is ok to not specify any IPAM configurations. We
|
||||
// will choose good defaults.
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validateDriver(ipam.Driver, ipamapi.DefaultIPAM); err != nil {
|
||||
if err := validateDriver(ipam.Driver, pg, ipamapi.PluginEndpointType); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -69,7 +70,7 @@ func validateIPAM(ipam *api.IPAMOptions) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func validateNetworkSpec(spec *api.NetworkSpec) error {
|
||||
func validateNetworkSpec(spec *api.NetworkSpec, pg plugingetter.PluginGetter) error {
|
||||
if spec == nil {
|
||||
return grpc.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
|
||||
}
|
||||
|
@ -78,11 +79,11 @@ func validateNetworkSpec(spec *api.NetworkSpec) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := validateDriver(spec.DriverConfig, networkallocator.DefaultDriver); err != nil {
|
||||
if err := validateDriver(spec.DriverConfig, pg, driverapi.NetworkPluginEndpointType); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateIPAM(spec.IPAM); err != nil {
|
||||
if err := validateIPAM(spec.IPAM, pg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -95,7 +96,7 @@ func validateNetworkSpec(spec *api.NetworkSpec) error {
|
|||
func (s *Server) CreateNetwork(ctx context.Context, request *api.CreateNetworkRequest) (*api.CreateNetworkResponse, error) {
|
||||
// if you change this function, you have to change createInternalNetwork in
|
||||
// the tests to match it (except the part where we check the label).
|
||||
if err := validateNetworkSpec(request.Spec); err != nil {
|
||||
if err := validateNetworkSpec(request.Spec, s.pg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
5
vendor/github.com/docker/swarmkit/manager/controlapi/server.go
generated
vendored
5
vendor/github.com/docker/swarmkit/manager/controlapi/server.go
generated
vendored
|
@ -3,6 +3,7 @@ package controlapi
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/swarmkit/ca"
|
||||
"github.com/docker/swarmkit/manager/state/raft"
|
||||
"github.com/docker/swarmkit/manager/state/store"
|
||||
|
@ -18,13 +19,15 @@ type Server struct {
|
|||
store *store.MemoryStore
|
||||
raft *raft.Node
|
||||
rootCA *ca.RootCA
|
||||
pg plugingetter.PluginGetter
|
||||
}
|
||||
|
||||
// NewServer creates a Cluster API server.
|
||||
func NewServer(store *store.MemoryStore, raft *raft.Node, rootCA *ca.RootCA) *Server {
|
||||
func NewServer(store *store.MemoryStore, raft *raft.Node, rootCA *ca.RootCA, pg plugingetter.PluginGetter) *Server {
|
||||
return &Server{
|
||||
store: store,
|
||||
raft: raft,
|
||||
rootCA: rootCA,
|
||||
pg: pg,
|
||||
}
|
||||
}
|
||||
|
|
8
vendor/github.com/docker/swarmkit/manager/manager.go
generated
vendored
8
vendor/github.com/docker/swarmkit/manager/manager.go
generated
vendored
|
@ -13,6 +13,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/go-events"
|
||||
"github.com/docker/swarmkit/api"
|
||||
"github.com/docker/swarmkit/ca"
|
||||
|
@ -99,6 +100,9 @@ type Config struct {
|
|||
// bootstrapping a cluster for the first time (it's a cluster-wide setting),
|
||||
// and also when loading up any raft data on disk (as a KEK for the raft DEK).
|
||||
UnlockKey []byte
|
||||
|
||||
// PluginGetter provides access to docker's plugin inventory.
|
||||
PluginGetter plugingetter.PluginGetter
|
||||
}
|
||||
|
||||
// Manager is the cluster manager for Swarm.
|
||||
|
@ -309,7 +313,7 @@ func (m *Manager) Run(parent context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
baseControlAPI := controlapi.NewServer(m.raftNode.MemoryStore(), m.raftNode, m.config.SecurityConfig.RootCA())
|
||||
baseControlAPI := controlapi.NewServer(m.raftNode.MemoryStore(), m.raftNode, m.config.SecurityConfig.RootCA(), m.config.PluginGetter)
|
||||
baseResourceAPI := resourceapi.New(m.raftNode.MemoryStore())
|
||||
healthServer := health.NewHealthServer()
|
||||
localHealthServer := health.NewHealthServer()
|
||||
|
@ -780,7 +784,7 @@ func (m *Manager) becomeLeader(ctx context.Context) {
|
|||
// shutdown underlying manager processes when leadership is
|
||||
// lost.
|
||||
|
||||
m.allocator, err = allocator.New(s)
|
||||
m.allocator, err = allocator.New(s, m.config.PluginGetter)
|
||||
if err != nil {
|
||||
log.G(ctx).WithError(err).Error("failed to create allocator")
|
||||
// TODO(stevvooe): It doesn't seem correct here to fail
|
||||
|
|
5
vendor/github.com/docker/swarmkit/node/node.go
generated
vendored
5
vendor/github.com/docker/swarmkit/node/node.go
generated
vendored
|
@ -14,6 +14,7 @@ import (
|
|||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/swarmkit/agent"
|
||||
"github.com/docker/swarmkit/agent/exec"
|
||||
"github.com/docker/swarmkit/api"
|
||||
|
@ -95,6 +96,9 @@ type Config struct {
|
|||
// UnlockKey is the key to unlock a node - used for decrypting at rest. This
|
||||
// only applies to nodes that have already joined a cluster.
|
||||
UnlockKey []byte
|
||||
|
||||
// PluginGetter provides access to docker's plugin inventory.
|
||||
PluginGetter plugingetter.PluginGetter
|
||||
}
|
||||
|
||||
// Node implements the primary node functionality for a member of a swarm
|
||||
|
@ -681,6 +685,7 @@ func (n *Node) runManager(ctx context.Context, securityConfig *ca.SecurityConfig
|
|||
ElectionTick: n.config.ElectionTick,
|
||||
AutoLockManagers: n.config.AutoLockManagers,
|
||||
UnlockKey: n.unlockKey,
|
||||
PluginGetter: n.config.PluginGetter,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue