"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "daemon/cluster/executor/container/executor.go" between
moby-20.10.7.tar.gz and moby-20.10.8.tar.gz

About: Moby is a framework to assemble specialized container systems (formerly project name Docker; see here to clarify the relationship between the projects).

executor.go  (moby-20.10.7):executor.go  (moby-20.10.8)
skipping to change at line 18 skipping to change at line 18
"sync" "sync"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
swarmtypes "github.com/docker/docker/api/types/swarm" swarmtypes "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/daemon/cluster/controllers/plugin" "github.com/docker/docker/daemon/cluster/controllers/plugin"
"github.com/docker/docker/daemon/cluster/convert" "github.com/docker/docker/daemon/cluster/convert"
executorpkg "github.com/docker/docker/daemon/cluster/executor" executorpkg "github.com/docker/docker/daemon/cluster/executor"
clustertypes "github.com/docker/docker/daemon/cluster/provider" clustertypes "github.com/docker/docker/daemon/cluster/provider"
"github.com/docker/libnetwork"
networktypes "github.com/docker/libnetwork/types" networktypes "github.com/docker/libnetwork/types"
"github.com/docker/swarmkit/agent" "github.com/docker/swarmkit/agent"
"github.com/docker/swarmkit/agent/exec" "github.com/docker/swarmkit/agent/exec"
"github.com/docker/swarmkit/api" "github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/api/naming" "github.com/docker/swarmkit/api/naming"
"github.com/docker/swarmkit/log"
"github.com/docker/swarmkit/template" "github.com/docker/swarmkit/template"
"github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
type executor struct { type executor struct {
backend executorpkg.Backend backend executorpkg.Backend
imageBackend executorpkg.ImageBackend imageBackend executorpkg.ImageBackend
pluginBackend plugin.Backend pluginBackend plugin.Backend
volumeBackend executorpkg.VolumeBackend volumeBackend executorpkg.VolumeBackend
dependencies exec.DependencyManager dependencies exec.DependencyManager
mutex sync.Mutex // This mutex protects the following node field mutex sync.Mutex // This mutex protects the following node field
node *api.NodeDescription node *api.NodeDescription
// nodeObj holds a copy of the swarmkit Node object from the time of the
// last call to executor.Configure. This allows us to discover which
// network attachments the node previously had, which further allows us t
o
// determine which, if any, need to be removed. nodeObj is not protected
by
// a mutex, because it is only written to in the method (Configure) that
it
// is read from. If that changes, it may need to be guarded.
nodeObj *api.Node
} }
// NewExecutor returns an executor from the docker client. // NewExecutor returns an executor from the docker client.
func NewExecutor(b executorpkg.Backend, p plugin.Backend, i executorpkg.ImageBac kend, v executorpkg.VolumeBackend) exec.Executor { func NewExecutor(b executorpkg.Backend, p plugin.Backend, i executorpkg.ImageBac kend, v executorpkg.VolumeBackend) exec.Executor {
return &executor{ return &executor{
backend: b, backend: b,
pluginBackend: p, pluginBackend: p,
imageBackend: i, imageBackend: i,
volumeBackend: v, volumeBackend: v,
dependencies: agent.NewDependencyManager(), dependencies: agent.NewDependencyManager(),
skipping to change at line 160 skipping to change at line 171
continue continue
} }
if na.Network.Spec.Ingress { if na.Network.Spec.Ingress {
ingressNA = na ingressNA = na
} }
attachments[na.Network.ID] = na.Addresses[0] attachments[na.Network.ID] = na.Addresses[0]
} }
// discover which, if any, attachments have been removed.
//
// we aren't responsible directly for creating these networks. that is
// handled indirectly when a container using that network is created.
// however, when it comes time to remove the network, none of the relevan
t
// tasks may exist anymore. this means we should go ahead and try to remo
ve
// any network we know to no longer be in use.
// removeAttachments maps the network ID to a boolean. This boolean
// indicates whether the attachment in question is totally removed (true)
,
// or has just had its IP changed (false)
removeAttachments := make(map[string]bool)
// the first time we Configure, nodeObj wil be nil, because it will not b
e
// set yet. in that case, skip this check.
if e.nodeObj != nil {
for _, na := range e.nodeObj.Attachments {
// same thing as above, check sanity of the attachments s
o we don't
// get a panic.
if na == nil || na.Network == nil || len(na.Addresses) ==
0 {
logrus.WithField("NetworkAttachment", fmt.Sprintf
("%#v", na)).
Warnf("skipping nil or malformed node net
work attachment entry")
continue
}
// now, check if the attachment exists and shares the sam
e IP address.
if ip, ok := attachments[na.Network.ID]; !ok || na.Addres
ses[0] != ip {
// if the map entry exists, then the network stil
l exists, and the
// IP must be what has changed
removeAttachments[na.Network.ID] = !ok
}
}
}
if (ingressNA == nil) && (node.Attachment != nil) && (len(node.Attachment .Addresses) > 0) { if (ingressNA == nil) && (node.Attachment != nil) && (len(node.Attachment .Addresses) > 0) {
ingressNA = node.Attachment ingressNA = node.Attachment
attachments[ingressNA.Network.ID] = ingressNA.Addresses[0] attachments[ingressNA.Network.ID] = ingressNA.Addresses[0]
} }
if ingressNA == nil { if ingressNA == nil {
e.backend.ReleaseIngress() e.backend.ReleaseIngress()
return e.backend.GetAttachmentStore().ResetAttachments(attachment s) return e.backend.GetAttachmentStore().ResetAttachments(attachment s)
} }
skipping to change at line 200 skipping to change at line 245
ID: ingressNA.Network.ID, ID: ingressNA.Network.ID,
NetworkCreateRequest: types.NetworkCreateRequest{ NetworkCreateRequest: types.NetworkCreateRequest{
Name: ingressNA.Network.Spec.Annotations.Name, Name: ingressNA.Network.Spec.Annotations.Name,
NetworkCreate: options, NetworkCreate: options,
}, },
}, ingressNA.Addresses[0]) }, ingressNA.Addresses[0])
if err != nil { if err != nil {
return err return err
} }
var (
activeEndpointsError *libnetwork.ActiveEndpointsError
errNoSuchNetwork libnetwork.ErrNoSuchNetwork
)
// now, finally, remove any network LB attachments that we no longer have
.
for nw, gone := range removeAttachments {
err := e.backend.DeleteManagedNetwork(nw)
switch {
case err == nil:
continue
case errors.As(err, &activeEndpointsError):
// this is the purpose of the boolean in the map. it's li
terally
// just to log an appropriate, informative error. i'm uns
ure if
// this can ever actually occur, but we need to know if i
t does.
if gone {
log.G(ctx).Warnf("network %s should be removed, b
ut still has active attachments", nw)
} else {
log.G(ctx).Warnf(
"network %s should have its node LB IP ch
anged, but cannot be removed because of active attachments",
nw,
)
}
continue
case errors.As(err, &errNoSuchNetwork):
// NoSuchNetworkError indicates the network is already go
ne.
continue
default:
log.G(ctx).Errorf("network %s remove failed: %v", nw, err
)
}
}
// now update our copy of the node object, reset the attachment store, an
d
// return
e.nodeObj = node
return e.backend.GetAttachmentStore().ResetAttachments(attachments) return e.backend.GetAttachmentStore().ResetAttachments(attachments)
} }
// Controller returns a docker container runner. // Controller returns a docker container runner.
func (e *executor) Controller(t *api.Task) (exec.Controller, error) { func (e *executor) Controller(t *api.Task) (exec.Controller, error) {
dependencyGetter := template.NewTemplatedDependencyGetter(agent.Restrict( e.dependencies, t), t, nil) dependencyGetter := template.NewTemplatedDependencyGetter(agent.Restrict( e.dependencies, t), t, nil)
// Get the node description from the executor field // Get the node description from the executor field
e.mutex.Lock() e.mutex.Lock()
nodeDescription := e.node nodeDescription := e.node
 End of changes. 6 change blocks. 
0 lines changed or deleted 104 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)