Fixup libnetwork lint errors
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
b53b85ca40
commit
4b981436fe
|
@ -17,10 +17,10 @@ import (
|
||||||
"github.com/docker/docker/builder"
|
"github.com/docker/docker/builder"
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
"github.com/docker/docker/daemon/images"
|
"github.com/docker/docker/daemon/images"
|
||||||
|
"github.com/docker/docker/libnetwork"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
"github.com/docker/docker/pkg/streamformatter"
|
"github.com/docker/docker/pkg/streamformatter"
|
||||||
"github.com/docker/docker/pkg/system"
|
"github.com/docker/docker/pkg/system"
|
||||||
"github.com/docker/docker/libnetwork"
|
|
||||||
controlapi "github.com/moby/buildkit/api/services/control"
|
controlapi "github.com/moby/buildkit/api/services/control"
|
||||||
"github.com/moby/buildkit/client"
|
"github.com/moby/buildkit/client"
|
||||||
"github.com/moby/buildkit/control"
|
"github.com/moby/buildkit/control"
|
||||||
|
|
|
@ -10,9 +10,9 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
|
"github.com/docker/docker/libnetwork"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/docker/docker/libnetwork"
|
|
||||||
"github.com/moby/buildkit/executor"
|
"github.com/moby/buildkit/executor"
|
||||||
"github.com/moby/buildkit/executor/oci"
|
"github.com/moby/buildkit/executor/oci"
|
||||||
"github.com/moby/buildkit/executor/runcexecutor"
|
"github.com/moby/buildkit/executor/runcexecutor"
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
|
"github.com/docker/docker/pkg/idtools"
|
||||||
"github.com/moby/buildkit/executor"
|
"github.com/moby/buildkit/executor"
|
||||||
"github.com/moby/buildkit/executor/oci"
|
"github.com/moby/buildkit/executor/oci"
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,8 +16,8 @@ import (
|
||||||
"github.com/docker/docker/daemon"
|
"github.com/docker/docker/daemon"
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
"github.com/docker/docker/libcontainerd/supervisor"
|
"github.com/docker/docker/libcontainerd/supervisor"
|
||||||
"github.com/docker/docker/pkg/homedir"
|
|
||||||
"github.com/docker/docker/libnetwork/portallocator"
|
"github.com/docker/docker/libnetwork/portallocator"
|
||||||
|
"github.com/docker/docker/pkg/homedir"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
|
@ -53,8 +53,8 @@ import (
|
||||||
types "github.com/docker/docker/api/types/swarm"
|
types "github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/daemon/cluster/controllers/plugin"
|
"github.com/docker/docker/daemon/cluster/controllers/plugin"
|
||||||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||||
"github.com/docker/docker/pkg/signal"
|
|
||||||
lncluster "github.com/docker/docker/libnetwork/cluster"
|
lncluster "github.com/docker/docker/libnetwork/cluster"
|
||||||
|
"github.com/docker/docker/pkg/signal"
|
||||||
swarmapi "github.com/docker/swarmkit/api"
|
swarmapi "github.com/docker/swarmkit/api"
|
||||||
swarmnode "github.com/docker/swarmkit/node"
|
swarmnode "github.com/docker/swarmkit/node"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
|
@ -17,11 +17,11 @@ import (
|
||||||
containerpkg "github.com/docker/docker/container"
|
containerpkg "github.com/docker/docker/container"
|
||||||
clustertypes "github.com/docker/docker/daemon/cluster/provider"
|
clustertypes "github.com/docker/docker/daemon/cluster/provider"
|
||||||
networkSettings "github.com/docker/docker/daemon/network"
|
networkSettings "github.com/docker/docker/daemon/network"
|
||||||
"github.com/docker/docker/plugin"
|
|
||||||
volumeopts "github.com/docker/docker/volume/service/opts"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
"github.com/docker/docker/libnetwork/cluster"
|
"github.com/docker/docker/libnetwork/cluster"
|
||||||
networktypes "github.com/docker/docker/libnetwork/types"
|
networktypes "github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/plugin"
|
||||||
|
volumeopts "github.com/docker/docker/volume/service/opts"
|
||||||
"github.com/docker/swarmkit/agent/exec"
|
"github.com/docker/swarmkit/agent/exec"
|
||||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,8 +20,8 @@ import (
|
||||||
"github.com/docker/docker/daemon"
|
"github.com/docker/docker/daemon"
|
||||||
"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"
|
||||||
volumeopts "github.com/docker/docker/volume/service/opts"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
|
volumeopts "github.com/docker/docker/volume/service/opts"
|
||||||
"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/log"
|
"github.com/docker/swarmkit/log"
|
||||||
|
|
|
@ -20,9 +20,9 @@ import (
|
||||||
"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"
|
||||||
|
netconst "github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
netconst "github.com/docker/docker/libnetwork/datastore"
|
|
||||||
"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/genericresource"
|
"github.com/docker/swarmkit/api/genericresource"
|
||||||
|
|
|
@ -11,8 +11,8 @@ import (
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/events"
|
"github.com/docker/docker/api/types/events"
|
||||||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||||
"github.com/docker/go-connections/nat"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
|
"github.com/docker/go-connections/nat"
|
||||||
"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/log"
|
"github.com/docker/swarmkit/log"
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/daemon/discovery"
|
"github.com/docker/docker/daemon/discovery"
|
||||||
"github.com/docker/docker/opts"
|
|
||||||
"github.com/docker/docker/libnetwork/ipamutils"
|
"github.com/docker/docker/libnetwork/ipamutils"
|
||||||
|
"github.com/docker/docker/opts"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
|
|
|
@ -14,15 +14,15 @@ import (
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/daemon/network"
|
"github.com/docker/docker/daemon/network"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/docker/opts"
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
|
||||||
"github.com/docker/docker/runconfig"
|
|
||||||
"github.com/docker/go-connections/nat"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
netconst "github.com/docker/docker/libnetwork/datastore"
|
netconst "github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/docker/libnetwork/options"
|
"github.com/docker/docker/libnetwork/options"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/opts"
|
||||||
|
"github.com/docker/docker/pkg/stringid"
|
||||||
|
"github.com/docker/docker/runconfig"
|
||||||
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,11 @@ import (
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/daemon/links"
|
"github.com/docker/docker/daemon/links"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
|
"github.com/docker/docker/libnetwork"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/docker/docker/pkg/system"
|
"github.com/docker/docker/pkg/system"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/docker/docker/libnetwork"
|
|
||||||
"github.com/moby/sys/mount"
|
"github.com/moby/sys/mount"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/pkg/system"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
|
"github.com/docker/docker/pkg/system"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
|
@ -55,6 +55,9 @@ import (
|
||||||
"github.com/docker/docker/layer"
|
"github.com/docker/docker/layer"
|
||||||
"github.com/docker/docker/libcontainerd"
|
"github.com/docker/docker/libcontainerd"
|
||||||
libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
|
libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
|
||||||
|
"github.com/docker/docker/libnetwork"
|
||||||
|
"github.com/docker/docker/libnetwork/cluster"
|
||||||
|
nwconfig "github.com/docker/docker/libnetwork/config"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
"github.com/docker/docker/pkg/system"
|
"github.com/docker/docker/pkg/system"
|
||||||
|
@ -65,9 +68,6 @@ import (
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
volumesservice "github.com/docker/docker/volume/service"
|
volumesservice "github.com/docker/docker/volume/service"
|
||||||
"github.com/docker/docker/libnetwork"
|
|
||||||
"github.com/docker/docker/libnetwork/cluster"
|
|
||||||
nwconfig "github.com/docker/docker/libnetwork/config"
|
|
||||||
"github.com/moby/locker"
|
"github.com/moby/locker"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/sync/semaphore"
|
"golang.org/x/sync/semaphore"
|
||||||
|
|
|
@ -10,12 +10,12 @@ import (
|
||||||
containertypes "github.com/docker/docker/api/types/container"
|
containertypes "github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
|
"github.com/docker/docker/libnetwork"
|
||||||
_ "github.com/docker/docker/pkg/discovery/memory"
|
_ "github.com/docker/docker/pkg/discovery/memory"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
"github.com/docker/docker/pkg/truncindex"
|
"github.com/docker/docker/pkg/truncindex"
|
||||||
volumesservice "github.com/docker/docker/volume/service"
|
volumesservice "github.com/docker/docker/volume/service"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/docker/docker/libnetwork"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
|
|
|
@ -28,6 +28,13 @@ import (
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
"github.com/docker/docker/daemon/initlayer"
|
"github.com/docker/docker/daemon/initlayer"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
|
"github.com/docker/docker/libnetwork"
|
||||||
|
nwconfig "github.com/docker/docker/libnetwork/config"
|
||||||
|
"github.com/docker/docker/libnetwork/drivers/bridge"
|
||||||
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
|
"github.com/docker/docker/libnetwork/netutils"
|
||||||
|
"github.com/docker/docker/libnetwork/options"
|
||||||
|
lntypes "github.com/docker/docker/libnetwork/types"
|
||||||
"github.com/docker/docker/opts"
|
"github.com/docker/docker/opts"
|
||||||
"github.com/docker/docker/pkg/containerfs"
|
"github.com/docker/docker/pkg/containerfs"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
|
@ -36,13 +43,6 @@ import (
|
||||||
"github.com/docker/docker/pkg/sysinfo"
|
"github.com/docker/docker/pkg/sysinfo"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
volumemounts "github.com/docker/docker/volume/mounts"
|
volumemounts "github.com/docker/docker/volume/mounts"
|
||||||
"github.com/docker/docker/libnetwork"
|
|
||||||
nwconfig "github.com/docker/docker/libnetwork/config"
|
|
||||||
"github.com/docker/docker/libnetwork/drivers/bridge"
|
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
|
||||||
"github.com/docker/docker/libnetwork/netutils"
|
|
||||||
"github.com/docker/docker/libnetwork/options"
|
|
||||||
lntypes "github.com/docker/docker/libnetwork/types"
|
|
||||||
"github.com/moby/sys/mount"
|
"github.com/moby/sys/mount"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/opencontainers/selinux/go-selinux"
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
|
|
|
@ -14,6 +14,12 @@ import (
|
||||||
containertypes "github.com/docker/docker/api/types/container"
|
containertypes "github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
|
"github.com/docker/docker/libnetwork"
|
||||||
|
nwconfig "github.com/docker/docker/libnetwork/config"
|
||||||
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
|
winlibnetwork "github.com/docker/docker/libnetwork/drivers/windows"
|
||||||
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
|
"github.com/docker/docker/libnetwork/options"
|
||||||
"github.com/docker/docker/pkg/containerfs"
|
"github.com/docker/docker/pkg/containerfs"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
"github.com/docker/docker/pkg/parsers"
|
"github.com/docker/docker/pkg/parsers"
|
||||||
|
@ -21,12 +27,6 @@ import (
|
||||||
"github.com/docker/docker/pkg/sysinfo"
|
"github.com/docker/docker/pkg/sysinfo"
|
||||||
"github.com/docker/docker/pkg/system"
|
"github.com/docker/docker/pkg/system"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/docker/docker/libnetwork"
|
|
||||||
nwconfig "github.com/docker/docker/libnetwork/config"
|
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
|
||||||
winlibnetwork "github.com/docker/docker/libnetwork/drivers/windows"
|
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
|
||||||
"github.com/docker/docker/libnetwork/options"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
|
|
|
@ -17,10 +17,6 @@ import (
|
||||||
clustertypes "github.com/docker/docker/daemon/cluster/provider"
|
clustertypes "github.com/docker/docker/daemon/cluster/provider"
|
||||||
internalnetwork "github.com/docker/docker/daemon/network"
|
internalnetwork "github.com/docker/docker/daemon/network"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/docker/opts"
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/runconfig"
|
|
||||||
"github.com/docker/go-connections/nat"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
lncluster "github.com/docker/docker/libnetwork/cluster"
|
lncluster "github.com/docker/docker/libnetwork/cluster"
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
|
@ -29,6 +25,10 @@ import (
|
||||||
"github.com/docker/docker/libnetwork/networkdb"
|
"github.com/docker/docker/libnetwork/networkdb"
|
||||||
"github.com/docker/docker/libnetwork/options"
|
"github.com/docker/docker/libnetwork/options"
|
||||||
networktypes "github.com/docker/docker/libnetwork/types"
|
networktypes "github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/opts"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
|
"github.com/docker/docker/runconfig"
|
||||||
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,9 +10,9 @@ import (
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
"github.com/docker/docker/daemon/network"
|
"github.com/docker/docker/daemon/network"
|
||||||
|
"github.com/docker/docker/libnetwork"
|
||||||
"github.com/docker/docker/pkg/containerfs"
|
"github.com/docker/docker/pkg/containerfs"
|
||||||
"github.com/docker/docker/pkg/idtools"
|
"github.com/docker/docker/pkg/idtools"
|
||||||
"github.com/docker/docker/libnetwork"
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
"gotest.tools/v3/skip"
|
"gotest.tools/v3/skip"
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
timetypes "github.com/docker/docker/api/types/time"
|
timetypes "github.com/docker/docker/api/types/time"
|
||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/docker/runconfig"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,10 +9,10 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/daemon/config"
|
"github.com/docker/docker/daemon/config"
|
||||||
"github.com/docker/docker/daemon/images"
|
"github.com/docker/docker/daemon/images"
|
||||||
|
"github.com/docker/docker/libnetwork"
|
||||||
"github.com/docker/docker/pkg/discovery"
|
"github.com/docker/docker/pkg/discovery"
|
||||||
_ "github.com/docker/docker/pkg/discovery/memory"
|
_ "github.com/docker/docker/pkg/discovery/memory"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/docker/docker/libnetwork"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
|
|
|
@ -18,8 +18,8 @@ TESTDIRS="${TESTDIRS:-./...}"
|
||||||
exclude_paths='/vendor/|/integration'
|
exclude_paths='/vendor/|/integration'
|
||||||
pkg_list=$(go list $TESTDIRS | grep -vE "($exclude_paths)")
|
pkg_list=$(go list $TESTDIRS | grep -vE "($exclude_paths)")
|
||||||
|
|
||||||
echo "${pkg_list}" | grep --fixed-strings "libnetwork/drivers/bridge" && \
|
echo "${pkg_list}" | grep --fixed-strings "libnetwork/drivers/bridge" \
|
||||||
if ! type docker-proxy; then
|
&& if ! type docker-proxy; then
|
||||||
hack/make.sh binary-proxy install-proxy
|
hack/make.sh binary-proxy install-proxy
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ linters:
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
- bundles
|
- bundles
|
||||||
- docs
|
- docs
|
||||||
|
# TODO: This package should be completely removed
|
||||||
|
- libnetwork/client/mflag
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
govet:
|
govet:
|
||||||
|
@ -59,6 +61,11 @@ issues:
|
||||||
- text: "G304: Potential file inclusion via variable"
|
- text: "G304: Potential file inclusion via variable"
|
||||||
linters:
|
linters:
|
||||||
- gosec
|
- gosec
|
||||||
|
- text: "G306: Expect WriteFile permissions to be 0600 or less"
|
||||||
|
linters:
|
||||||
|
- gosec
|
||||||
|
- text: 'G307: Deferring unsafe method "Close" on type "*os.File"'
|
||||||
|
linters: gosec
|
||||||
|
|
||||||
# Exclude some linters from running on tests files.
|
# Exclude some linters from running on tests files.
|
||||||
- path: _test\.go
|
- path: _test\.go
|
||||||
|
@ -86,3 +93,16 @@ issues:
|
||||||
- text: "SA1019: httputil.ErrPersistEOF is deprecated"
|
- text: "SA1019: httputil.ErrPersistEOF is deprecated"
|
||||||
linters:
|
linters:
|
||||||
- staticcheck
|
- staticcheck
|
||||||
|
# This code is doing some fun stuff with reflect and it trips up the linter.
|
||||||
|
- text: "field `foo` is unused"
|
||||||
|
path: "libnetwork/options/options_test.go"
|
||||||
|
linters:
|
||||||
|
- structcheck
|
||||||
|
- unused
|
||||||
|
# This field is only used on windows but is defined in a platform agnostic file.
|
||||||
|
# The linter doesn't understand that the field is used.
|
||||||
|
- text: "`resolverOnce` is unused"
|
||||||
|
path: libnetwork/network.go
|
||||||
|
linters:
|
||||||
|
- structcheck
|
||||||
|
- unused
|
|
@ -4,7 +4,7 @@ set -e -o pipefail
|
||||||
shfmtflags="-bn -ci -sr"
|
shfmtflags="-bn -ci -sr"
|
||||||
# NOTE: `git grep '^#!'` may also pick up non-shell script files.
|
# NOTE: `git grep '^#!'` may also pick up non-shell script files.
|
||||||
# Add exceptional files to `egrep -v` if any false-positive is detected.
|
# Add exceptional files to `egrep -v` if any false-positive is detected.
|
||||||
if git grep --name-only '^#!' | egrep -v '(vendor|\.go|Jenkinsfile)' \
|
if git grep --name-only '^#!' | egrep -v '(vendor|\.go|Jenkinsfile|\.py|\.bats)' \
|
||||||
| xargs shfmt -d $shfmtflags; then
|
| xargs shfmt -d $shfmtflags; then
|
||||||
echo 'Congratulations! The shell scripts are properly formatted.'
|
echo 'Congratulations! The shell scripts are properly formatted.'
|
||||||
else
|
else
|
||||||
|
|
|
@ -31,10 +31,10 @@ import (
|
||||||
"github.com/docker/docker/integration-cli/cli"
|
"github.com/docker/docker/integration-cli/cli"
|
||||||
"github.com/docker/docker/integration-cli/cli/build"
|
"github.com/docker/docker/integration-cli/cli/build"
|
||||||
"github.com/docker/docker/integration-cli/daemon"
|
"github.com/docker/docker/integration-cli/daemon"
|
||||||
|
"github.com/docker/docker/libnetwork/iptables"
|
||||||
"github.com/docker/docker/opts"
|
"github.com/docker/docker/opts"
|
||||||
testdaemon "github.com/docker/docker/testutil/daemon"
|
testdaemon "github.com/docker/docker/testutil/daemon"
|
||||||
units "github.com/docker/go-units"
|
units "github.com/docker/go-units"
|
||||||
"github.com/docker/docker/libnetwork/iptables"
|
|
||||||
"github.com/docker/libtrust"
|
"github.com/docker/libtrust"
|
||||||
"github.com/moby/sys/mount"
|
"github.com/moby/sys/mount"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
|
@ -18,14 +18,14 @@ import (
|
||||||
"github.com/docker/docker/api/types/versions/v1p20"
|
"github.com/docker/docker/api/types/versions/v1p20"
|
||||||
"github.com/docker/docker/integration-cli/cli"
|
"github.com/docker/docker/integration-cli/cli"
|
||||||
"github.com/docker/docker/integration-cli/daemon"
|
"github.com/docker/docker/integration-cli/daemon"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
|
||||||
"github.com/docker/docker/runconfig"
|
|
||||||
testdaemon "github.com/docker/docker/testutil/daemon"
|
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
remoteapi "github.com/docker/docker/libnetwork/drivers/remote/api"
|
remoteapi "github.com/docker/docker/libnetwork/drivers/remote/api"
|
||||||
"github.com/docker/docker/libnetwork/ipamapi"
|
"github.com/docker/docker/libnetwork/ipamapi"
|
||||||
remoteipam "github.com/docker/docker/libnetwork/ipams/remote/api"
|
remoteipam "github.com/docker/docker/libnetwork/ipams/remote/api"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
|
"github.com/docker/docker/pkg/stringid"
|
||||||
|
"github.com/docker/docker/runconfig"
|
||||||
|
testdaemon "github.com/docker/docker/testutil/daemon"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
|
|
|
@ -27,13 +27,13 @@ import (
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/docker/docker/integration-cli/cli"
|
"github.com/docker/docker/integration-cli/cli"
|
||||||
"github.com/docker/docker/integration-cli/cli/build"
|
"github.com/docker/docker/integration-cli/cli/build"
|
||||||
|
"github.com/docker/docker/libnetwork/resolvconf"
|
||||||
|
"github.com/docker/docker/libnetwork/types"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/docker/docker/testutil"
|
"github.com/docker/docker/testutil"
|
||||||
"github.com/docker/docker/testutil/fakecontext"
|
"github.com/docker/docker/testutil/fakecontext"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/docker/docker/libnetwork/resolvconf"
|
|
||||||
"github.com/docker/docker/libnetwork/types"
|
|
||||||
"github.com/moby/sys/mountinfo"
|
"github.com/moby/sys/mountinfo"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/icmd"
|
"gotest.tools/v3/icmd"
|
||||||
|
|
|
@ -569,7 +569,7 @@ func (c *client) CreateCheckpoint(ctx context.Context, containerID, checkpointDi
|
||||||
var cpDesc *v1.Descriptor
|
var cpDesc *v1.Descriptor
|
||||||
for _, m := range index.Manifests {
|
for _, m := range index.Manifests {
|
||||||
if m.MediaType == images.MediaTypeContainerd1Checkpoint {
|
if m.MediaType == images.MediaTypeContainerd1Checkpoint {
|
||||||
cpDesc = &m
|
cpDesc = &m // nolint:gosec
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,13 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/docker/go-events"
|
|
||||||
"github.com/docker/docker/libnetwork/cluster"
|
"github.com/docker/docker/libnetwork/cluster"
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/networkdb"
|
"github.com/docker/docker/libnetwork/networkdb"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/go-events"
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -793,7 +793,7 @@ func (n *network) addDriverWatches() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
agent.networkDB.WalkTable(table.name, func(nid, key string, value []byte, deleted bool) bool {
|
err = agent.networkDB.WalkTable(table.name, func(nid, key string, value []byte, deleted bool) bool {
|
||||||
// skip the entries that are mark for deletion, this is safe because this function is
|
// skip the entries that are mark for deletion, this is safe because this function is
|
||||||
// called at initialization time so there is no state to delete
|
// called at initialization time so there is no state to delete
|
||||||
if nid == n.ID() && !deleted {
|
if nid == n.ID() && !deleted {
|
||||||
|
@ -801,6 +801,9 @@ func (n *network) addDriverWatches() {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
logrus.WithError(err).Warn("Error while walking networkdb")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
var (
|
var (
|
||||||
successResponse = responseStatus{Status: "Success", StatusCode: http.StatusOK}
|
successResponse = responseStatus{Status: "Success", StatusCode: http.StatusOK}
|
||||||
createdResponse = responseStatus{Status: "Created", StatusCode: http.StatusCreated}
|
createdResponse = responseStatus{Status: "Created", StatusCode: http.StatusCreated}
|
||||||
mismatchResponse = responseStatus{Status: "Body/URI parameter mismatch", StatusCode: http.StatusBadRequest}
|
|
||||||
badQueryResponse = responseStatus{Status: "Unsupported query", StatusCode: http.StatusBadRequest}
|
badQueryResponse = responseStatus{Status: "Unsupported query", StatusCode: http.StatusBadRequest}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,11 +28,9 @@ const (
|
||||||
regex = "[a-zA-Z_0-9-]+"
|
regex = "[a-zA-Z_0-9-]+"
|
||||||
qregx = "$|" + regex
|
qregx = "$|" + regex
|
||||||
// Router URL variable definition
|
// Router URL variable definition
|
||||||
nwName = "{" + urlNwName + ":" + regex + "}"
|
|
||||||
nwNameQr = "{" + urlNwName + ":" + qregx + "}"
|
nwNameQr = "{" + urlNwName + ":" + qregx + "}"
|
||||||
nwID = "{" + urlNwID + ":" + regex + "}"
|
nwID = "{" + urlNwID + ":" + regex + "}"
|
||||||
nwPIDQr = "{" + urlNwPID + ":" + qregx + "}"
|
nwPIDQr = "{" + urlNwPID + ":" + qregx + "}"
|
||||||
epName = "{" + urlEpName + ":" + regex + "}"
|
|
||||||
epNameQr = "{" + urlEpName + ":" + qregx + "}"
|
epNameQr = "{" + urlEpName + ":" + qregx + "}"
|
||||||
epID = "{" + urlEpID + ":" + regex + "}"
|
epID = "{" + urlEpID + ":" + regex + "}"
|
||||||
epPIDQr = "{" + urlEpPID + ":" + qregx + "}"
|
epPIDQr = "{" + urlEpPID + ":" + qregx + "}"
|
||||||
|
@ -260,11 +257,6 @@ func (sc *sandboxCreate) parseOptions() []libnetwork.SandboxOption {
|
||||||
return setFctList
|
return setFctList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ej *endpointJoin) parseOptions() []libnetwork.EndpointOption {
|
|
||||||
// priority will go here
|
|
||||||
return []libnetwork.EndpointOption{}
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
Process functions
|
Process functions
|
||||||
*******************/
|
*******************/
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
bridgeNetType = "bridge"
|
bridgeNetType = "bridge"
|
||||||
bridgeName = "docker0"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func i2s(i interface{}) string {
|
func i2s(i interface{}) string {
|
||||||
|
@ -1664,7 +1663,7 @@ func newWriter() *localResponseWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *localResponseWriter) Header() http.Header {
|
func (f *localResponseWriter) Header() http.Header {
|
||||||
return make(map[string][]string, 0)
|
return make(map[string][]string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *localResponseWriter) Write(data []byte) (int, error) {
|
func (f *localResponseWriter) Write(data []byte) (int, error) {
|
||||||
|
|
|
@ -144,11 +144,7 @@ func (s *sequence) equal(o *sequence) bool {
|
||||||
this = this.next
|
this = this.next
|
||||||
other = other.next
|
other = other.next
|
||||||
}
|
}
|
||||||
// Check if other is longer than this
|
return other == nil
|
||||||
if other != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToByteArray converts the sequence into a byte array
|
// ToByteArray converts the sequence into a byte array
|
||||||
|
@ -699,7 +695,6 @@ func removeCurrentIfEmpty(head **sequence, previous, current *sequence) {
|
||||||
*head = current.next
|
*head = current.next
|
||||||
} else {
|
} else {
|
||||||
previous.next = current.next
|
previous.next = current.next
|
||||||
current = current.next
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -849,7 +849,7 @@ func TestSetAnyInRange(t *testing.T) {
|
||||||
|
|
||||||
func TestMethods(t *testing.T) {
|
func TestMethods(t *testing.T) {
|
||||||
numBits := uint64(256 * blockLen)
|
numBits := uint64(256 * blockLen)
|
||||||
hnd, err := NewHandle("path/to/data", nil, "sequence1", uint64(numBits))
|
hnd, err := NewHandle("path/to/data", nil, "sequence1", numBits)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package bitseq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
@ -106,17 +105,6 @@ func (h *Handle) DataScope() string {
|
||||||
return h.store.Scope()
|
return h.store.Scope()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) fromDsValue(value []byte) error {
|
|
||||||
var ba []byte
|
|
||||||
if err := json.Unmarshal(value, &ba); err != nil {
|
|
||||||
return fmt.Errorf("failed to decode json: %s", err.Error())
|
|
||||||
}
|
|
||||||
if err := h.FromByteArray(ba); err != nil {
|
|
||||||
return fmt.Errorf("failed to decode handle: %s", err.Error())
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Handle) writeToStore() error {
|
func (h *Handle) writeToStore() error {
|
||||||
h.Lock()
|
h.Lock()
|
||||||
store := h.store
|
store := h.store
|
||||||
|
|
|
@ -231,7 +231,7 @@ func (s *stringValue) Set(val string) error {
|
||||||
|
|
||||||
func (s *stringValue) Get() interface{} { return string(*s) }
|
func (s *stringValue) Get() interface{} { return string(*s) }
|
||||||
|
|
||||||
func (s *stringValue) String() string { return fmt.Sprintf("%s", *s) }
|
func (s *stringValue) String() string { return string(*s) }
|
||||||
|
|
||||||
// -- float64 Value
|
// -- float64 Value
|
||||||
type float64Value float64
|
type float64Value float64
|
||||||
|
|
|
@ -97,9 +97,7 @@ func TestEverything(t *testing.T) {
|
||||||
// Now test they're visited in sort order.
|
// Now test they're visited in sort order.
|
||||||
var flagNames []string
|
var flagNames []string
|
||||||
Visit(func(f *Flag) {
|
Visit(func(f *Flag) {
|
||||||
for _, name := range f.Names {
|
flagNames = append(flagNames, f.Names...)
|
||||||
flagNames = append(flagNames, name)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
if !sort.StringsAreSorted(flagNames) {
|
if !sort.StringsAreSorted(flagNames) {
|
||||||
t.Errorf("flag names not sorted: %v", flagNames)
|
t.Errorf("flag names not sorted: %v", flagNames)
|
||||||
|
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
|
||||||
flag "github.com/docker/docker/libnetwork/client/mflag"
|
flag "github.com/docker/docker/libnetwork/client/mflag"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
|
"github.com/docker/docker/pkg/stringid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type command struct {
|
type command struct {
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
|
||||||
flag "github.com/docker/docker/libnetwork/client/mflag"
|
flag "github.com/docker/docker/libnetwork/client/mflag"
|
||||||
"github.com/docker/docker/libnetwork/netutils"
|
"github.com/docker/docker/libnetwork/netutils"
|
||||||
|
"github.com/docker/docker/pkg/stringid"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -86,11 +86,3 @@ type extraHost struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// sandboxParentUpdate is the object carrying the information about the
|
|
||||||
// sandbox parent that needs to be updated.
|
|
||||||
type sandboxParentUpdate struct {
|
|
||||||
ContainerID string `json:"container_id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Address string `json:"address"`
|
|
||||||
}
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ func fetchNodePeers(ip string, port int, network string) map[string]string {
|
||||||
path = fmt.Sprintf(clusterPeers, ip, port)
|
path = fmt.Sprintf(clusterPeers, ip, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := http.Get(path)
|
resp, err := http.Get(path) // nolint:gosec
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Fatalf("Failed fetching path")
|
logrus.WithError(err).Fatalf("Failed fetching path")
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@ import (
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/pkg/discovery"
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
"github.com/docker/docker/libnetwork/api"
|
"github.com/docker/docker/libnetwork/api"
|
||||||
"github.com/docker/docker/libnetwork/cluster"
|
"github.com/docker/docker/libnetwork/cluster"
|
||||||
|
@ -33,6 +31,8 @@ import (
|
||||||
"github.com/docker/docker/libnetwork/netutils"
|
"github.com/docker/docker/libnetwork/netutils"
|
||||||
"github.com/docker/docker/libnetwork/options"
|
"github.com/docker/docker/libnetwork/options"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/discovery"
|
||||||
|
"github.com/docker/docker/pkg/reexec"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/moby/term"
|
"github.com/moby/term"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -43,13 +43,11 @@ const (
|
||||||
// DefaultHTTPHost is used if only port is provided to -H flag e.g. docker -d -H tcp://:8080
|
// DefaultHTTPHost is used if only port is provided to -H flag e.g. docker -d -H tcp://:8080
|
||||||
DefaultHTTPHost = "0.0.0.0"
|
DefaultHTTPHost = "0.0.0.0"
|
||||||
// DefaultHTTPPort is the default http port used by dnet
|
// DefaultHTTPPort is the default http port used by dnet
|
||||||
DefaultHTTPPort = 2385
|
DefaultHTTPPort = 2385
|
||||||
// DefaultUnixSocket exported
|
cfgFileEnv = "LIBNETWORK_CFG"
|
||||||
DefaultUnixSocket = "/var/run/dnet.sock"
|
defaultCfgFile = "/etc/default/libnetwork.toml"
|
||||||
cfgFileEnv = "LIBNETWORK_CFG"
|
defaultHeartbeat = time.Duration(10) * time.Second
|
||||||
defaultCfgFile = "/etc/default/libnetwork.toml"
|
ttlFactor = 2
|
||||||
defaultHeartbeat = time.Duration(10) * time.Second
|
|
||||||
ttlFactor = 2
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var epConn *dnetConnection
|
var epConn *dnetConnection
|
||||||
|
@ -172,11 +170,9 @@ func startDiscovery(cfg *config.ClusterCfg) ([]config.Option, error) {
|
||||||
options := []config.Option{config.OptionDiscoveryWatcher(d), config.OptionDiscoveryAddress(cfg.Address)}
|
options := []config.Option{config.OptionDiscoveryWatcher(d), config.OptionDiscoveryAddress(cfg.Address)}
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
time.Sleep(hb)
|
||||||
case <-time.After(hb):
|
if err := d.Register(cfg.Address + ":0"); err != nil {
|
||||||
if err := d.Register(cfg.Address + ":0"); err != nil {
|
logrus.Warn(err)
|
||||||
logrus.Warn(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -507,7 +503,7 @@ func (d *dnetConnection) httpCall(method, path string, data interface{}, headers
|
||||||
return nil, nil, -1, err
|
return nil, nil, -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest(method, fmt.Sprintf("%s", path), in)
|
req, err := http.NewRequest(method, path, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, -1, err
|
return nil, nil, -1, err
|
||||||
}
|
}
|
||||||
|
@ -552,10 +548,8 @@ func setupRequestHeaders(method string, data interface{}, req *http.Request, hea
|
||||||
req.Header.Set("Content-Type", "text/plain")
|
req.Header.Set("Content-Type", "text/plain")
|
||||||
}
|
}
|
||||||
|
|
||||||
if headers != nil {
|
for k, v := range headers {
|
||||||
for k, v := range headers {
|
req.Header[k] = v
|
||||||
req.Header[k] = v
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,19 +118,6 @@ func dbTableEntriesNumber(ip, port, networkName, tableName string, doneCh chan r
|
||||||
doneCh <- resultTuple{id: ip, result: entriesNum}
|
doneCh <- resultTuple{id: ip, result: entriesNum}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dbEntriesNumber(ip, port, networkName string, doneCh chan resultTuple) {
|
|
||||||
body, err := httpGet(ip, port, "/networkstats?nid="+networkName)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
logrus.Errorf("entriesNumber %s there was an error: %s", ip, err)
|
|
||||||
doneCh <- resultTuple{id: ip, result: -1}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
elementsRegexp := regexp.MustCompile(`entries: ([0-9]+)`)
|
|
||||||
entriesNum, _ := strconv.Atoi(elementsRegexp.FindStringSubmatch(string(body))[1])
|
|
||||||
doneCh <- resultTuple{id: ip, result: entriesNum}
|
|
||||||
}
|
|
||||||
|
|
||||||
func dbQueueLength(ip, port, networkName string, doneCh chan resultTuple) {
|
func dbQueueLength(ip, port, networkName string, doneCh chan resultTuple) {
|
||||||
body, err := httpGet(ip, port, "/networkstats?nid="+networkName)
|
body, err := httpGet(ip, port, "/networkstats?nid="+networkName)
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
events "github.com/docker/go-events"
|
|
||||||
"github.com/docker/docker/libnetwork/diagnostic"
|
"github.com/docker/docker/libnetwork/diagnostic"
|
||||||
"github.com/docker/docker/libnetwork/networkdb"
|
"github.com/docker/docker/libnetwork/networkdb"
|
||||||
|
events "github.com/docker/go-events"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ type tableHandler struct {
|
||||||
var clientWatchTable = map[string]tableHandler{}
|
var clientWatchTable = map[string]tableHandler{}
|
||||||
|
|
||||||
func watchTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
func watchTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm() // nolint:errcheck
|
||||||
diagnostic.DebugHTTPForm(r)
|
diagnostic.DebugHTTPForm(r)
|
||||||
if len(r.Form["tname"]) < 1 {
|
if len(r.Form["tname"]) < 1 {
|
||||||
rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name", r.URL.Path))
|
rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name", r.URL.Path))
|
||||||
diagnostic.HTTPReply(w, rsp, &diagnostic.JSONOutput{})
|
diagnostic.HTTPReply(w, rsp, &diagnostic.JSONOutput{}) // nolint:errcheck
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,11 +54,11 @@ func watchTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func watchTableEntries(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
func watchTableEntries(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm() // nolint:errcheck
|
||||||
diagnostic.DebugHTTPForm(r)
|
diagnostic.DebugHTTPForm(r)
|
||||||
if len(r.Form["tname"]) < 1 {
|
if len(r.Form["tname"]) < 1 {
|
||||||
rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name", r.URL.Path))
|
rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name", r.URL.Path))
|
||||||
diagnostic.HTTPReply(w, rsp, &diagnostic.JSONOutput{})
|
diagnostic.HTTPReply(w, rsp, &diagnostic.JSONOutput{}) // nolint:errcheck
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/drivers/overlay"
|
"github.com/docker/docker/libnetwork/drivers/overlay"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
|
"github.com/docker/docker/pkg/reexec"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -161,14 +161,13 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sigCh := make(chan os.Signal, 1)
|
sigCh := make(chan os.Signal, 1)
|
||||||
signal.Notify(sigCh, os.Interrupt, os.Kill)
|
signal.Notify(sigCh, os.Interrupt)
|
||||||
|
|
||||||
for {
|
for range sigCh {
|
||||||
select {
|
if err := r.d.Leave("testnetwork", "testep"); err != nil {
|
||||||
case <-sigCh:
|
fmt.Printf("Error leaving: %v", err)
|
||||||
r.d.Leave("testnetwork", "testep")
|
|
||||||
overlay.Fini(r.d)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
}
|
||||||
|
overlay.Fini(r.d)
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
)
|
|
||||||
|
|
||||||
// StubProxy is a proxy that is a stub (does nothing).
|
|
||||||
type StubProxy struct {
|
|
||||||
frontendAddr net.Addr
|
|
||||||
backendAddr net.Addr
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run does nothing.
|
|
||||||
func (p *StubProxy) Run() {}
|
|
||||||
|
|
||||||
// Close does nothing.
|
|
||||||
func (p *StubProxy) Close() {}
|
|
||||||
|
|
||||||
// FrontendAddr returns the frontend address.
|
|
||||||
func (p *StubProxy) FrontendAddr() net.Addr { return p.frontendAddr }
|
|
||||||
|
|
||||||
// BackendAddr returns the backend address.
|
|
||||||
func (p *StubProxy) BackendAddr() net.Addr { return p.backendAddr }
|
|
||||||
|
|
||||||
// NewStubProxy creates a new StubProxy
|
|
||||||
func NewStubProxy(frontendAddr, backendAddr net.Addr) (Proxy, error) {
|
|
||||||
return &StubProxy{
|
|
||||||
frontendAddr: frontendAddr,
|
|
||||||
backendAddr: backendAddr,
|
|
||||||
}, nil
|
|
||||||
}
|
|
|
@ -4,11 +4,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
"github.com/docker/docker/libnetwork/config"
|
"github.com/docker/docker/libnetwork/config"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/docker/libnetwork/options"
|
"github.com/docker/docker/libnetwork/options"
|
||||||
|
"github.com/docker/docker/pkg/reexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -5,16 +5,16 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/docker/docker/pkg/discovery"
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/go-connections/tlsconfig"
|
|
||||||
"github.com/docker/libkv/store"
|
|
||||||
"github.com/docker/docker/libnetwork/cluster"
|
"github.com/docker/docker/libnetwork/cluster"
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/ipamutils"
|
"github.com/docker/docker/libnetwork/ipamutils"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
"github.com/docker/docker/libnetwork/osl"
|
||||||
"github.com/docker/docker/libnetwork/portallocator"
|
"github.com/docker/docker/libnetwork/portallocator"
|
||||||
|
"github.com/docker/docker/pkg/discovery"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
|
"github.com/docker/go-connections/tlsconfig"
|
||||||
|
"github.com/docker/libkv/store"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/discovery"
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/pkg/plugins"
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
|
||||||
"github.com/docker/docker/libnetwork/cluster"
|
"github.com/docker/docker/libnetwork/cluster"
|
||||||
"github.com/docker/docker/libnetwork/config"
|
"github.com/docker/docker/libnetwork/config"
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
|
@ -69,6 +65,10 @@ import (
|
||||||
"github.com/docker/docker/libnetwork/options"
|
"github.com/docker/docker/libnetwork/options"
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
"github.com/docker/docker/libnetwork/osl"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/discovery"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
|
"github.com/docker/docker/pkg/plugins"
|
||||||
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/moby/locker"
|
"github.com/moby/locker"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -156,28 +156,27 @@ type SandboxWalker func(sb Sandbox) bool
|
||||||
type sandboxTable map[string]*sandbox
|
type sandboxTable map[string]*sandbox
|
||||||
|
|
||||||
type controller struct {
|
type controller struct {
|
||||||
id string
|
id string
|
||||||
drvRegistry *drvregistry.DrvRegistry
|
drvRegistry *drvregistry.DrvRegistry
|
||||||
sandboxes sandboxTable
|
sandboxes sandboxTable
|
||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
stores []datastore.DataStore
|
stores []datastore.DataStore
|
||||||
discovery hostdiscovery.HostDiscovery
|
discovery hostdiscovery.HostDiscovery
|
||||||
extKeyListener net.Listener
|
extKeyListener net.Listener
|
||||||
watchCh chan *endpoint
|
watchCh chan *endpoint
|
||||||
unWatchCh chan *endpoint
|
unWatchCh chan *endpoint
|
||||||
svcRecords map[string]svcInfo
|
svcRecords map[string]svcInfo
|
||||||
nmap map[string]*netWatch
|
nmap map[string]*netWatch
|
||||||
serviceBindings map[serviceKey]*service
|
serviceBindings map[serviceKey]*service
|
||||||
defOsSbox osl.Sandbox
|
defOsSbox osl.Sandbox
|
||||||
ingressSandbox *sandbox
|
ingressSandbox *sandbox
|
||||||
sboxOnce sync.Once
|
sboxOnce sync.Once
|
||||||
agent *agent
|
agent *agent
|
||||||
networkLocker *locker.Locker
|
networkLocker *locker.Locker
|
||||||
agentInitDone chan struct{}
|
agentInitDone chan struct{}
|
||||||
agentStopDone chan struct{}
|
agentStopDone chan struct{}
|
||||||
keys []*types.EncryptionKey
|
keys []*types.EncryptionKey
|
||||||
clusterConfigAvailable bool
|
DiagnosticServer *diagnostic.Server
|
||||||
DiagnosticServer *diagnostic.Server
|
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,10 +277,6 @@ func (c *controller) SetClusterProvider(provider cluster.Provider) {
|
||||||
go c.clusterAgentInit()
|
go c.clusterAgentInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
func isValidClusteringIP(addr string) bool {
|
|
||||||
return addr != "" && !net.ParseIP(addr).IsLoopback() && !net.ParseIP(addr).IsUnspecified()
|
|
||||||
}
|
|
||||||
|
|
||||||
// libnetwork side of agent depends on the keys. On the first receipt of
|
// libnetwork side of agent depends on the keys. On the first receipt of
|
||||||
// keys setup the agent. For subsequent key set handle the key change
|
// keys setup the agent. For subsequent key set handle the key change
|
||||||
func (c *controller) SetKeys(keys []*types.EncryptionKey) error {
|
func (c *controller) SetKeys(keys []*types.EncryptionKey) error {
|
||||||
|
@ -559,13 +554,6 @@ func (c *controller) BuiltinIPAMDrivers() []string {
|
||||||
return drivers
|
return drivers
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controller) validateHostDiscoveryConfig() bool {
|
|
||||||
if c.cfg == nil || c.cfg.Cluster.Discovery == "" || c.cfg.Cluster.Address == "" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *controller) clusterHostID() string {
|
func (c *controller) clusterHostID() string {
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
@ -576,21 +564,6 @@ func (c *controller) clusterHostID() string {
|
||||||
return addr[0]
|
return addr[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controller) isNodeAlive(node string) bool {
|
|
||||||
if c.discovery == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes := c.discovery.Fetch()
|
|
||||||
for _, n := range nodes {
|
|
||||||
if n.String() == node {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *controller) initDiscovery(watcher discovery.Watcher) error {
|
func (c *controller) initDiscovery(watcher discovery.Watcher) error {
|
||||||
if c.cfg == nil {
|
if c.cfg == nil {
|
||||||
return fmt.Errorf("discovery initialization requires a valid configuration")
|
return fmt.Errorf("discovery initialization requires a valid configuration")
|
||||||
|
@ -716,7 +689,7 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
|
||||||
|
|
||||||
if id != "" {
|
if id != "" {
|
||||||
c.networkLocker.Lock(id)
|
c.networkLocker.Lock(id)
|
||||||
defer c.networkLocker.Unlock(id)
|
defer c.networkLocker.Unlock(id) // nolint:errcheck
|
||||||
|
|
||||||
if _, err = c.NetworkByID(id); err == nil {
|
if _, err = c.NetworkByID(id); err == nil {
|
||||||
return nil, NetworkNameError(id)
|
return nil, NetworkNameError(id)
|
||||||
|
@ -827,7 +800,7 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
|
||||||
|
|
||||||
err = c.addNetwork(network)
|
err = c.addNetwork(network)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(types.MaskableError); ok {
|
if _, ok := err.(types.MaskableError); ok { // nolint:gosimple
|
||||||
// This error can be ignored and set this boolean
|
// This error can be ignored and set this boolean
|
||||||
// value to skip a refcount increment for configOnly networks
|
// value to skip a refcount increment for configOnly networks
|
||||||
skipCfgEpCount = true
|
skipCfgEpCount = true
|
||||||
|
|
|
@ -8,10 +8,10 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/libkv"
|
|
||||||
"github.com/docker/libkv/store"
|
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/libkv"
|
||||||
|
"github.com/docker/libkv/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
//DataStore exported
|
//DataStore exported
|
||||||
|
|
|
@ -3,8 +3,8 @@ package datastore
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/docker/libkv/store"
|
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/libkv/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -125,5 +125,4 @@ func (s *MockStore) AtomicDelete(key string, previous *store.KVPair) (bool, erro
|
||||||
|
|
||||||
// Close closes the client connection
|
// Close closes the client connection
|
||||||
func (s *MockStore) Close() {
|
func (s *MockStore) Close() {
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,18 +162,6 @@ func (ep *endpoint) endpointInGWNetwork() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *sandbox) getEPwithoutGateway() *endpoint {
|
|
||||||
for _, ep := range sb.getConnectedEndpoints() {
|
|
||||||
if ep.getNetwork().Type() == "null" || ep.getNetwork().Type() == "host" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if len(ep.Gateway()) == 0 {
|
|
||||||
return ep
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Looks for the default gw network and creates it if not there.
|
// Looks for the default gw network and creates it if not there.
|
||||||
// Parallel executions are serialized.
|
// Parallel executions are serialized.
|
||||||
func (c *controller) defaultGwNetwork() (Network, error) {
|
func (c *controller) defaultGwNetwork() (Network, error) {
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
stackdump "github.com/docker/docker/pkg/signal"
|
|
||||||
"github.com/docker/docker/libnetwork/internal/caller"
|
"github.com/docker/docker/libnetwork/internal/caller"
|
||||||
|
stackdump "github.com/docker/docker/pkg/signal"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ func (s *Server) DisableDiagnostic() {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
|
|
||||||
s.srv.Shutdown(context.Background())
|
s.srv.Shutdown(context.Background()) // nolint:errcheck
|
||||||
s.srv = nil
|
s.srv = nil
|
||||||
s.enable = 0
|
s.enable = 0
|
||||||
logrus.Info("Disabling the diagnostic server")
|
logrus.Info("Disabling the diagnostic server")
|
||||||
|
@ -122,7 +122,7 @@ func (s *Server) IsDiagnosticEnabled() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func notImplemented(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
func notImplemented(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm() // nolint:errcheck
|
||||||
_, json := ParseHTTPFormOptions(r)
|
_, json := ParseHTTPFormOptions(r)
|
||||||
rsp := WrongCommand("not implemented", fmt.Sprintf("URL path: %s no method implemented check /help\n", r.URL.Path))
|
rsp := WrongCommand("not implemented", fmt.Sprintf("URL path: %s no method implemented check /help\n", r.URL.Path))
|
||||||
|
|
||||||
|
@ -130,11 +130,11 @@ func notImplemented(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
log := logrus.WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
|
log := logrus.WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
|
||||||
log.Info("command not implemented done")
|
log.Info("command not implemented done")
|
||||||
|
|
||||||
HTTPReply(w, rsp, json)
|
HTTPReply(w, rsp, json) // nolint:errcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func help(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
func help(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm() // nolint:errcheck
|
||||||
_, json := ParseHTTPFormOptions(r)
|
_, json := ParseHTTPFormOptions(r)
|
||||||
|
|
||||||
// audit logs
|
// audit logs
|
||||||
|
@ -147,22 +147,22 @@ func help(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
for path := range n.registeredHanders {
|
for path := range n.registeredHanders {
|
||||||
result += fmt.Sprintf("%s\n", path)
|
result += fmt.Sprintf("%s\n", path)
|
||||||
}
|
}
|
||||||
HTTPReply(w, CommandSucceed(&StringCmd{Info: result}), json)
|
HTTPReply(w, CommandSucceed(&StringCmd{Info: result}), json) // nolint:errcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ready(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
func ready(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm() // nolint:errcheck
|
||||||
_, json := ParseHTTPFormOptions(r)
|
_, json := ParseHTTPFormOptions(r)
|
||||||
|
|
||||||
// audit logs
|
// audit logs
|
||||||
log := logrus.WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
|
log := logrus.WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
|
||||||
log.Info("ready done")
|
log.Info("ready done")
|
||||||
HTTPReply(w, CommandSucceed(&StringCmd{Info: "OK"}), json)
|
HTTPReply(w, CommandSucceed(&StringCmd{Info: "OK"}), json) // nolint:errcheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func stackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
func stackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
r.ParseForm()
|
r.ParseForm() // nolint:errcheck
|
||||||
_, json := ParseHTTPFormOptions(r)
|
_, json := ParseHTTPFormOptions(r)
|
||||||
|
|
||||||
// audit logs
|
// audit logs
|
||||||
|
@ -172,10 +172,10 @@ func stackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
path, err := stackdump.DumpStacks("/tmp/")
|
path, err := stackdump.DumpStacks("/tmp/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("failed to write goroutines dump")
|
log.WithError(err).Error("failed to write goroutines dump")
|
||||||
HTTPReply(w, FailCommand(err), json)
|
HTTPReply(w, FailCommand(err), json) // nolint:errcheck
|
||||||
} else {
|
} else {
|
||||||
log.Info("stack trace done")
|
log.Info("stack trace done")
|
||||||
HTTPReply(w, CommandSucceed(&StringCmd{Info: fmt.Sprintf("goroutine stacks written to %s", path)}), json)
|
HTTPReply(w, CommandSucceed(&StringCmd{Info: fmt.Sprintf("goroutine stacks written to %s", path)}), json) // nolint:errcheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ package driverapi
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NetworkPluginEndpointType represents the Endpoint Type used by Plugin system
|
// NetworkPluginEndpointType represents the Endpoint Type used by Plugin system
|
||||||
|
|
|
@ -144,7 +144,6 @@ type bridgeNetwork struct {
|
||||||
|
|
||||||
type driver struct {
|
type driver struct {
|
||||||
config *configuration
|
config *configuration
|
||||||
network *bridgeNetwork
|
|
||||||
natChain *iptables.ChainInfo
|
natChain *iptables.ChainInfo
|
||||||
filterChain *iptables.ChainInfo
|
filterChain *iptables.ChainInfo
|
||||||
isolationChain1 *iptables.ChainInfo
|
isolationChain1 *iptables.ChainInfo
|
||||||
|
@ -399,7 +398,9 @@ func (d *driver) configure(option map[string]interface{}) error {
|
||||||
// Make sure on firewall reload, first thing being re-played is chains creation
|
// Make sure on firewall reload, first thing being re-played is chains creation
|
||||||
iptables.OnReloaded(func() {
|
iptables.OnReloaded(func() {
|
||||||
logrus.Debugf("Recreating iptables chains on firewall reload")
|
logrus.Debugf("Recreating iptables chains on firewall reload")
|
||||||
setupIPChains(config, iptables.IPv4)
|
if _, _, _, _, err := setupIPChains(config, iptables.IPv4); err != nil {
|
||||||
|
logrus.WithError(err).Error("Error reloading iptables chains")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +415,9 @@ func (d *driver) configure(option map[string]interface{}) error {
|
||||||
// Make sure on firewall reload, first thing being re-played is chains creation
|
// Make sure on firewall reload, first thing being re-played is chains creation
|
||||||
iptables.OnReloaded(func() {
|
iptables.OnReloaded(func() {
|
||||||
logrus.Debugf("Recreating ip6tables chains on firewall reload")
|
logrus.Debugf("Recreating ip6tables chains on firewall reload")
|
||||||
setupIPChains(config, iptables.IPv6)
|
if _, _, _, _, err := setupIPChains(config, iptables.IPv6); err != nil {
|
||||||
|
logrus.WithError(err).Error("Error reloading ip6tables chains")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,7 +552,7 @@ func parseNetworkOptions(id string, option options.Generic) (*networkConfigurati
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.BridgeName == "" && config.DefaultBridge == false {
|
if config.BridgeName == "" && !config.DefaultBridge {
|
||||||
config.BridgeName = "br-" + id[:12]
|
config.BridgeName = "br-" + id[:12]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,18 +571,6 @@ func parseNetworkOptions(id string, option options.Generic) (*networkConfigurati
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the non link-local IPv6 subnet for the containers attached to this bridge if found, nil otherwise
|
|
||||||
func getV6Network(config *networkConfiguration, i *bridgeInterface) *net.IPNet {
|
|
||||||
if config.AddressIPv6 != nil {
|
|
||||||
return config.AddressIPv6
|
|
||||||
}
|
|
||||||
if i.bridgeIPv6 != nil && i.bridgeIPv6.IP != nil && !i.bridgeIPv6.IP.IsLinkLocalUnicast() {
|
|
||||||
return i.bridgeIPv6
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a slice of networks over which caller can iterate safely
|
// Return a slice of networks over which caller can iterate safely
|
||||||
func (d *driver) getNetworks() []*bridgeNetwork {
|
func (d *driver) getNetworks() []*bridgeNetwork {
|
||||||
d.Lock()
|
d.Lock()
|
||||||
|
@ -643,7 +634,9 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo d
|
||||||
}
|
}
|
||||||
// Got a conflict with a stale default network, clean that up and continue
|
// Got a conflict with a stale default network, clean that up and continue
|
||||||
logrus.Warn(nerr)
|
logrus.Warn(nerr)
|
||||||
d.deleteNetwork(nerr.ID)
|
if err := d.deleteNetwork(nerr.ID); err != nil {
|
||||||
|
logrus.WithError(err).Debug("Error while cleaning up network on conflict")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is no conflict, now create the network
|
// there is no conflict, now create the network
|
||||||
|
|
|
@ -455,16 +455,24 @@ func TestCreateMultipleNetworks(t *testing.T) {
|
||||||
|
|
||||||
verifyV4INCEntries(d.networks, t)
|
verifyV4INCEntries(d.networks, t)
|
||||||
|
|
||||||
d.DeleteNetwork("1")
|
if err := d.DeleteNetwork("1"); err != nil {
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
verifyV4INCEntries(d.networks, t)
|
verifyV4INCEntries(d.networks, t)
|
||||||
|
|
||||||
d.DeleteNetwork("2")
|
if err := d.DeleteNetwork("2"); err != nil {
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
verifyV4INCEntries(d.networks, t)
|
verifyV4INCEntries(d.networks, t)
|
||||||
|
|
||||||
d.DeleteNetwork("3")
|
if err := d.DeleteNetwork("3"); err != nil {
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
verifyV4INCEntries(d.networks, t)
|
verifyV4INCEntries(d.networks, t)
|
||||||
|
|
||||||
d.DeleteNetwork("4")
|
if err := d.DeleteNetwork("4"); err != nil {
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
verifyV4INCEntries(d.networks, t)
|
verifyV4INCEntries(d.networks, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,12 +511,10 @@ type testInterface struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type testEndpoint struct {
|
type testEndpoint struct {
|
||||||
iface *testInterface
|
iface *testInterface
|
||||||
gw net.IP
|
gw net.IP
|
||||||
gw6 net.IP
|
gw6 net.IP
|
||||||
hostsPath string
|
routes []types.StaticRoute
|
||||||
resolvConfPath string
|
|
||||||
routes []types.StaticRoute
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestEndpoint(nw *net.IPNet, ordinal byte) *testEndpoint {
|
func newTestEndpoint(nw *net.IPNet, ordinal byte) *testEndpoint {
|
||||||
|
@ -662,7 +668,7 @@ func testQueryEndpointInfo(t *testing.T, ulPxyEnabled bool) {
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Cannot find network %s inside driver", "net1")
|
t.Fatalf("Cannot find network %s inside driver", "net1")
|
||||||
}
|
}
|
||||||
ep, _ := network.endpoints["ep1"]
|
ep := network.endpoints["ep1"]
|
||||||
data, err := d.EndpointOperInfo(network.id, ep.id)
|
data, err := d.EndpointOperInfo(network.id, ep.id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to ask for endpoint operational data: %v", err)
|
t.Fatalf("Failed to ask for endpoint operational data: %v", err)
|
||||||
|
@ -794,7 +800,7 @@ func TestLinkContainers(t *testing.T) {
|
||||||
t.Fatalf("Failed to program external connectivity: %v", err)
|
t.Fatalf("Failed to program external connectivity: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := iptable.Raw("-L", DockerChain)
|
out, _ := iptable.Raw("-L", DockerChain)
|
||||||
for _, pm := range exposedPorts {
|
for _, pm := range exposedPorts {
|
||||||
regex := fmt.Sprintf("%s dpt:%d", pm.Proto.String(), pm.Port)
|
regex := fmt.Sprintf("%s dpt:%d", pm.Proto.String(), pm.Port)
|
||||||
re := regexp.MustCompile(regex)
|
re := regexp.MustCompile(regex)
|
||||||
|
@ -820,7 +826,7 @@ func TestLinkContainers(t *testing.T) {
|
||||||
t.Fatal("Failed to unlink ep1 and ep2")
|
t.Fatal("Failed to unlink ep1 and ep2")
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err = iptable.Raw("-L", DockerChain)
|
out, _ = iptable.Raw("-L", DockerChain)
|
||||||
for _, pm := range exposedPorts {
|
for _, pm := range exposedPorts {
|
||||||
regex := fmt.Sprintf("%s dpt:%d", pm.Proto.String(), pm.Port)
|
regex := fmt.Sprintf("%s dpt:%d", pm.Proto.String(), pm.Port)
|
||||||
re := regexp.MustCompile(regex)
|
re := regexp.MustCompile(regex)
|
||||||
|
@ -848,7 +854,7 @@ func TestLinkContainers(t *testing.T) {
|
||||||
}
|
}
|
||||||
err = d.ProgramExternalConnectivity("net1", "ep2", sbOptions)
|
err = d.ProgramExternalConnectivity("net1", "ep2", sbOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
out, err = iptable.Raw("-L", DockerChain)
|
out, _ = iptable.Raw("-L", DockerChain)
|
||||||
for _, pm := range exposedPorts {
|
for _, pm := range exposedPorts {
|
||||||
regex := fmt.Sprintf("%s dpt:%d", pm.Proto.String(), pm.Port)
|
regex := fmt.Sprintf("%s dpt:%d", pm.Proto.String(), pm.Port)
|
||||||
re := regexp.MustCompile(regex)
|
re := regexp.MustCompile(regex)
|
||||||
|
|
|
@ -2,10 +2,8 @@ package bridge
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"net"
|
"net"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,8 +23,6 @@ type ifreqHwaddr struct {
|
||||||
IfruHwaddr syscall.RawSockaddr
|
IfruHwaddr syscall.RawSockaddr
|
||||||
}
|
}
|
||||||
|
|
||||||
var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
||||||
|
|
||||||
// THIS CODE DOES NOT COMMUNICATE WITH KERNEL VIA RTNETLINK INTERFACE
|
// THIS CODE DOES NOT COMMUNICATE WITH KERNEL VIA RTNETLINK INTERFACE
|
||||||
// IT IS HERE FOR BACKWARDS COMPATIBILITY WITH OLDER LINUX KERNELS
|
// IT IS HERE FOR BACKWARDS COMPATIBILITY WITH OLDER LINUX KERNELS
|
||||||
// WHICH SHIP WITH OLDER NOT ENTIRELY FUNCTIONAL VERSION OF NETLINK
|
// WHICH SHIP WITH OLDER NOT ENTIRELY FUNCTIONAL VERSION OF NETLINK
|
||||||
|
|
|
@ -6,10 +6,10 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/docker/libnetwork/testutils"
|
"github.com/docker/docker/libnetwork/testutils"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/reexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
@ -71,7 +71,7 @@ func TestPortMappingConfig(t *testing.T) {
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Cannot find network %s inside driver", "dummy")
|
t.Fatalf("Cannot find network %s inside driver", "dummy")
|
||||||
}
|
}
|
||||||
ep, _ := network.endpoints["ep1"]
|
ep := network.endpoints["ep1"]
|
||||||
if len(ep.portMapping) != 3 {
|
if len(ep.portMapping) != 3 {
|
||||||
t.Fatalf("Failed to store the port bindings into the sandbox info. Found: %v", ep.portMapping)
|
t.Fatalf("Failed to store the port bindings into the sandbox info. Found: %v", ep.portMapping)
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ func TestPortMappingV6Config(t *testing.T) {
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("Cannot find network %s inside driver", "dummy")
|
t.Fatalf("Cannot find network %s inside driver", "dummy")
|
||||||
}
|
}
|
||||||
ep, _ := network.endpoints["ep1"]
|
ep := network.endpoints["ep1"]
|
||||||
if len(ep.portMapping) != 6 {
|
if len(ep.portMapping) != 6 {
|
||||||
t.Fatalf("Failed to store the port bindings into the sandbox info. Found: %v", ep.portMapping)
|
t.Fatalf("Failed to store the port bindings into the sandbox info. Found: %v", ep.portMapping)
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ func TestGenerateRandomMAC(t *testing.T) {
|
||||||
|
|
||||||
mac1 := netutils.GenerateRandomMAC()
|
mac1 := netutils.GenerateRandomMAC()
|
||||||
mac2 := netutils.GenerateRandomMAC()
|
mac2 := netutils.GenerateRandomMAC()
|
||||||
if bytes.Compare(mac1, mac2) == 0 {
|
if bytes.Equal(mac1, mac2) {
|
||||||
t.Fatalf("Generated twice the same MAC address %v", mac1)
|
t.Fatalf("Generated twice the same MAC address %v", mac1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ func TestSetupIPForwarding(t *testing.T) {
|
||||||
defer reconcileIPForwardingSetting(t, procSetting)
|
defer reconcileIPForwardingSetting(t, procSetting)
|
||||||
|
|
||||||
// Disable IP Forwarding if enabled
|
// Disable IP Forwarding if enabled
|
||||||
if bytes.Compare(procSetting, []byte("1\n")) == 0 {
|
if bytes.Equal(procSetting, []byte("1\n")) {
|
||||||
writeIPForwardingSetting(t, []byte{'0', '\n'})
|
writeIPForwardingSetting(t, []byte{'0', '\n'})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ func TestSetupIPForwarding(t *testing.T) {
|
||||||
|
|
||||||
// Read new setting
|
// Read new setting
|
||||||
procSetting = readCurrentIPForwardingSetting(t)
|
procSetting = readCurrentIPForwardingSetting(t)
|
||||||
if bytes.Compare(procSetting, []byte("1\n")) != 0 {
|
if !bytes.Equal(procSetting, []byte("1\n")) {
|
||||||
t.Fatal("Failed to effectively setup IP forwarding")
|
t.Fatal("Failed to effectively setup IP forwarding")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func writeIPForwardingSetting(t *testing.T, chars []byte) {
|
||||||
|
|
||||||
func reconcileIPForwardingSetting(t *testing.T, original []byte) {
|
func reconcileIPForwardingSetting(t *testing.T, original []byte) {
|
||||||
current := readCurrentIPForwardingSetting(t)
|
current := readCurrentIPForwardingSetting(t)
|
||||||
if bytes.Compare(original, current) != 0 {
|
if !bytes.Equal(original, current) {
|
||||||
writeIPForwardingSetting(t, original)
|
writeIPForwardingSetting(t, original)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ const (
|
||||||
|
|
||||||
func setupIPChains(config *configuration, version iptables.IPVersion) (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
|
func setupIPChains(config *configuration, version iptables.IPVersion) (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
|
||||||
// Sanity check.
|
// Sanity check.
|
||||||
if config.EnableIPTables == false {
|
if !config.EnableIPTables {
|
||||||
return nil, nil, nil, nil, errors.New("cannot create new chains, EnableIPTable is disabled")
|
return nil, nil, nil, nil, errors.New("cannot create new chains, EnableIPTable is disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ func TestSetupIPv6(t *testing.T) {
|
||||||
t.Fatalf("Failed to read disable_ipv6 kernel setting: %v", err)
|
t.Fatalf("Failed to read disable_ipv6 kernel setting: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if expected := []byte("0\n"); bytes.Compare(expected, procSetting) != 0 {
|
if expected := []byte("0\n"); !bytes.Equal(expected, procSetting) {
|
||||||
t.Fatalf("Invalid kernel setting disable_ipv6: expected %q, got %q", string(expected), string(procSetting))
|
t.Fatalf("Invalid kernel setting disable_ipv6: expected %q, got %q", string(expected), string(procSetting))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ func setupVerifyAndReconcile(config *networkConfiguration, i *bridgeInterface) e
|
||||||
// Release any residual IPv6 address that might be there because of older daemon instances
|
// Release any residual IPv6 address that might be there because of older daemon instances
|
||||||
for _, addrv6 := range addrsv6 {
|
for _, addrv6 := range addrsv6 {
|
||||||
if addrv6.IP.IsGlobalUnicast() && !types.CompareIPNet(addrv6.IPNet, i.bridgeIPv6) {
|
if addrv6.IP.IsGlobalUnicast() && !types.CompareIPNet(addrv6.IPNet, i.bridgeIPv6) {
|
||||||
if err := i.nlh.AddrDel(i.Link, &addrv6); err != nil {
|
if err := i.nlh.AddrDel(i.Link, &addrv6); err != nil { // nolint:gosec
|
||||||
logrus.Warnf("Failed to remove residual IPv6 address %s from bridge: %v", addrv6.IPNet, err)
|
logrus.Warnf("Failed to remove residual IPv6 address %s from bridge: %v", addrv6.IPNet, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
||||||
return make(map[string]interface{}, 0), nil
|
return make(map[string]interface{}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Join method is invoked when a Sandbox is attached to an endpoint.
|
// Join method is invoked when a Sandbox is attached to an endpoint.
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -50,7 +49,6 @@ type endpoint struct {
|
||||||
|
|
||||||
type network struct {
|
type network struct {
|
||||||
id string
|
id string
|
||||||
sbox osl.Sandbox
|
|
||||||
endpoints endpointTable
|
endpoints endpointTable
|
||||||
driver *driver
|
driver *driver
|
||||||
config *configuration
|
config *configuration
|
||||||
|
@ -66,7 +64,9 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
||||||
d := &driver{
|
d := &driver{
|
||||||
networks: networkTable{},
|
networks: networkTable{},
|
||||||
}
|
}
|
||||||
d.initStore(config)
|
if err := d.initStore(config); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return dc.RegisterDriver(ipvlanType, d, c)
|
return dc.RegisterDriver(ipvlanType, d, c)
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func (d *driver) NetworkFree(id string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
||||||
return make(map[string]interface{}, 0), nil
|
return make(map[string]interface{}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) Type() string {
|
func (d *driver) Type() string {
|
||||||
|
|
|
@ -5,14 +5,14 @@ package ipvlan
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/parsers/kernel"
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/docker/libnetwork/ns"
|
"github.com/docker/docker/libnetwork/ns"
|
||||||
"github.com/docker/docker/libnetwork/options"
|
"github.com/docker/docker/libnetwork/options"
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
"github.com/docker/docker/libnetwork/osl"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/parsers/kernel"
|
||||||
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -65,11 +65,7 @@ func setIPVlanMode(mode string) (netlink.IPVlanMode, error) {
|
||||||
// parentExists check if the specified interface exists in the default namespace
|
// parentExists check if the specified interface exists in the default namespace
|
||||||
func parentExists(ifaceStr string) bool {
|
func parentExists(ifaceStr string) bool {
|
||||||
_, err := ns.NlHandle().LinkByName(ifaceStr)
|
_, err := ns.NlHandle().LinkByName(ifaceStr)
|
||||||
if err != nil {
|
return err == nil
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// createVlanLink parses sub-interfaces and vlan id for creation
|
// createVlanLink parses sub-interfaces and vlan id for creation
|
||||||
|
|
|
@ -5,7 +5,6 @@ package ipvlan
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -89,19 +88,6 @@ func validateID(nid, eid string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) sandbox() osl.Sandbox {
|
|
||||||
n.Lock()
|
|
||||||
defer n.Unlock()
|
|
||||||
|
|
||||||
return n.sbox
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *network) setSandbox(sbox osl.Sandbox) {
|
|
||||||
n.Lock()
|
|
||||||
n.sbox = sbox
|
|
||||||
n.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *driver) getNetwork(id string) (*network, error) {
|
func (d *driver) getNetwork(id string) (*network, error) {
|
||||||
d.Lock()
|
d.Lock()
|
||||||
defer d.Unlock()
|
defer d.Unlock()
|
||||||
|
|
|
@ -5,9 +5,9 @@ package ipvlan
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
)
|
)
|
||||||
|
|
||||||
const testNetworkType = "ipvlan"
|
const testNetworkType = "ipvlan"
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -52,7 +51,6 @@ type endpoint struct {
|
||||||
|
|
||||||
type network struct {
|
type network struct {
|
||||||
id string
|
id string
|
||||||
sbox osl.Sandbox
|
|
||||||
endpoints endpointTable
|
endpoints endpointTable
|
||||||
driver *driver
|
driver *driver
|
||||||
config *configuration
|
config *configuration
|
||||||
|
@ -68,7 +66,9 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
||||||
d := &driver{
|
d := &driver{
|
||||||
networks: networkTable{},
|
networks: networkTable{},
|
||||||
}
|
}
|
||||||
d.initStore(config)
|
if err := d.initStore(config); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return dc.RegisterDriver(macvlanType, d, c)
|
return dc.RegisterDriver(macvlanType, d, c)
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func (d *driver) NetworkFree(id string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
||||||
return make(map[string]interface{}, 0), nil
|
return make(map[string]interface{}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) Type() string {
|
func (d *driver) Type() string {
|
||||||
|
|
|
@ -5,13 +5,13 @@ package macvlan
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
"github.com/docker/docker/libnetwork/ns"
|
"github.com/docker/docker/libnetwork/ns"
|
||||||
"github.com/docker/docker/libnetwork/options"
|
"github.com/docker/docker/libnetwork/options"
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
"github.com/docker/docker/libnetwork/osl"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -67,11 +67,7 @@ func setMacVlanMode(mode string) (netlink.MacvlanMode, error) {
|
||||||
// parentExists checks if the specified interface exists in the default namespace
|
// parentExists checks if the specified interface exists in the default namespace
|
||||||
func parentExists(ifaceStr string) bool {
|
func parentExists(ifaceStr string) bool {
|
||||||
_, err := ns.NlHandle().LinkByName(ifaceStr)
|
_, err := ns.NlHandle().LinkByName(ifaceStr)
|
||||||
if err != nil {
|
return err == nil
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// createVlanLink parses sub-interfaces and vlan id for creation
|
// createVlanLink parses sub-interfaces and vlan id for creation
|
||||||
|
|
|
@ -5,7 +5,6 @@ package macvlan
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -88,19 +87,6 @@ func validateID(nid, eid string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) sandbox() osl.Sandbox {
|
|
||||||
n.Lock()
|
|
||||||
defer n.Unlock()
|
|
||||||
|
|
||||||
return n.sbox
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *network) setSandbox(sbox osl.Sandbox) {
|
|
||||||
n.Lock()
|
|
||||||
n.sbox = sbox
|
|
||||||
n.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *driver) getNetwork(id string) (*network, error) {
|
func (d *driver) getNetwork(id string) (*network, error) {
|
||||||
d.Lock()
|
d.Lock()
|
||||||
defer d.Unlock()
|
defer d.Unlock()
|
||||||
|
|
|
@ -5,9 +5,9 @@ package macvlan
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
)
|
)
|
||||||
|
|
||||||
const testNetworkType = "macvlan"
|
const testNetworkType = "macvlan"
|
||||||
|
|
|
@ -65,7 +65,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
||||||
return make(map[string]interface{}, 0), nil
|
return make(map[string]interface{}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Join method is invoked when a Sandbox is attached to an endpoint.
|
// Join method is invoked when a Sandbox is attached to an endpoint.
|
||||||
|
|
|
@ -629,7 +629,7 @@ func clearEncryptionStates() {
|
||||||
}
|
}
|
||||||
for _, sp := range spList {
|
for _, sp := range spList {
|
||||||
if sp.Mark != nil && sp.Mark.Value == spMark.Value {
|
if sp.Mark != nil && sp.Mark.Value == spMark.Value {
|
||||||
if err := nlh.XfrmPolicyDel(&sp); err != nil {
|
if err := nlh.XfrmPolicyDel(&sp); err != nil { // nolint:gosec
|
||||||
logrus.Warnf("Failed to delete stale SP %s: %v", sp, err)
|
logrus.Warnf("Failed to delete stale SP %s: %v", sp, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -638,7 +638,7 @@ func clearEncryptionStates() {
|
||||||
}
|
}
|
||||||
for _, sa := range saList {
|
for _, sa := range saList {
|
||||||
if sa.Reqid == r {
|
if sa.Reqid == r {
|
||||||
if err := nlh.XfrmStateDel(&sa); err != nil {
|
if err := nlh.XfrmStateDel(&sa); err != nil { // nolint:gosec
|
||||||
logrus.Warnf("Failed to delete stale SA %s: %v", sa, err)
|
logrus.Warnf("Failed to delete stale SA %s: %v", sa, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
||||||
return make(map[string]interface{}, 0), nil
|
return make(map[string]interface{}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) deleteEndpointFromStore(e *endpoint) error {
|
func (d *driver) deleteEndpointFromStore(e *endpoint) error {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
|
@ -24,6 +23,7 @@ import (
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
"github.com/docker/docker/libnetwork/osl"
|
||||||
"github.com/docker/docker/libnetwork/resolvconf"
|
"github.com/docker/docker/libnetwork/resolvconf"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/reexec"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
"github.com/vishvananda/netlink/nl"
|
"github.com/vishvananda/netlink/nl"
|
||||||
|
@ -415,7 +415,9 @@ func (n *network) destroySandbox() {
|
||||||
|
|
||||||
func populateVNITbl() {
|
func populateVNITbl() {
|
||||||
filepath.Walk(filepath.Dir(osl.GenerateKey("walk")),
|
filepath.Walk(filepath.Dir(osl.GenerateKey("walk")),
|
||||||
func(path string, info os.FileInfo, err error) error {
|
// NOTE(cpuguy83): The linter picked up on the fact that this walk function was not using this error argument
|
||||||
|
// That seems wrong... however I'm not familiar with this code or if that error matters
|
||||||
|
func(path string, info os.FileInfo, _ error) error {
|
||||||
_, fname := filepath.Split(path)
|
_, fname := filepath.Split(path)
|
||||||
|
|
||||||
if len(strings.Split(fname, "-")) <= 1 {
|
if len(strings.Split(fname, "-")) <= 1 {
|
||||||
|
|
|
@ -151,7 +151,7 @@ func (d *driver) resolvePeer(nid string, peerIP net.IP) (net.HardwareAddr, net.I
|
||||||
return nil, nil, nil, fmt.Errorf("could not resolve peer: serf instance not initialized")
|
return nil, nil, nil, fmt.Errorf("could not resolve peer: serf instance not initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
qPayload := fmt.Sprintf("%s %s", string(nid), peerIP.String())
|
qPayload := fmt.Sprintf("%s %s", nid, peerIP.String())
|
||||||
resp, err := d.serfInstance.Query("peerlookup", []byte(qPayload), nil)
|
resp, err := d.serfInstance.Query("peerlookup", []byte(qPayload), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, fmt.Errorf("resolving peer by querying the cluster failed: %v", err)
|
return nil, nil, nil, fmt.Errorf("resolving peer by querying the cluster failed: %v", err)
|
||||||
|
|
|
@ -13,13 +13,13 @@ import (
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/libkv/store/consul"
|
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
|
"github.com/docker/libkv/store/consul"
|
||||||
"github.com/vishvananda/netlink/nl"
|
"github.com/vishvananda/netlink/nl"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ type networkTable map[string]*network
|
||||||
type driver struct {
|
type driver struct {
|
||||||
config map[string]interface{}
|
config map[string]interface{}
|
||||||
networks networkTable
|
networks networkTable
|
||||||
store datastore.DataStore
|
|
||||||
vxlanIdm *idm.Idm
|
vxlanIdm *idm.Idm
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ func (d *driver) peerDbNetworkWalk(nid string, f func(*peerKey, *peerEntry) bool
|
||||||
if _, err := fmt.Sscan(pKeyStr, &pKey); err != nil {
|
if _, err := fmt.Sscan(pKeyStr, &pKey); err != nil {
|
||||||
logrus.Warnf("Peer key scan on network %s failed: %v", nid, err)
|
logrus.Warnf("Peer key scan on network %s failed: %v", nid, err)
|
||||||
}
|
}
|
||||||
if f(&pKey, &pEntry) {
|
if f(&pKey, &pEntry) { // nolint:gosec
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/pkg/plugins"
|
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/drivers/remote/api"
|
"github.com/docker/docker/libnetwork/drivers/remote/api"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
|
"github.com/docker/docker/pkg/plugins"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,10 +6,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
"github.com/docker/docker/libnetwork/ipamapi"
|
"github.com/docker/docker/libnetwork/ipamapi"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
)
|
)
|
||||||
|
|
||||||
type driverData struct {
|
type driverData struct {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
|
@ -60,7 +59,6 @@ type endpoint struct {
|
||||||
anonymous bool
|
anonymous bool
|
||||||
disableResolution bool
|
disableResolution bool
|
||||||
generic map[string]interface{}
|
generic map[string]interface{}
|
||||||
joinLeaveDone chan struct{}
|
|
||||||
prefAddress net.IP
|
prefAddress net.IP
|
||||||
prefAddressV6 net.IP
|
prefAddressV6 net.IP
|
||||||
ipamOptions map[string]string
|
ipamOptions map[string]string
|
||||||
|
@ -117,19 +115,25 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) {
|
||||||
ep.name = epMap["name"].(string)
|
ep.name = epMap["name"].(string)
|
||||||
ep.id = epMap["id"].(string)
|
ep.id = epMap["id"].(string)
|
||||||
|
|
||||||
|
// TODO(cpuguy83): So yeah, this isn't checking any errors anywhere.
|
||||||
|
// Seems like we should be checking errors even because of memory related issues that can arise.
|
||||||
|
// Alas it seems like given the nature of this data we could introduce problems if we start checking these errors.
|
||||||
|
//
|
||||||
|
// If anyone ever comes here and figures out one way or another if we can/should be checking these errors and it turns out we can't... then please document *why*
|
||||||
|
|
||||||
ib, _ := json.Marshal(epMap["ep_iface"])
|
ib, _ := json.Marshal(epMap["ep_iface"])
|
||||||
json.Unmarshal(ib, &ep.iface)
|
json.Unmarshal(ib, &ep.iface) // nolint:errcheck
|
||||||
|
|
||||||
jb, _ := json.Marshal(epMap["joinInfo"])
|
jb, _ := json.Marshal(epMap["joinInfo"])
|
||||||
json.Unmarshal(jb, &ep.joinInfo)
|
json.Unmarshal(jb, &ep.joinInfo) // nolint:errcheck
|
||||||
|
|
||||||
tb, _ := json.Marshal(epMap["exposed_ports"])
|
tb, _ := json.Marshal(epMap["exposed_ports"])
|
||||||
var tPorts []types.TransportPort
|
var tPorts []types.TransportPort
|
||||||
json.Unmarshal(tb, &tPorts)
|
json.Unmarshal(tb, &tPorts) // nolint:errcheck
|
||||||
ep.exposedPorts = tPorts
|
ep.exposedPorts = tPorts
|
||||||
|
|
||||||
cb, _ := json.Marshal(epMap["sandbox"])
|
cb, _ := json.Marshal(epMap["sandbox"])
|
||||||
json.Unmarshal(cb, &ep.sandboxID)
|
json.Unmarshal(cb, &ep.sandboxID) // nolint:errcheck
|
||||||
|
|
||||||
if v, ok := epMap["generic"]; ok {
|
if v, ok := epMap["generic"]; ok {
|
||||||
ep.generic = v.(map[string]interface{})
|
ep.generic = v.(map[string]interface{})
|
||||||
|
@ -208,17 +212,17 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) {
|
||||||
|
|
||||||
sal, _ := json.Marshal(epMap["svcAliases"])
|
sal, _ := json.Marshal(epMap["svcAliases"])
|
||||||
var svcAliases []string
|
var svcAliases []string
|
||||||
json.Unmarshal(sal, &svcAliases)
|
json.Unmarshal(sal, &svcAliases) // nolint:errcheck
|
||||||
ep.svcAliases = svcAliases
|
ep.svcAliases = svcAliases
|
||||||
|
|
||||||
pc, _ := json.Marshal(epMap["ingressPorts"])
|
pc, _ := json.Marshal(epMap["ingressPorts"])
|
||||||
var ingressPorts []*PortConfig
|
var ingressPorts []*PortConfig
|
||||||
json.Unmarshal(pc, &ingressPorts)
|
json.Unmarshal(pc, &ingressPorts) // nolint:errcheck
|
||||||
ep.ingressPorts = ingressPorts
|
ep.ingressPorts = ingressPorts
|
||||||
|
|
||||||
ma, _ := json.Marshal(epMap["myAliases"])
|
ma, _ := json.Marshal(epMap["myAliases"])
|
||||||
var myAliases []string
|
var myAliases []string
|
||||||
json.Unmarshal(ma, &myAliases)
|
json.Unmarshal(ma, &myAliases) // nolint:errcheck
|
||||||
ep.myAliases = myAliases
|
ep.myAliases = myAliases
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -253,12 +257,16 @@ func (ep *endpoint) CopyTo(o datastore.KVObject) error {
|
||||||
|
|
||||||
if ep.iface != nil {
|
if ep.iface != nil {
|
||||||
dstEp.iface = &endpointInterface{}
|
dstEp.iface = &endpointInterface{}
|
||||||
ep.iface.CopyTo(dstEp.iface)
|
if err := ep.iface.CopyTo(dstEp.iface); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ep.joinInfo != nil {
|
if ep.joinInfo != nil {
|
||||||
dstEp.joinInfo = &endpointJoinInfo{}
|
dstEp.joinInfo = &endpointJoinInfo{}
|
||||||
ep.joinInfo.CopyTo(dstEp.joinInfo)
|
if err := ep.joinInfo.CopyTo(dstEp.joinInfo); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dstEp.exposedPorts = make([]types.TransportPort, len(ep.exposedPorts))
|
dstEp.exposedPorts = make([]types.TransportPort, len(ep.exposedPorts))
|
||||||
|
@ -354,17 +362,6 @@ func (ep *endpoint) KeyPrefix() []string {
|
||||||
return []string{datastore.EndpointKeyPrefix, ep.network.id}
|
return []string{datastore.EndpointKeyPrefix, ep.network.id}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ep *endpoint) networkIDFromKey(key string) (string, error) {
|
|
||||||
// endpoint Key structure : docker/libnetwork/endpoint/${network-id}/${endpoint-id}
|
|
||||||
// it's an invalid key if the key doesn't have all the 5 key elements above
|
|
||||||
keyElements := strings.Split(key, "/")
|
|
||||||
if !strings.HasPrefix(key, datastore.Key(datastore.EndpointKeyPrefix)) || len(keyElements) < 5 {
|
|
||||||
return "", fmt.Errorf("invalid endpoint key : %v", key)
|
|
||||||
}
|
|
||||||
// network-id is placed at index=3. pls refer to endpoint.Key() method
|
|
||||||
return strings.Split(key, "/")[3], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ep *endpoint) Value() []byte {
|
func (ep *endpoint) Value() []byte {
|
||||||
b, err := json.Marshal(ep)
|
b, err := json.Marshal(ep)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -650,10 +647,14 @@ func (ep *endpoint) rename(name string) error {
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ep.deleteServiceInfoFromCluster(sb, true, "rename")
|
if err2 := ep.deleteServiceInfoFromCluster(sb, true, "rename"); err2 != nil {
|
||||||
|
logrus.WithField("main error", err).WithError(err2).Debug("Error during cleanup due deleting service info from cluster while cleaning up due to other error")
|
||||||
|
}
|
||||||
ep.name = oldName
|
ep.name = oldName
|
||||||
ep.anonymous = oldAnonymous
|
ep.anonymous = oldAnonymous
|
||||||
ep.addServiceInfoToCluster(sb)
|
if err2 := ep.addServiceInfoToCluster(sb); err2 != nil {
|
||||||
|
logrus.WithField("main error", err).WithError(err2).Debug("Error during cleanup due adding service to from cluster while cleaning up due to other error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
|
@ -679,7 +680,7 @@ func (ep *endpoint) rename(name string) error {
|
||||||
// benign error. Besides there is no meaningful recovery that
|
// benign error. Besides there is no meaningful recovery that
|
||||||
// we can do. When the cluster recovers subsequent EpCnt update
|
// we can do. When the cluster recovers subsequent EpCnt update
|
||||||
// will force the peers to get the correct EP name.
|
// will force the peers to get the correct EP name.
|
||||||
n.getEpCnt().updateStore()
|
n.getEpCnt().updateStore() // nolint:errcheck
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1226,7 +1227,9 @@ func (c *controller) cleanupLocalEndpoints() {
|
||||||
epCnt := n.getEpCnt().EndpointCnt()
|
epCnt := n.getEpCnt().EndpointCnt()
|
||||||
if epCnt != uint64(len(epl)) {
|
if epCnt != uint64(len(epl)) {
|
||||||
logrus.Infof("Fixing inconsistent endpoint_cnt for network %s. Expected=%d, Actual=%d", n.name, len(epl), epCnt)
|
logrus.Infof("Fixing inconsistent endpoint_cnt for network %s. Expected=%d, Actual=%d", n.name, len(epl), epCnt)
|
||||||
n.getEpCnt().setCnt(uint64(len(epl)))
|
if err := n.getEpCnt().setCnt(uint64(len(epl))); err != nil {
|
||||||
|
logrus.WithField("network", n.name).WithError(err).Warn("Error while fixing inconsistent endpoint_cnt for network")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,10 @@ func (epi *endpointInterface) UnmarshalJSON(b []byte) error {
|
||||||
|
|
||||||
rb, _ := json.Marshal(epMap["routes"])
|
rb, _ := json.Marshal(epMap["routes"])
|
||||||
var routes []string
|
var routes []string
|
||||||
json.Unmarshal(rb, &routes)
|
|
||||||
|
// TODO(cpuguy83): linter noticed we don't check the error here... no idea why but it seems like it could introduce problems if we start checking
|
||||||
|
json.Unmarshal(rb, &routes) // nolint:errcheck
|
||||||
|
|
||||||
epi.routes = make([]*net.IPNet, 0)
|
epi.routes = make([]*net.IPNet, 0)
|
||||||
for _, route := range routes {
|
for _, route := range routes {
|
||||||
ip, ipr, err := net.ParseCIDR(route)
|
ip, ipr, err := net.ParseCIDR(route)
|
||||||
|
@ -436,11 +439,16 @@ func (epj *endpointJoinInfo) UnmarshalJSON(b []byte) error {
|
||||||
if v, ok := epMap["StaticRoutes"]; ok {
|
if v, ok := epMap["StaticRoutes"]; ok {
|
||||||
tb, _ := json.Marshal(v)
|
tb, _ := json.Marshal(v)
|
||||||
var tStaticRoute []types.StaticRoute
|
var tStaticRoute []types.StaticRoute
|
||||||
json.Unmarshal(tb, &tStaticRoute)
|
// TODO(cpuguy83): Linter caught that we aren't checking errors here
|
||||||
|
// I don't know why we aren't other than potentially the data is not always expected to be right?
|
||||||
|
// This is why I'm not adding the error check.
|
||||||
|
//
|
||||||
|
// In any case for posterity please if you figure this out document it or check the error
|
||||||
|
json.Unmarshal(tb, &tStaticRoute) // nolint:errcheck
|
||||||
}
|
}
|
||||||
var StaticRoutes []*types.StaticRoute
|
var StaticRoutes []*types.StaticRoute
|
||||||
for _, r := range tStaticRoute {
|
for _, r := range tStaticRoute {
|
||||||
StaticRoutes = append(StaticRoutes, &r)
|
StaticRoutes = append(StaticRoutes, &r) // nolint:gosec
|
||||||
}
|
}
|
||||||
epj.StaticRoutes = StaticRoutes
|
epj.StaticRoutes = StaticRoutes
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBuildDefault(t *testing.T) {
|
func TestBuildDefault(t *testing.T) {
|
||||||
|
@ -431,12 +431,10 @@ func TestConcurrentWrites(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
group := new(errgroup.Group)
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
wg.Add(1)
|
i := i
|
||||||
go func(i int) {
|
group.Go(func() error {
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
rec := []Record{
|
rec := []Record{
|
||||||
{
|
{
|
||||||
IP: fmt.Sprintf("%d.%d.%d.%d", i, i, i, i),
|
IP: fmt.Sprintf("%d.%d.%d.%d", i, i, i, i),
|
||||||
|
@ -446,17 +444,20 @@ func TestConcurrentWrites(t *testing.T) {
|
||||||
|
|
||||||
for j := 0; j < 25; j++ {
|
for j := 0; j < 25; j++ {
|
||||||
if err := Add(file.Name(), rec); err != nil {
|
if err := Add(file.Name(), rec); err != nil {
|
||||||
t.Fatal(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := Delete(file.Name(), rec); err != nil {
|
if err := Delete(file.Name(), rec); err != nil {
|
||||||
t.Fatal(err)
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(i)
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
if err := group.Wait(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(file.Name())
|
content, err := ioutil.ReadFile(file.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -8,12 +8,13 @@ import (
|
||||||
|
|
||||||
mapset "github.com/deckarep/golang-set"
|
mapset "github.com/deckarep/golang-set"
|
||||||
"github.com/docker/docker/pkg/discovery"
|
"github.com/docker/docker/pkg/discovery"
|
||||||
|
|
||||||
// Including KV
|
// Including KV
|
||||||
_ "github.com/docker/docker/pkg/discovery/kv"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
_ "github.com/docker/docker/pkg/discovery/kv" // register all the things with host discovery
|
||||||
"github.com/docker/libkv/store/consul"
|
"github.com/docker/libkv/store/consul"
|
||||||
"github.com/docker/libkv/store/etcd"
|
"github.com/docker/libkv/store/etcd"
|
||||||
"github.com/docker/libkv/store/zookeeper"
|
"github.com/docker/libkv/store/zookeeper"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type hostDiscovery struct {
|
type hostDiscovery struct {
|
||||||
|
|
|
@ -18,9 +18,6 @@ import (
|
||||||
const (
|
const (
|
||||||
localAddressSpace = "LocalDefault"
|
localAddressSpace = "LocalDefault"
|
||||||
globalAddressSpace = "GlobalDefault"
|
globalAddressSpace = "GlobalDefault"
|
||||||
// The biggest configurable host subnets
|
|
||||||
minNetSize = 8
|
|
||||||
minNetSizeV6 = 64
|
|
||||||
// datastore keyes for ipam objects
|
// datastore keyes for ipam objects
|
||||||
dsConfigKey = "ipam/" + ipamapi.DefaultIPAM + "/config"
|
dsConfigKey = "ipam/" + ipamapi.DefaultIPAM + "/config"
|
||||||
dsDataKey = "ipam/" + ipamapi.DefaultIPAM + "/data"
|
dsDataKey = "ipam/" + ipamapi.DefaultIPAM + "/data"
|
||||||
|
@ -103,11 +100,9 @@ func (a *Allocator) updateBitMasks(aSpace *addrSpace) error {
|
||||||
aSpace.Unlock()
|
aSpace.Unlock()
|
||||||
|
|
||||||
// Add the bitmasks (data could come from datastore)
|
// Add the bitmasks (data could come from datastore)
|
||||||
if inserterList != nil {
|
for _, f := range inserterList {
|
||||||
for _, f := range inserterList {
|
if err := f(); err != nil {
|
||||||
if err := f(); err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,7 +567,7 @@ func (a *Allocator) getAddress(nw *net.IPNet, bitmask *bitseq.Handle, prefAddres
|
||||||
logrus.Debugf("Request address PoolID:%v %s Serial:%v PrefAddress:%v ", nw, bitmask.String(), serial, prefAddress)
|
logrus.Debugf("Request address PoolID:%v %s Serial:%v PrefAddress:%v ", nw, bitmask.String(), serial, prefAddress)
|
||||||
base = types.GetIPNetCopy(nw)
|
base = types.GetIPNetCopy(nw)
|
||||||
|
|
||||||
if bitmask.Unselected() <= 0 {
|
if bitmask.Unselected() == 0 {
|
||||||
return nil, ipamapi.ErrNoAvailableIPs
|
return nil, ipamapi.ErrNoAvailableIPs
|
||||||
}
|
}
|
||||||
if ipr == nil && prefAddress == nil {
|
if ipr == nil && prefAddress == nil {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
"github.com/docker/libkv/store"
|
"github.com/docker/libkv/store"
|
||||||
"github.com/docker/libkv/store/boltdb"
|
"github.com/docker/libkv/store/boltdb"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
)
|
)
|
||||||
|
@ -307,7 +308,7 @@ func TestAddReleasePoolID(t *testing.T) {
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
var k0, k1 SubnetKey
|
var k0, k1 SubnetKey
|
||||||
aSpace, err := a.getAddrSpace(localAddressSpace)
|
_, err = a.getAddrSpace(localAddressSpace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -320,7 +321,7 @@ func TestAddReleasePoolID(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
aSpace, err = a.getAddrSpace(localAddressSpace)
|
aSpace, err := a.getAddrSpace(localAddressSpace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1070,8 +1071,6 @@ func TestRelease(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
bm := a.addresses[SubnetKey{localAddressSpace, subnet, ""}]
|
|
||||||
|
|
||||||
// Allocate all addresses
|
// Allocate all addresses
|
||||||
for err != ipamapi.ErrNoAvailableIPs {
|
for err != ipamapi.ErrNoAvailableIPs {
|
||||||
_, _, err = a.RequestAddress(pid, nil, nil)
|
_, _, err = a.RequestAddress(pid, nil, nil)
|
||||||
|
@ -1108,7 +1107,7 @@ func TestRelease(t *testing.T) {
|
||||||
for i, inp := range toRelease {
|
for i, inp := range toRelease {
|
||||||
ip0 := net.ParseIP(inp.address)
|
ip0 := net.ParseIP(inp.address)
|
||||||
a.ReleaseAddress(pid, ip0)
|
a.ReleaseAddress(pid, ip0)
|
||||||
bm = a.addresses[SubnetKey{localAddressSpace, subnet, ""}]
|
bm := a.addresses[SubnetKey{localAddressSpace, subnet, ""}]
|
||||||
if bm.Unselected() != 1 {
|
if bm.Unselected() != 1 {
|
||||||
t.Fatalf("Failed to update free address count after release. Expected %d, Found: %d", i+1, bm.Unselected())
|
t.Fatalf("Failed to update free address count after release. Expected %d, Found: %d", i+1, bm.Unselected())
|
||||||
}
|
}
|
||||||
|
@ -1200,13 +1199,6 @@ func benchmarkRequest(b *testing.B, a *Allocator, subnet string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func benchMarkRequest(subnet string, b *testing.B) {
|
|
||||||
a, _ := getAllocator(true)
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
benchmarkRequest(b, a, subnet)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkRequest(b *testing.B) {
|
func BenchmarkRequest(b *testing.B) {
|
||||||
|
|
||||||
subnets := []string{
|
subnets := []string{
|
||||||
|
@ -1442,10 +1434,7 @@ func runParallelTests(t *testing.T, instance int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if instance != first {
|
if instance != first {
|
||||||
select {
|
<-start
|
||||||
case <-start:
|
|
||||||
}
|
|
||||||
|
|
||||||
instDone := make(chan struct{})
|
instDone := make(chan struct{})
|
||||||
done <- instDone
|
done <- instDone
|
||||||
defer close(instDone)
|
defer close(instDone)
|
||||||
|
@ -1462,9 +1451,7 @@ func runParallelTests(t *testing.T, instance int) {
|
||||||
|
|
||||||
if instance == first {
|
if instance == first {
|
||||||
for instDone := range done {
|
for instDone := range done {
|
||||||
select {
|
<-instDone
|
||||||
case <-instDone:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Now check each instance got a different pool
|
// Now check each instance got a different pool
|
||||||
for i := 0; i < numInstances; i++ {
|
for i := 0; i < numInstances; i++ {
|
||||||
|
@ -1495,7 +1482,7 @@ func TestRequestReleaseAddressDuplicate(t *testing.T) {
|
||||||
scope: a.addrSpaces[localAddressSpace].scope,
|
scope: a.addrSpaces[localAddressSpace].scope,
|
||||||
subnets: map[SubnetKey]*PoolData{},
|
subnets: map[SubnetKey]*PoolData{},
|
||||||
}
|
}
|
||||||
var wg sync.WaitGroup
|
|
||||||
opts := map[string]string{
|
opts := map[string]string{
|
||||||
ipamapi.AllocSerialPrefix: "true",
|
ipamapi.AllocSerialPrefix: "true",
|
||||||
}
|
}
|
||||||
|
@ -1506,6 +1493,7 @@ func TestRequestReleaseAddressDuplicate(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group := new(errgroup.Group)
|
||||||
for err == nil {
|
for err == nil {
|
||||||
var c *net.IPNet
|
var c *net.IPNet
|
||||||
if c, _, err = a.RequestAddress(poolID, nil, opts); err == nil {
|
if c, _, err = a.RequestAddress(poolID, nil, opts); err == nil {
|
||||||
|
@ -1515,21 +1503,26 @@ func TestRequestReleaseAddressDuplicate(t *testing.T) {
|
||||||
allocatedIPs = append(allocatedIPs, c)
|
allocatedIPs = append(allocatedIPs, c)
|
||||||
if len(allocatedIPs) > 500 {
|
if len(allocatedIPs) > 500 {
|
||||||
i := rand.Intn(len(allocatedIPs) - 1)
|
i := rand.Intn(len(allocatedIPs) - 1)
|
||||||
wg.Add(1)
|
ip := allocatedIPs[i]
|
||||||
go func(ip *net.IPNet) {
|
group.Go(func() error {
|
||||||
if err = a.ReleaseAddress(poolID, ip.IP); err != nil {
|
if err = a.ReleaseAddress(poolID, ip.IP); err != nil {
|
||||||
t.Fatal(err)
|
return err
|
||||||
}
|
}
|
||||||
l.Lock()
|
l.Lock()
|
||||||
ips = append(ips, IP{ip, -1})
|
ips = append(ips, IP{ip, -1})
|
||||||
l.Unlock()
|
l.Unlock()
|
||||||
wg.Done()
|
return nil
|
||||||
}(allocatedIPs[i])
|
})
|
||||||
|
|
||||||
allocatedIPs = append(allocatedIPs[:i], allocatedIPs[i+1:]...)
|
allocatedIPs = append(allocatedIPs[:i], allocatedIPs[i+1:]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wg.Wait()
|
|
||||||
|
if err := group.Wait(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
refMap := make(map[string]int)
|
refMap := make(map[string]int)
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
refMap[ip.ip.String()] = refMap[ip.ip.String()] + ip.ref
|
refMap[ip.ip.String()] = refMap[ip.ip.String()] + ip.ref
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/libnetwork/ipamapi"
|
"github.com/docker/docker/libnetwork/ipamapi"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
"golang.org/x/sync/semaphore"
|
"golang.org/x/sync/semaphore"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
|
@ -89,11 +90,20 @@ func TestRequestPoolParallel(t *testing.T) {
|
||||||
}
|
}
|
||||||
var operationIndex int32
|
var operationIndex int32
|
||||||
ch := make(chan *op, 240)
|
ch := make(chan *op, 240)
|
||||||
|
|
||||||
|
group := new(errgroup.Group)
|
||||||
|
defer func() {
|
||||||
|
if err := group.Wait(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
for i := 0; i < 120; i++ {
|
for i := 0; i < 120; i++ {
|
||||||
go func(t *testing.T, a *Allocator, ch chan *op) {
|
group.Go(func() error {
|
||||||
name, _, _, err := a.RequestPool("GlobalDefault", "", "", nil, false)
|
name, _, _, err := a.RequestPool("GlobalDefault", "", "", nil, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("request error %v", err)
|
t.Log(err) // log so we can see the error in real time rather than at the end when we actually call "Wait".
|
||||||
|
return fmt.Errorf("request error %v", err)
|
||||||
}
|
}
|
||||||
idx := atomic.AddInt32(&operationIndex, 1)
|
idx := atomic.AddInt32(&operationIndex, 1)
|
||||||
ch <- &op{idx, true, name}
|
ch <- &op{idx, true, name}
|
||||||
|
@ -101,10 +111,12 @@ func TestRequestPoolParallel(t *testing.T) {
|
||||||
idx = atomic.AddInt32(&operationIndex, 1)
|
idx = atomic.AddInt32(&operationIndex, 1)
|
||||||
err = a.ReleasePool(name)
|
err = a.ReleasePool(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("release error %v", err)
|
t.Log(err) // log so we can see the error in real time rather than at the end when we actually call "Wait".
|
||||||
|
return fmt.Errorf("release error %v", err)
|
||||||
}
|
}
|
||||||
ch <- &op{idx, false, name}
|
ch <- &op{idx, false, name}
|
||||||
}(t, a, ch)
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// map of events
|
// map of events
|
||||||
|
@ -258,24 +270,25 @@ func release(t *testing.T, tctx *testContext, mode releaseMode, parallel int64)
|
||||||
var id int
|
var id int
|
||||||
parallelExec := semaphore.NewWeighted(parallel)
|
parallelExec := semaphore.NewWeighted(parallel)
|
||||||
ch := make(chan *net.IPNet, len(ipIndex))
|
ch := make(chan *net.IPNet, len(ipIndex))
|
||||||
wg := sync.WaitGroup{}
|
group := new(errgroup.Group)
|
||||||
for index := range ipIndex {
|
for index := range ipIndex {
|
||||||
wg.Add(1)
|
index := index
|
||||||
go func(id, index int) {
|
group.Go(func() error {
|
||||||
parallelExec.Acquire(context.Background(), 1)
|
parallelExec.Acquire(context.Background(), 1)
|
||||||
// logrus.Errorf("index %v", index)
|
|
||||||
// logrus.Errorf("list %v", tctx.ipList)
|
|
||||||
err := tctx.a.ReleaseAddress(tctx.pid, tctx.ipList[index].IP)
|
err := tctx.a.ReleaseAddress(tctx.pid, tctx.ipList[index].IP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("routine %d got %v", id, err)
|
return fmt.Errorf("routine %d got %v", id, err)
|
||||||
}
|
}
|
||||||
ch <- tctx.ipList[index]
|
ch <- tctx.ipList[index]
|
||||||
parallelExec.Release(1)
|
parallelExec.Release(1)
|
||||||
wg.Done()
|
return nil
|
||||||
}(id, index)
|
})
|
||||||
id++
|
id++
|
||||||
}
|
}
|
||||||
wg.Wait()
|
|
||||||
|
if err := group.Wait(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < len(ipIndex); i++ {
|
for i := 0; i < len(ipIndex); i++ {
|
||||||
ip := <-ch
|
ip := <-ch
|
||||||
|
|
|
@ -116,17 +116,6 @@ func (a *Allocator) writeToStore(aSpace *addrSpace) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Allocator) deleteFromStore(aSpace *addrSpace) error {
|
|
||||||
store := aSpace.store()
|
|
||||||
|
|
||||||
// IPAM may not have a valid store. In such cases it is just in-memory state.
|
|
||||||
if store == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return store.DeleteObjectAtomic(aSpace)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DataScope method returns the storage scope of the datastore
|
// DataScope method returns the storage scope of the datastore
|
||||||
func (aSpace *addrSpace) DataScope() string {
|
func (aSpace *addrSpace) DataScope() string {
|
||||||
aSpace.Lock()
|
aSpace.Lock()
|
||||||
|
|
|
@ -159,7 +159,7 @@ func (aSpace *addrSpace) MarshalJSON() ([]byte, error) {
|
||||||
defer aSpace.Unlock()
|
defer aSpace.Unlock()
|
||||||
|
|
||||||
m := map[string]interface{}{
|
m := map[string]interface{}{
|
||||||
"Scope": string(aSpace.scope),
|
"Scope": aSpace.scope,
|
||||||
}
|
}
|
||||||
|
|
||||||
if aSpace.subnets != nil {
|
if aSpace.subnets != nil {
|
||||||
|
|
|
@ -4,9 +4,9 @@ package ipamapi
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
)
|
)
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
|
|
|
@ -4,12 +4,12 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/plugingetter"
|
|
||||||
"github.com/docker/docker/pkg/plugins"
|
|
||||||
"github.com/docker/docker/libnetwork/discoverapi"
|
"github.com/docker/docker/libnetwork/discoverapi"
|
||||||
"github.com/docker/docker/libnetwork/ipamapi"
|
"github.com/docker/docker/libnetwork/ipamapi"
|
||||||
"github.com/docker/docker/libnetwork/ipams/remote/api"
|
"github.com/docker/docker/libnetwork/ipams/remote/api"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/plugingetter"
|
||||||
|
"github.com/docker/docker/pkg/plugins"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
|
@ -54,6 +54,8 @@ func purgeConntrackState(nlh *netlink.Handle, family netlink.InetFamily, ipAddre
|
||||||
filter := &netlink.ConntrackFilter{}
|
filter := &netlink.ConntrackFilter{}
|
||||||
// NOTE: doing the flush using the ipAddress is safe because today there cannot be multiple networks with the same subnet
|
// NOTE: doing the flush using the ipAddress is safe because today there cannot be multiple networks with the same subnet
|
||||||
// so it will not be possible to flush flows that are of other containers
|
// so it will not be possible to flush flows that are of other containers
|
||||||
filter.AddIP(netlink.ConntrackNatAnyIP, ipAddress)
|
if err := filter.AddIP(netlink.ConntrackNatAnyIP, ipAddress); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
return nlh.ConntrackDeleteFilter(netlink.ConntrackTable, family, filter)
|
return nlh.ConntrackDeleteFilter(netlink.ConntrackTable, family, filter)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/docker/docker/libnetwork/testutils"
|
_ "github.com/docker/docker/libnetwork/testutils"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
const chainName = "DOCKEREST"
|
const chainName = "DOCKEREST"
|
||||||
|
@ -194,8 +194,6 @@ func TestConcurrencyNoWait(t *testing.T) {
|
||||||
// Note that if iptables does not support the xtable lock on this
|
// Note that if iptables does not support the xtable lock on this
|
||||||
// system, then allowXlock has no effect -- it will always be off.
|
// system, then allowXlock has no effect -- it will always be off.
|
||||||
func RunConcurrencyTest(t *testing.T, allowXlock bool) {
|
func RunConcurrencyTest(t *testing.T, allowXlock bool) {
|
||||||
var wg sync.WaitGroup
|
|
||||||
|
|
||||||
if !allowXlock && supportsXlock {
|
if !allowXlock && supportsXlock {
|
||||||
supportsXlock = false
|
supportsXlock = false
|
||||||
defer func() { supportsXlock = true }()
|
defer func() { supportsXlock = true }()
|
||||||
|
@ -207,17 +205,15 @@ func RunConcurrencyTest(t *testing.T, allowXlock bool) {
|
||||||
dstPort := 4321
|
dstPort := 4321
|
||||||
proto := "tcp"
|
proto := "tcp"
|
||||||
|
|
||||||
|
group := new(errgroup.Group)
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
wg.Add(1)
|
group.Go(func() error {
|
||||||
go func() {
|
return natChain.Forward(Append, ip, port, proto, dstAddr, dstPort, "lo")
|
||||||
defer wg.Done()
|
})
|
||||||
err := natChain.Forward(Append, ip, port, proto, dstAddr, dstPort, "lo")
|
}
|
||||||
if err != nil {
|
if err := group.Wait(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
wg.Wait()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCleanup(t *testing.T) {
|
func TestCleanup(t *testing.T) {
|
||||||
|
|
|
@ -156,7 +156,7 @@ func TestNetworkMarshalling(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func printIpamConf(list []*IpamConf) string {
|
func printIpamConf(list []*IpamConf) string {
|
||||||
s := fmt.Sprintf("\n[]*IpamConfig{")
|
s := "\n[]*IpamConfig{"
|
||||||
for _, i := range list {
|
for _, i := range list {
|
||||||
s = fmt.Sprintf("%s %v,", s, i)
|
s = fmt.Sprintf("%s %v,", s, i)
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ func printIpamConf(list []*IpamConf) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func printIpamInfo(list []*IpamInfo) string {
|
func printIpamInfo(list []*IpamInfo) string {
|
||||||
s := fmt.Sprintf("\n[]*IpamInfo{")
|
s := "\n[]*IpamInfo{"
|
||||||
for _, i := range list {
|
for _, i := range list {
|
||||||
s = fmt.Sprintf("%s\n{\n%s\n}", s, i)
|
s = fmt.Sprintf("%s\n{\n%s\n}", s, i)
|
||||||
}
|
}
|
||||||
|
@ -586,7 +586,9 @@ func TestIpamReleaseOnNetDriverFailures(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
gnw.Delete()
|
if err := gnw.Delete(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Now check whether ipam release works on endpoint creation failure
|
// Now check whether ipam release works on endpoint creation failure
|
||||||
bd.failNetworkCreation = false
|
bd.failNetworkCreation = false
|
||||||
|
@ -594,7 +596,11 @@ func TestIpamReleaseOnNetDriverFailures(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer bnw.Delete()
|
defer func() {
|
||||||
|
if err := bnw.Delete(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if _, err := bnw.CreateEndpoint("ep0"); err == nil {
|
if _, err := bnw.CreateEndpoint("ep0"); err == nil {
|
||||||
t.Fatalf("bad network driver should have failed endpoint creation")
|
t.Fatalf("bad network driver should have failed endpoint creation")
|
||||||
|
@ -606,13 +612,17 @@ func TestIpamReleaseOnNetDriverFailures(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer gnw.Delete()
|
defer func() {
|
||||||
|
if err := gnw.Delete(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
ep, err := gnw.CreateEndpoint("ep1")
|
ep, err := gnw.CreateEndpoint("ep1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer ep.Delete(false)
|
defer ep.Delete(false) // nolint:errcheck
|
||||||
|
|
||||||
expectedIP, _ := types.ParseCIDR("10.35.0.1/16")
|
expectedIP, _ := types.ParseCIDR("10.35.0.1/16")
|
||||||
if !types.CompareIPNet(ep.Info().Iface().Address(), expectedIP) {
|
if !types.CompareIPNet(ep.Info().Iface().Address(), expectedIP) {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/reexec"
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
"github.com/docker/docker/libnetwork/ipamapi"
|
"github.com/docker/docker/libnetwork/ipamapi"
|
||||||
"github.com/docker/docker/libnetwork/netlabel"
|
"github.com/docker/docker/libnetwork/netlabel"
|
||||||
|
@ -22,6 +21,7 @@ import (
|
||||||
"github.com/docker/docker/libnetwork/osl"
|
"github.com/docker/docker/libnetwork/osl"
|
||||||
"github.com/docker/docker/libnetwork/testutils"
|
"github.com/docker/docker/libnetwork/testutils"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/reexec"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
"github.com/vishvananda/netns"
|
"github.com/vishvananda/netns"
|
||||||
|
@ -920,7 +920,17 @@ func runParallelTests(t *testing.T, thrNumber int) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer netns.Set(origins)
|
defer func() {
|
||||||
|
if err := netns.Set(origins); err != nil {
|
||||||
|
// NOTE(@cpuguy83): This...
|
||||||
|
// I touched this code because the linter found that we weren't checking the error...
|
||||||
|
// It returns an error because "origins" is a closed file handle *unless* createGlobalInstance is called.
|
||||||
|
// Which... this test is run in parallel and `createGlobalInstance` modifies `origins` without synchronization.
|
||||||
|
// I'm not sure what exactly the *intent* of this code was, but it looks very broken.
|
||||||
|
// Anyway that's why I'm only logging the error and not failing the test.
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
net1, err := controller.NetworkByName("testhost")
|
net1, err := controller.NetworkByName("testhost")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/libnetwork"
|
"github.com/docker/docker/libnetwork"
|
||||||
|
@ -372,7 +371,7 @@ func TestNetworkConfig(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify config network cannot inherit another config network
|
// Verify config network cannot inherit another config network
|
||||||
configNetwork, err := controller.NewNetwork("bridge", "config_network0", "",
|
_, err := controller.NewNetwork("bridge", "config_network0", "",
|
||||||
libnetwork.NetworkOptionConfigOnly(),
|
libnetwork.NetworkOptionConfigOnly(),
|
||||||
libnetwork.NetworkOptionConfigFrom("anotherConfigNw"))
|
libnetwork.NetworkOptionConfigFrom("anotherConfigNw"))
|
||||||
|
|
||||||
|
@ -400,7 +399,7 @@ func TestNetworkConfig(t *testing.T) {
|
||||||
libnetwork.NetworkOptionIpam("default", "", ipamV4ConfList, ipamV6ConfList, nil),
|
libnetwork.NetworkOptionIpam("default", "", ipamV4ConfList, ipamV6ConfList, nil),
|
||||||
}
|
}
|
||||||
|
|
||||||
configNetwork, err = controller.NewNetwork(bridgeNetType, "config_network0", "", netOptions...)
|
configNetwork, err := controller.NewNetwork(bridgeNetType, "config_network0", "", netOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -873,7 +872,7 @@ func TestNetworkQuery(t *testing.T) {
|
||||||
t.Fatalf("EndpointByName() returned %v instead of %v", e, ep11)
|
t.Fatalf("EndpointByName() returned %v instead of %v", e, ep11)
|
||||||
}
|
}
|
||||||
|
|
||||||
e, err = net1.EndpointByName("")
|
_, err = net1.EndpointByName("")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("EndpointByName() succeeded with invalid target name")
|
t.Fatalf("EndpointByName() succeeded with invalid target name")
|
||||||
}
|
}
|
||||||
|
@ -900,7 +899,7 @@ func TestNetworkQuery(t *testing.T) {
|
||||||
t.Fatalf("EndpointByID() returned %v instead of %v", e, ep12)
|
t.Fatalf("EndpointByID() returned %v instead of %v", e, ep12)
|
||||||
}
|
}
|
||||||
|
|
||||||
e, err = net1.EndpointByID("")
|
_, err = net1.EndpointByID("")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("EndpointByID() succeeded with invalid target id")
|
t.Fatalf("EndpointByID() succeeded with invalid target id")
|
||||||
}
|
}
|
||||||
|
@ -1322,10 +1321,6 @@ func TestInvalidRemoteDriver(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
type pluginRequest struct {
|
|
||||||
name string
|
|
||||||
}
|
|
||||||
|
|
||||||
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
||||||
fmt.Fprintln(w, `{"Implements": ["InvalidDriver"]}`)
|
fmt.Fprintln(w, `{"Implements": ["InvalidDriver"]}`)
|
||||||
|
@ -1369,10 +1364,6 @@ func TestValidRemoteDriver(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
type pluginRequest struct {
|
|
||||||
name string
|
|
||||||
}
|
|
||||||
|
|
||||||
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
|
||||||
fmt.Fprintf(w, `{"Implements": ["%s"]}`, driverapi.NetworkPluginEndpointType)
|
fmt.Fprintf(w, `{"Implements": ["%s"]}`, driverapi.NetworkPluginEndpointType)
|
||||||
|
@ -1420,7 +1411,6 @@ func TestValidRemoteDriver(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
once sync.Once
|
|
||||||
start = make(chan struct{})
|
start = make(chan struct{})
|
||||||
done = make(chan chan struct{}, numThreads-1)
|
done = make(chan chan struct{}, numThreads-1)
|
||||||
origins = netns.None()
|
origins = netns.None()
|
||||||
|
@ -1495,10 +1485,8 @@ func createGlobalInstance(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func debugf(format string, a ...interface{}) (int, error) {
|
func debugf(format string, a ...interface{}) {
|
||||||
if debug {
|
if debug {
|
||||||
return fmt.Printf(format, a...)
|
fmt.Printf(format, a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0, nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
|
||||||
"github.com/docker/docker/libnetwork/config"
|
"github.com/docker/docker/libnetwork/config"
|
||||||
"github.com/docker/docker/libnetwork/datastore"
|
"github.com/docker/docker/libnetwork/datastore"
|
||||||
"github.com/docker/docker/libnetwork/driverapi"
|
"github.com/docker/docker/libnetwork/driverapi"
|
||||||
|
@ -20,6 +19,7 @@ import (
|
||||||
"github.com/docker/docker/libnetwork/networkdb"
|
"github.com/docker/docker/libnetwork/networkdb"
|
||||||
"github.com/docker/docker/libnetwork/options"
|
"github.com/docker/docker/libnetwork/options"
|
||||||
"github.com/docker/docker/libnetwork/types"
|
"github.com/docker/docker/libnetwork/types"
|
||||||
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -220,7 +220,6 @@ type network struct {
|
||||||
dbIndex uint64
|
dbIndex uint64
|
||||||
dbExists bool
|
dbExists bool
|
||||||
persist bool
|
persist bool
|
||||||
stopWatchCh chan struct{}
|
|
||||||
drvOnce *sync.Once
|
drvOnce *sync.Once
|
||||||
resolverOnce sync.Once
|
resolverOnce sync.Once
|
||||||
resolver []Resolver
|
resolver []Resolver
|
||||||
|
@ -499,25 +498,33 @@ func (n *network) CopyTo(o datastore.KVObject) error {
|
||||||
|
|
||||||
for _, v4conf := range n.ipamV4Config {
|
for _, v4conf := range n.ipamV4Config {
|
||||||
dstV4Conf := &IpamConf{}
|
dstV4Conf := &IpamConf{}
|
||||||
v4conf.CopyTo(dstV4Conf)
|
if err := v4conf.CopyTo(dstV4Conf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
dstN.ipamV4Config = append(dstN.ipamV4Config, dstV4Conf)
|
dstN.ipamV4Config = append(dstN.ipamV4Config, dstV4Conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v4info := range n.ipamV4Info {
|
for _, v4info := range n.ipamV4Info {
|
||||||
dstV4Info := &IpamInfo{}
|
dstV4Info := &IpamInfo{}
|
||||||
v4info.CopyTo(dstV4Info)
|
if err := v4info.CopyTo(dstV4Info); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
dstN.ipamV4Info = append(dstN.ipamV4Info, dstV4Info)
|
dstN.ipamV4Info = append(dstN.ipamV4Info, dstV4Info)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v6conf := range n.ipamV6Config {
|
for _, v6conf := range n.ipamV6Config {
|
||||||
dstV6Conf := &IpamConf{}
|
dstV6Conf := &IpamConf{}
|
||||||
v6conf.CopyTo(dstV6Conf)
|
if err := v6conf.CopyTo(dstV6Conf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
dstN.ipamV6Config = append(dstN.ipamV6Config, dstV6Conf)
|
dstN.ipamV6Config = append(dstN.ipamV6Config, dstV6Conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v6info := range n.ipamV6Info {
|
for _, v6info := range n.ipamV6Info {
|
||||||
dstV6Info := &IpamInfo{}
|
dstV6Info := &IpamInfo{}
|
||||||
v6info.CopyTo(dstV6Info)
|
if err := v6info.CopyTo(dstV6Info); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
dstN.ipamV6Info = append(dstN.ipamV6Info, dstV6Info)
|
dstN.ipamV6Info = append(dstN.ipamV6Info, dstV6Info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -933,16 +940,6 @@ func (n *network) resolveDriver(name string, load bool) (driverapi.Driver, *driv
|
||||||
return d, cap, nil
|
return d, cap, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) driverScope() string {
|
|
||||||
_, cap, err := n.resolveDriver(n.networkType, true)
|
|
||||||
if err != nil {
|
|
||||||
// If driver could not be resolved simply return an empty string
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return cap.DataScope
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *network) driverIsMultihost() bool {
|
func (n *network) driverIsMultihost() bool {
|
||||||
_, cap, err := n.resolveDriver(n.networkType, true)
|
_, cap, err := n.resolveDriver(n.networkType, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -995,7 +992,7 @@ func (n *network) delete(force bool, rmLBEndpoint bool) error {
|
||||||
n.Unlock()
|
n.Unlock()
|
||||||
|
|
||||||
c.networkLocker.Lock(id)
|
c.networkLocker.Lock(id)
|
||||||
defer c.networkLocker.Unlock(id)
|
defer c.networkLocker.Unlock(id) // nolint:errcheck
|
||||||
|
|
||||||
n, err := c.getNetworkFromStore(id)
|
n, err := c.getNetworkFromStore(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1163,7 +1160,7 @@ func (n *network) CreateEndpoint(name string, options ...EndpointOption) (Endpoi
|
||||||
}
|
}
|
||||||
|
|
||||||
n.ctrlr.networkLocker.Lock(n.id)
|
n.ctrlr.networkLocker.Lock(n.id)
|
||||||
defer n.ctrlr.networkLocker.Unlock(n.id)
|
defer n.ctrlr.networkLocker.Unlock(n.id) // nolint:errcheck
|
||||||
|
|
||||||
return n.createEndpoint(name, options...)
|
return n.createEndpoint(name, options...)
|
||||||
|
|
||||||
|
@ -1832,13 +1829,17 @@ func (n *network) IpamConfig() (string, map[string]string, []*IpamConf, []*IpamC
|
||||||
|
|
||||||
for i, c := range n.ipamV4Config {
|
for i, c := range n.ipamV4Config {
|
||||||
cc := &IpamConf{}
|
cc := &IpamConf{}
|
||||||
c.CopyTo(cc)
|
if err := c.CopyTo(cc); err != nil {
|
||||||
|
logrus.WithError(err).Error("Error copying ipam ipv4 config")
|
||||||
|
}
|
||||||
v4L[i] = cc
|
v4L[i] = cc
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, c := range n.ipamV6Config {
|
for i, c := range n.ipamV6Config {
|
||||||
cc := &IpamConf{}
|
cc := &IpamConf{}
|
||||||
c.CopyTo(cc)
|
if err := c.CopyTo(cc); err != nil {
|
||||||
|
logrus.WithError(err).Debug("Error copying ipam ipv6 config")
|
||||||
|
}
|
||||||
v6L[i] = cc
|
v6L[i] = cc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1854,13 +1855,17 @@ func (n *network) IpamInfo() ([]*IpamInfo, []*IpamInfo) {
|
||||||
|
|
||||||
for i, info := range n.ipamV4Info {
|
for i, info := range n.ipamV4Info {
|
||||||
ic := &IpamInfo{}
|
ic := &IpamInfo{}
|
||||||
info.CopyTo(ic)
|
if err := info.CopyTo(ic); err != nil {
|
||||||
|
logrus.WithError(err).Error("Error copying ipv4 ipam config")
|
||||||
|
}
|
||||||
v4Info[i] = ic
|
v4Info[i] = ic
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, info := range n.ipamV6Info {
|
for i, info := range n.ipamV6Info {
|
||||||
ic := &IpamInfo{}
|
ic := &IpamInfo{}
|
||||||
info.CopyTo(ic)
|
if err := info.CopyTo(ic); err != nil {
|
||||||
|
logrus.WithError(err).Error("Error copying ipv6 ipam config")
|
||||||
|
}
|
||||||
v6Info[i] = ic
|
v6Info[i] = ic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue