Fixup libnetwork lint errors
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
b53b85ca40
commit
4b981436fe
132 changed files with 832 additions and 944 deletions
|
@ -17,10 +17,10 @@ import (
|
|||
"github.com/docker/docker/builder"
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/daemon/images"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/streamformatter"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
controlapi "github.com/moby/buildkit/api/services/control"
|
||||
"github.com/moby/buildkit/client"
|
||||
"github.com/moby/buildkit/control"
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/moby/buildkit/executor"
|
||||
"github.com/moby/buildkit/executor/oci"
|
||||
"github.com/moby/buildkit/executor/runcexecutor"
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"errors"
|
||||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/moby/buildkit/executor"
|
||||
"github.com/moby/buildkit/executor/oci"
|
||||
)
|
||||
|
|
|
@ -16,8 +16,8 @@ import (
|
|||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/libcontainerd/supervisor"
|
||||
"github.com/docker/docker/pkg/homedir"
|
||||
"github.com/docker/docker/libnetwork/portallocator"
|
||||
"github.com/docker/docker/pkg/homedir"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
|
|
|
@ -53,8 +53,8 @@ import (
|
|||
types "github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/daemon/cluster/controllers/plugin"
|
||||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||
"github.com/docker/docker/pkg/signal"
|
||||
lncluster "github.com/docker/docker/libnetwork/cluster"
|
||||
"github.com/docker/docker/pkg/signal"
|
||||
swarmapi "github.com/docker/swarmkit/api"
|
||||
swarmnode "github.com/docker/swarmkit/node"
|
||||
"github.com/pkg/errors"
|
||||
|
|
|
@ -17,11 +17,11 @@ import (
|
|||
containerpkg "github.com/docker/docker/container"
|
||||
clustertypes "github.com/docker/docker/daemon/cluster/provider"
|
||||
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/cluster"
|
||||
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"
|
||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
|
|
@ -20,8 +20,8 @@ import (
|
|||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/daemon/cluster/convert"
|
||||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||
volumeopts "github.com/docker/docker/volume/service/opts"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
volumeopts "github.com/docker/docker/volume/service/opts"
|
||||
"github.com/docker/swarmkit/agent/exec"
|
||||
"github.com/docker/swarmkit/api"
|
||||
"github.com/docker/swarmkit/log"
|
||||
|
|
|
@ -20,9 +20,9 @@ import (
|
|||
"github.com/docker/docker/daemon/cluster/convert"
|
||||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||
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-units"
|
||||
netconst "github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/swarmkit/agent/exec"
|
||||
"github.com/docker/swarmkit/api"
|
||||
"github.com/docker/swarmkit/api/genericresource"
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/events"
|
||||
executorpkg "github.com/docker/docker/daemon/cluster/executor"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/docker/swarmkit/agent/exec"
|
||||
"github.com/docker/swarmkit/api"
|
||||
"github.com/docker/swarmkit/log"
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/docker/daemon/discovery"
|
||||
"github.com/docker/docker/opts"
|
||||
"github.com/docker/docker/libnetwork/ipamutils"
|
||||
"github.com/docker/docker/opts"
|
||||
"github.com/spf13/pflag"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
|
|
|
@ -14,15 +14,15 @@ import (
|
|||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/daemon/network"
|
||||
"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"
|
||||
netconst "github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
"github.com/docker/docker/libnetwork/options"
|
||||
"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"
|
||||
)
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ import (
|
|||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/daemon/links"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/moby/sys/mount"
|
||||
"github.com/opencontainers/selinux/go-selinux/label"
|
||||
"github.com/pkg/errors"
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
|
|
@ -55,6 +55,9 @@ import (
|
|||
"github.com/docker/docker/layer"
|
||||
"github.com/docker/docker/libcontainerd"
|
||||
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/plugingetter"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
|
@ -65,9 +68,6 @@ import (
|
|||
"github.com/docker/docker/registry"
|
||||
"github.com/docker/docker/runconfig"
|
||||
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/pkg/errors"
|
||||
"golang.org/x/sync/semaphore"
|
||||
|
|
|
@ -10,12 +10,12 @@ import (
|
|||
containertypes "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
_ "github.com/docker/docker/pkg/discovery/memory"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/truncindex"
|
||||
volumesservice "github.com/docker/docker/volume/service"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
|
|
|
@ -28,6 +28,13 @@ import (
|
|||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/daemon/initlayer"
|
||||
"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/pkg/containerfs"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
|
@ -36,13 +43,6 @@ import (
|
|||
"github.com/docker/docker/pkg/sysinfo"
|
||||
"github.com/docker/docker/runconfig"
|
||||
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"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/opencontainers/selinux/go-selinux"
|
||||
|
|
|
@ -14,6 +14,12 @@ import (
|
|||
containertypes "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/container"
|
||||
"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/idtools"
|
||||
"github.com/docker/docker/pkg/parsers"
|
||||
|
@ -21,12 +27,6 @@ import (
|
|||
"github.com/docker/docker/pkg/sysinfo"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"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/sirupsen/logrus"
|
||||
"golang.org/x/sys/windows"
|
||||
|
|
|
@ -17,10 +17,6 @@ import (
|
|||
clustertypes "github.com/docker/docker/daemon/cluster/provider"
|
||||
internalnetwork "github.com/docker/docker/daemon/network"
|
||||
"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"
|
||||
lncluster "github.com/docker/docker/libnetwork/cluster"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
|
@ -29,6 +25,10 @@ import (
|
|||
"github.com/docker/docker/libnetwork/networkdb"
|
||||
"github.com/docker/docker/libnetwork/options"
|
||||
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/sirupsen/logrus"
|
||||
)
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/daemon/network"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/pkg/containerfs"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/skip"
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
"github.com/docker/docker/api/types/filters"
|
||||
timetypes "github.com/docker/docker/api/types/time"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
|
|
@ -9,10 +9,10 @@ import (
|
|||
|
||||
"github.com/docker/docker/daemon/config"
|
||||
"github.com/docker/docker/daemon/images"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/pkg/discovery"
|
||||
_ "github.com/docker/docker/pkg/discovery/memory"
|
||||
"github.com/docker/docker/registry"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/sirupsen/logrus"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
|
|
|
@ -11,4 +11,4 @@ install_binary() {
|
|||
echo "Install is only supported on linux"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,4 +8,4 @@ source "${MAKEDIR}/.install"
|
|||
(
|
||||
DEST="$(dirname $DEST)/binary-proxy"
|
||||
install_binary "${DEST}/docker-proxy"
|
||||
)
|
||||
)
|
||||
|
|
|
@ -18,8 +18,8 @@ TESTDIRS="${TESTDIRS:-./...}"
|
|||
exclude_paths='/vendor/|/integration'
|
||||
pkg_list=$(go list $TESTDIRS | grep -vE "($exclude_paths)")
|
||||
|
||||
echo "${pkg_list}" | grep --fixed-strings "libnetwork/drivers/bridge" && \
|
||||
if ! type docker-proxy; then
|
||||
echo "${pkg_list}" | grep --fixed-strings "libnetwork/drivers/bridge" \
|
||||
&& if ! type docker-proxy; then
|
||||
hack/make.sh binary-proxy install-proxy
|
||||
fi
|
||||
|
||||
|
@ -30,4 +30,4 @@ gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report.json --junit
|
|||
-coverprofile=bundles/profile.out \
|
||||
-covermode=atomic \
|
||||
${TESTFLAGS} \
|
||||
${pkg_list}
|
||||
${pkg_list}
|
||||
|
|
|
@ -25,6 +25,8 @@ linters:
|
|||
skip-dirs:
|
||||
- bundles
|
||||
- docs
|
||||
# TODO: This package should be completely removed
|
||||
- libnetwork/client/mflag
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
|
@ -59,6 +61,11 @@ issues:
|
|||
- text: "G304: Potential file inclusion via variable"
|
||||
linters:
|
||||
- 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.
|
||||
- path: _test\.go
|
||||
|
@ -86,3 +93,16 @@ issues:
|
|||
- text: "SA1019: httputil.ErrPersistEOF is deprecated"
|
||||
linters:
|
||||
- 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"
|
||||
# NOTE: `git grep '^#!'` may also pick up non-shell script files.
|
||||
# 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
|
||||
echo 'Congratulations! The shell scripts are properly formatted.'
|
||||
else
|
||||
|
|
|
@ -31,10 +31,10 @@ import (
|
|||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
"github.com/docker/docker/libnetwork/iptables"
|
||||
"github.com/docker/docker/opts"
|
||||
testdaemon "github.com/docker/docker/testutil/daemon"
|
||||
units "github.com/docker/go-units"
|
||||
"github.com/docker/docker/libnetwork/iptables"
|
||||
"github.com/docker/libtrust"
|
||||
"github.com/moby/sys/mount"
|
||||
"golang.org/x/sys/unix"
|
||||
|
|
|
@ -18,14 +18,14 @@ import (
|
|||
"github.com/docker/docker/api/types/versions/v1p20"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"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"
|
||||
remoteapi "github.com/docker/docker/libnetwork/drivers/remote/api"
|
||||
"github.com/docker/docker/libnetwork/ipamapi"
|
||||
remoteipam "github.com/docker/docker/libnetwork/ipams/remote/api"
|
||||
"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"
|
||||
"golang.org/x/sys/unix"
|
||||
"gotest.tools/v3/assert"
|
||||
|
|
|
@ -27,13 +27,13 @@ import (
|
|||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"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/runconfig"
|
||||
"github.com/docker/docker/testutil"
|
||||
"github.com/docker/docker/testutil/fakecontext"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/docker/docker/libnetwork/resolvconf"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/moby/sys/mountinfo"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/icmd"
|
||||
|
|
|
@ -569,7 +569,7 @@ func (c *client) CreateCheckpoint(ctx context.Context, containerID, checkpointDi
|
|||
var cpDesc *v1.Descriptor
|
||||
for _, m := range index.Manifests {
|
||||
if m.MediaType == images.MediaTypeContainerd1Checkpoint {
|
||||
cpDesc = &m
|
||||
cpDesc = &m // nolint:gosec
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,13 @@ import (
|
|||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/docker/go-events"
|
||||
"github.com/docker/docker/libnetwork/cluster"
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/networkdb"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/go-events"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -793,7 +793,7 @@ func (n *network) addDriverWatches() {
|
|||
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
|
||||
// called at initialization time so there is no state to delete
|
||||
if nid == n.ID() && !deleted {
|
||||
|
@ -801,6 +801,9 @@ func (n *network) addDriverWatches() {
|
|||
}
|
||||
return false
|
||||
})
|
||||
if err != nil {
|
||||
logrus.WithError(err).Warn("Error while walking networkdb")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
var (
|
||||
successResponse = responseStatus{Status: "Success", StatusCode: http.StatusOK}
|
||||
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}
|
||||
)
|
||||
|
||||
|
@ -29,11 +28,9 @@ const (
|
|||
regex = "[a-zA-Z_0-9-]+"
|
||||
qregx = "$|" + regex
|
||||
// Router URL variable definition
|
||||
nwName = "{" + urlNwName + ":" + regex + "}"
|
||||
nwNameQr = "{" + urlNwName + ":" + qregx + "}"
|
||||
nwID = "{" + urlNwID + ":" + regex + "}"
|
||||
nwPIDQr = "{" + urlNwPID + ":" + qregx + "}"
|
||||
epName = "{" + urlEpName + ":" + regex + "}"
|
||||
epNameQr = "{" + urlEpName + ":" + qregx + "}"
|
||||
epID = "{" + urlEpID + ":" + regex + "}"
|
||||
epPIDQr = "{" + urlEpPID + ":" + qregx + "}"
|
||||
|
@ -260,11 +257,6 @@ func (sc *sandboxCreate) parseOptions() []libnetwork.SandboxOption {
|
|||
return setFctList
|
||||
}
|
||||
|
||||
func (ej *endpointJoin) parseOptions() []libnetwork.EndpointOption {
|
||||
// priority will go here
|
||||
return []libnetwork.EndpointOption{}
|
||||
}
|
||||
|
||||
/******************
|
||||
Process functions
|
||||
*******************/
|
||||
|
|
|
@ -24,7 +24,6 @@ import (
|
|||
|
||||
const (
|
||||
bridgeNetType = "bridge"
|
||||
bridgeName = "docker0"
|
||||
)
|
||||
|
||||
func i2s(i interface{}) string {
|
||||
|
@ -1664,7 +1663,7 @@ func newWriter() *localResponseWriter {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -144,11 +144,7 @@ func (s *sequence) equal(o *sequence) bool {
|
|||
this = this.next
|
||||
other = other.next
|
||||
}
|
||||
// Check if other is longer than this
|
||||
if other != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return other == nil
|
||||
}
|
||||
|
||||
// ToByteArray converts the sequence into a byte array
|
||||
|
@ -699,7 +695,6 @@ func removeCurrentIfEmpty(head **sequence, previous, current *sequence) {
|
|||
*head = current.next
|
||||
} else {
|
||||
previous.next = current.next
|
||||
current = current.next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -849,7 +849,7 @@ func TestSetAnyInRange(t *testing.T) {
|
|||
|
||||
func TestMethods(t *testing.T) {
|
||||
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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package bitseq
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
|
@ -106,17 +105,6 @@ func (h *Handle) DataScope() string {
|
|||
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 {
|
||||
h.Lock()
|
||||
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) String() string { return fmt.Sprintf("%s", *s) }
|
||||
func (s *stringValue) String() string { return string(*s) }
|
||||
|
||||
// -- float64 Value
|
||||
type float64Value float64
|
||||
|
|
|
@ -97,9 +97,7 @@ func TestEverything(t *testing.T) {
|
|||
// Now test they're visited in sort order.
|
||||
var flagNames []string
|
||||
Visit(func(f *Flag) {
|
||||
for _, name := range f.Names {
|
||||
flagNames = append(flagNames, name)
|
||||
}
|
||||
flagNames = append(flagNames, f.Names...)
|
||||
})
|
||||
if !sort.StringsAreSorted(flagNames) {
|
||||
t.Errorf("flag names not sorted: %v", flagNames)
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
flag "github.com/docker/docker/libnetwork/client/mflag"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
)
|
||||
|
||||
type command struct {
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
flag "github.com/docker/docker/libnetwork/client/mflag"
|
||||
"github.com/docker/docker/libnetwork/netutils"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -86,11 +86,3 @@ type extraHost struct {
|
|||
Name string `json:"name"`
|
||||
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)
|
||||
}
|
||||
|
||||
resp, err := http.Get(path)
|
||||
resp, err := http.Get(path) // nolint:gosec
|
||||
if err != nil {
|
||||
logrus.WithError(err).Fatalf("Failed fetching path")
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ import (
|
|||
|
||||
"github.com/BurntSushi/toml"
|
||||
"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/api"
|
||||
"github.com/docker/docker/libnetwork/cluster"
|
||||
|
@ -33,6 +31,8 @@ import (
|
|||
"github.com/docker/docker/libnetwork/netutils"
|
||||
"github.com/docker/docker/libnetwork/options"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/discovery"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/moby/term"
|
||||
"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 = "0.0.0.0"
|
||||
// DefaultHTTPPort is the default http port used by dnet
|
||||
DefaultHTTPPort = 2385
|
||||
// DefaultUnixSocket exported
|
||||
DefaultUnixSocket = "/var/run/dnet.sock"
|
||||
cfgFileEnv = "LIBNETWORK_CFG"
|
||||
defaultCfgFile = "/etc/default/libnetwork.toml"
|
||||
defaultHeartbeat = time.Duration(10) * time.Second
|
||||
ttlFactor = 2
|
||||
DefaultHTTPPort = 2385
|
||||
cfgFileEnv = "LIBNETWORK_CFG"
|
||||
defaultCfgFile = "/etc/default/libnetwork.toml"
|
||||
defaultHeartbeat = time.Duration(10) * time.Second
|
||||
ttlFactor = 2
|
||||
)
|
||||
|
||||
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)}
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-time.After(hb):
|
||||
if err := d.Register(cfg.Address + ":0"); err != nil {
|
||||
logrus.Warn(err)
|
||||
}
|
||||
time.Sleep(hb)
|
||||
if err := d.Register(cfg.Address + ":0"); err != nil {
|
||||
logrus.Warn(err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
@ -507,7 +503,7 @@ func (d *dnetConnection) httpCall(method, path string, data interface{}, headers
|
|||
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 {
|
||||
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")
|
||||
}
|
||||
|
||||
if headers != nil {
|
||||
for k, v := range headers {
|
||||
req.Header[k] = v
|
||||
}
|
||||
for k, v := range headers {
|
||||
req.Header[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,19 +118,6 @@ func dbTableEntriesNumber(ip, port, networkName, tableName string, doneCh chan r
|
|||
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) {
|
||||
body, err := httpGet(ip, port, "/networkstats?nid="+networkName)
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
|
||||
events "github.com/docker/go-events"
|
||||
"github.com/docker/docker/libnetwork/diagnostic"
|
||||
"github.com/docker/docker/libnetwork/networkdb"
|
||||
events "github.com/docker/go-events"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -29,11 +29,11 @@ type tableHandler struct {
|
|||
var clientWatchTable = map[string]tableHandler{}
|
||||
|
||||
func watchTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
r.ParseForm() // nolint:errcheck
|
||||
diagnostic.DebugHTTPForm(r)
|
||||
if len(r.Form["tname"]) < 1 {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -54,11 +54,11 @@ func watchTable(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)
|
||||
if len(r.Form["tname"]) < 1 {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ import (
|
|||
"os"
|
||||
"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/drivers/overlay"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
|
@ -161,14 +161,13 @@ func main() {
|
|||
}
|
||||
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
signal.Notify(sigCh, os.Interrupt, os.Kill)
|
||||
signal.Notify(sigCh, os.Interrupt)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-sigCh:
|
||||
r.d.Leave("testnetwork", "testep")
|
||||
overlay.Fini(r.d)
|
||||
os.Exit(0)
|
||||
for range sigCh {
|
||||
if err := r.d.Leave("testnetwork", "testep"); err != nil {
|
||||
fmt.Printf("Error leaving: %v", err)
|
||||
}
|
||||
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"
|
||||
"log"
|
||||
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/libnetwork/config"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
"github.com/docker/docker/libnetwork/options"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -5,16 +5,16 @@ import (
|
|||
"strings"
|
||||
|
||||
"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/datastore"
|
||||
"github.com/docker/docker/libnetwork/ipamutils"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
"github.com/docker/docker/libnetwork/osl"
|
||||
"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"
|
||||
)
|
||||
|
||||
|
|
|
@ -52,10 +52,6 @@ import (
|
|||
"sync"
|
||||
"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/config"
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
|
@ -69,6 +65,10 @@ import (
|
|||
"github.com/docker/docker/libnetwork/options"
|
||||
"github.com/docker/docker/libnetwork/osl"
|
||||
"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/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -156,28 +156,27 @@ type SandboxWalker func(sb Sandbox) bool
|
|||
type sandboxTable map[string]*sandbox
|
||||
|
||||
type controller struct {
|
||||
id string
|
||||
drvRegistry *drvregistry.DrvRegistry
|
||||
sandboxes sandboxTable
|
||||
cfg *config.Config
|
||||
stores []datastore.DataStore
|
||||
discovery hostdiscovery.HostDiscovery
|
||||
extKeyListener net.Listener
|
||||
watchCh chan *endpoint
|
||||
unWatchCh chan *endpoint
|
||||
svcRecords map[string]svcInfo
|
||||
nmap map[string]*netWatch
|
||||
serviceBindings map[serviceKey]*service
|
||||
defOsSbox osl.Sandbox
|
||||
ingressSandbox *sandbox
|
||||
sboxOnce sync.Once
|
||||
agent *agent
|
||||
networkLocker *locker.Locker
|
||||
agentInitDone chan struct{}
|
||||
agentStopDone chan struct{}
|
||||
keys []*types.EncryptionKey
|
||||
clusterConfigAvailable bool
|
||||
DiagnosticServer *diagnostic.Server
|
||||
id string
|
||||
drvRegistry *drvregistry.DrvRegistry
|
||||
sandboxes sandboxTable
|
||||
cfg *config.Config
|
||||
stores []datastore.DataStore
|
||||
discovery hostdiscovery.HostDiscovery
|
||||
extKeyListener net.Listener
|
||||
watchCh chan *endpoint
|
||||
unWatchCh chan *endpoint
|
||||
svcRecords map[string]svcInfo
|
||||
nmap map[string]*netWatch
|
||||
serviceBindings map[serviceKey]*service
|
||||
defOsSbox osl.Sandbox
|
||||
ingressSandbox *sandbox
|
||||
sboxOnce sync.Once
|
||||
agent *agent
|
||||
networkLocker *locker.Locker
|
||||
agentInitDone chan struct{}
|
||||
agentStopDone chan struct{}
|
||||
keys []*types.EncryptionKey
|
||||
DiagnosticServer *diagnostic.Server
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
|
@ -278,10 +277,6 @@ func (c *controller) SetClusterProvider(provider cluster.Provider) {
|
|||
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
|
||||
// keys setup the agent. For subsequent key set handle the key change
|
||||
func (c *controller) SetKeys(keys []*types.EncryptionKey) error {
|
||||
|
@ -559,13 +554,6 @@ func (c *controller) BuiltinIPAMDrivers() []string {
|
|||
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 {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
@ -576,21 +564,6 @@ func (c *controller) clusterHostID() string {
|
|||
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 {
|
||||
if c.cfg == nil {
|
||||
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 != "" {
|
||||
c.networkLocker.Lock(id)
|
||||
defer c.networkLocker.Unlock(id)
|
||||
defer c.networkLocker.Unlock(id) // nolint:errcheck
|
||||
|
||||
if _, err = c.NetworkByID(id); err == nil {
|
||||
return nil, NetworkNameError(id)
|
||||
|
@ -827,7 +800,7 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
|
|||
|
||||
err = c.addNetwork(network)
|
||||
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
|
||||
// value to skip a refcount increment for configOnly networks
|
||||
skipCfgEpCount = true
|
||||
|
|
|
@ -8,10 +8,10 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/docker/libkv"
|
||||
"github.com/docker/libkv/store"
|
||||
"github.com/docker/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/libkv"
|
||||
"github.com/docker/libkv/store"
|
||||
)
|
||||
|
||||
//DataStore exported
|
||||
|
|
|
@ -3,8 +3,8 @@ package datastore
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/docker/libkv/store"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/libkv/store"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -125,5 +125,4 @@ func (s *MockStore) AtomicDelete(key string, previous *store.KVPair) (bool, erro
|
|||
|
||||
// Close closes the client connection
|
||||
func (s *MockStore) Close() {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -162,18 +162,6 @@ func (ep *endpoint) endpointInGWNetwork() bool {
|
|||
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.
|
||||
// Parallel executions are serialized.
|
||||
func (c *controller) defaultGwNetwork() (Network, error) {
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
stackdump "github.com/docker/docker/pkg/signal"
|
||||
"github.com/docker/docker/libnetwork/internal/caller"
|
||||
stackdump "github.com/docker/docker/pkg/signal"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -108,7 +108,7 @@ func (s *Server) DisableDiagnostic() {
|
|||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
s.srv.Shutdown(context.Background())
|
||||
s.srv.Shutdown(context.Background()) // nolint:errcheck
|
||||
s.srv = nil
|
||||
s.enable = 0
|
||||
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) {
|
||||
r.ParseForm()
|
||||
r.ParseForm() // nolint:errcheck
|
||||
_, json := ParseHTTPFormOptions(r)
|
||||
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.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) {
|
||||
r.ParseForm()
|
||||
r.ParseForm() // nolint:errcheck
|
||||
_, json := ParseHTTPFormOptions(r)
|
||||
|
||||
// audit logs
|
||||
|
@ -147,22 +147,22 @@ func help(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
|||
for path := range n.registeredHanders {
|
||||
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) {
|
||||
r.ParseForm()
|
||||
r.ParseForm() // nolint:errcheck
|
||||
_, json := ParseHTTPFormOptions(r)
|
||||
|
||||
// audit logs
|
||||
log := logrus.WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
|
||||
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) {
|
||||
r.ParseForm()
|
||||
r.ParseForm() // nolint:errcheck
|
||||
_, json := ParseHTTPFormOptions(r)
|
||||
|
||||
// audit logs
|
||||
|
@ -172,10 +172,10 @@ func stackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) {
|
|||
path, err := stackdump.DumpStacks("/tmp/")
|
||||
if err != nil {
|
||||
log.WithError(err).Error("failed to write goroutines dump")
|
||||
HTTPReply(w, FailCommand(err), json)
|
||||
HTTPReply(w, FailCommand(err), json) // nolint:errcheck
|
||||
} else {
|
||||
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 (
|
||||
"net"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
)
|
||||
|
||||
// NetworkPluginEndpointType represents the Endpoint Type used by Plugin system
|
||||
|
|
|
@ -144,7 +144,6 @@ type bridgeNetwork struct {
|
|||
|
||||
type driver struct {
|
||||
config *configuration
|
||||
network *bridgeNetwork
|
||||
natChain *iptables.ChainInfo
|
||||
filterChain *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
|
||||
iptables.OnReloaded(func() {
|
||||
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
|
||||
iptables.OnReloaded(func() {
|
||||
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
|
||||
}
|
||||
|
||||
if config.BridgeName == "" && config.DefaultBridge == false {
|
||||
if config.BridgeName == "" && !config.DefaultBridge {
|
||||
config.BridgeName = "br-" + id[:12]
|
||||
}
|
||||
|
||||
|
@ -568,18 +571,6 @@ func parseNetworkOptions(id string, option options.Generic) (*networkConfigurati
|
|||
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
|
||||
func (d *driver) getNetworks() []*bridgeNetwork {
|
||||
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
|
||||
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
|
||||
|
|
|
@ -455,16 +455,24 @@ func TestCreateMultipleNetworks(t *testing.T) {
|
|||
|
||||
verifyV4INCEntries(d.networks, t)
|
||||
|
||||
d.DeleteNetwork("1")
|
||||
if err := d.DeleteNetwork("1"); err != nil {
|
||||
t.Log(err)
|
||||
}
|
||||
verifyV4INCEntries(d.networks, t)
|
||||
|
||||
d.DeleteNetwork("2")
|
||||
if err := d.DeleteNetwork("2"); err != nil {
|
||||
t.Log(err)
|
||||
}
|
||||
verifyV4INCEntries(d.networks, t)
|
||||
|
||||
d.DeleteNetwork("3")
|
||||
if err := d.DeleteNetwork("3"); err != nil {
|
||||
t.Log(err)
|
||||
}
|
||||
verifyV4INCEntries(d.networks, t)
|
||||
|
||||
d.DeleteNetwork("4")
|
||||
if err := d.DeleteNetwork("4"); err != nil {
|
||||
t.Log(err)
|
||||
}
|
||||
verifyV4INCEntries(d.networks, t)
|
||||
}
|
||||
|
||||
|
@ -503,12 +511,10 @@ type testInterface struct {
|
|||
}
|
||||
|
||||
type testEndpoint struct {
|
||||
iface *testInterface
|
||||
gw net.IP
|
||||
gw6 net.IP
|
||||
hostsPath string
|
||||
resolvConfPath string
|
||||
routes []types.StaticRoute
|
||||
iface *testInterface
|
||||
gw net.IP
|
||||
gw6 net.IP
|
||||
routes []types.StaticRoute
|
||||
}
|
||||
|
||||
func newTestEndpoint(nw *net.IPNet, ordinal byte) *testEndpoint {
|
||||
|
@ -662,7 +668,7 @@ func testQueryEndpointInfo(t *testing.T, ulPxyEnabled bool) {
|
|||
if !ok {
|
||||
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)
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
out, err := iptable.Raw("-L", DockerChain)
|
||||
out, _ := iptable.Raw("-L", DockerChain)
|
||||
for _, pm := range exposedPorts {
|
||||
regex := fmt.Sprintf("%s dpt:%d", pm.Proto.String(), pm.Port)
|
||||
re := regexp.MustCompile(regex)
|
||||
|
@ -820,7 +826,7 @@ func TestLinkContainers(t *testing.T) {
|
|||
t.Fatal("Failed to unlink ep1 and ep2")
|
||||
}
|
||||
|
||||
out, err = iptable.Raw("-L", DockerChain)
|
||||
out, _ = iptable.Raw("-L", DockerChain)
|
||||
for _, pm := range exposedPorts {
|
||||
regex := fmt.Sprintf("%s dpt:%d", pm.Proto.String(), pm.Port)
|
||||
re := regexp.MustCompile(regex)
|
||||
|
@ -848,7 +854,7 @@ func TestLinkContainers(t *testing.T) {
|
|||
}
|
||||
err = d.ProgramExternalConnectivity("net1", "ep2", sbOptions)
|
||||
if err != nil {
|
||||
out, err = iptable.Raw("-L", DockerChain)
|
||||
out, _ = iptable.Raw("-L", DockerChain)
|
||||
for _, pm := range exposedPorts {
|
||||
regex := fmt.Sprintf("%s dpt:%d", pm.Proto.String(), pm.Port)
|
||||
re := regexp.MustCompile(regex)
|
||||
|
|
|
@ -2,10 +2,8 @@ package bridge
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
|
@ -25,8 +23,6 @@ type ifreqHwaddr struct {
|
|||
IfruHwaddr syscall.RawSockaddr
|
||||
}
|
||||
|
||||
var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
|
||||
// THIS CODE DOES NOT COMMUNICATE WITH KERNEL VIA RTNETLINK INTERFACE
|
||||
// IT IS HERE FOR BACKWARDS COMPATIBILITY WITH OLDER LINUX KERNELS
|
||||
// WHICH SHIP WITH OLDER NOT ENTIRELY FUNCTIONAL VERSION OF NETLINK
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
"github.com/docker/docker/libnetwork/testutils"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
@ -71,7 +71,7 @@ func TestPortMappingConfig(t *testing.T) {
|
|||
if !ok {
|
||||
t.Fatalf("Cannot find network %s inside driver", "dummy")
|
||||
}
|
||||
ep, _ := network.endpoints["ep1"]
|
||||
ep := network.endpoints["ep1"]
|
||||
if len(ep.portMapping) != 3 {
|
||||
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 {
|
||||
t.Fatalf("Cannot find network %s inside driver", "dummy")
|
||||
}
|
||||
ep, _ := network.endpoints["ep1"]
|
||||
ep := network.endpoints["ep1"]
|
||||
if len(ep.portMapping) != 6 {
|
||||
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()
|
||||
mac2 := netutils.GenerateRandomMAC()
|
||||
if bytes.Compare(mac1, mac2) == 0 {
|
||||
if bytes.Equal(mac1, mac2) {
|
||||
t.Fatalf("Generated twice the same MAC address %v", mac1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ func TestSetupIPForwarding(t *testing.T) {
|
|||
defer reconcileIPForwardingSetting(t, procSetting)
|
||||
|
||||
// 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'})
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ func TestSetupIPForwarding(t *testing.T) {
|
|||
|
||||
// Read new setting
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func writeIPForwardingSetting(t *testing.T, chars []byte) {
|
|||
|
||||
func reconcileIPForwardingSetting(t *testing.T, original []byte) {
|
||||
current := readCurrentIPForwardingSetting(t)
|
||||
if bytes.Compare(original, current) != 0 {
|
||||
if !bytes.Equal(original, current) {
|
||||
writeIPForwardingSetting(t, original)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ const (
|
|||
|
||||
func setupIPChains(config *configuration, version iptables.IPVersion) (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
|
||||
// Sanity check.
|
||||
if config.EnableIPTables == false {
|
||||
if !config.EnableIPTables {
|
||||
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)
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
for _, addrv6 := range addrsv6 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) 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.
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/osl"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
)
|
||||
|
||||
|
@ -50,7 +49,6 @@ type endpoint struct {
|
|||
|
||||
type network struct {
|
||||
id string
|
||||
sbox osl.Sandbox
|
||||
endpoints endpointTable
|
||||
driver *driver
|
||||
config *configuration
|
||||
|
@ -66,7 +64,9 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
|||
d := &driver{
|
||||
networks: networkTable{},
|
||||
}
|
||||
d.initStore(config)
|
||||
if err := d.initStore(config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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) {
|
||||
return make(map[string]interface{}, 0), nil
|
||||
return make(map[string]interface{}), nil
|
||||
}
|
||||
|
||||
func (d *driver) Type() string {
|
||||
|
|
|
@ -5,14 +5,14 @@ package ipvlan
|
|||
import (
|
||||
"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/netlabel"
|
||||
"github.com/docker/docker/libnetwork/ns"
|
||||
"github.com/docker/docker/libnetwork/options"
|
||||
"github.com/docker/docker/libnetwork/osl"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/parsers/kernel"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"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
|
||||
func parentExists(ifaceStr string) bool {
|
||||
_, err := ns.NlHandle().LinkByName(ifaceStr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// createVlanLink parses sub-interfaces and vlan id for creation
|
||||
|
|
|
@ -5,7 +5,6 @@ package ipvlan
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/libnetwork/osl"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -89,19 +88,6 @@ func validateID(nid, eid string) error {
|
|||
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) {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
|
|
|
@ -5,9 +5,9 @@ package ipvlan
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
_ "github.com/docker/docker/libnetwork/testutils"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
)
|
||||
|
||||
const testNetworkType = "ipvlan"
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/osl"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
)
|
||||
|
||||
|
@ -52,7 +51,6 @@ type endpoint struct {
|
|||
|
||||
type network struct {
|
||||
id string
|
||||
sbox osl.Sandbox
|
||||
endpoints endpointTable
|
||||
driver *driver
|
||||
config *configuration
|
||||
|
@ -68,7 +66,9 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
|||
d := &driver{
|
||||
networks: networkTable{},
|
||||
}
|
||||
d.initStore(config)
|
||||
if err := d.initStore(config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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) {
|
||||
return make(map[string]interface{}, 0), nil
|
||||
return make(map[string]interface{}), nil
|
||||
}
|
||||
|
||||
func (d *driver) Type() string {
|
||||
|
|
|
@ -5,13 +5,13 @@ package macvlan
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
"github.com/docker/docker/libnetwork/ns"
|
||||
"github.com/docker/docker/libnetwork/options"
|
||||
"github.com/docker/docker/libnetwork/osl"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"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
|
||||
func parentExists(ifaceStr string) bool {
|
||||
_, err := ns.NlHandle().LinkByName(ifaceStr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// createVlanLink parses sub-interfaces and vlan id for creation
|
||||
|
|
|
@ -5,7 +5,6 @@ package macvlan
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/libnetwork/osl"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -88,19 +87,6 @@ func validateID(nid, eid string) error {
|
|||
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) {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
|
|
|
@ -5,9 +5,9 @@ package macvlan
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
_ "github.com/docker/docker/libnetwork/testutils"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
)
|
||||
|
||||
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) {
|
||||
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.
|
||||
|
|
|
@ -629,7 +629,7 @@ func clearEncryptionStates() {
|
|||
}
|
||||
for _, sp := range spList {
|
||||
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)
|
||||
continue
|
||||
}
|
||||
|
@ -638,7 +638,7 @@ func clearEncryptionStates() {
|
|||
}
|
||||
for _, sa := range saList {
|
||||
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)
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ func (d *driver) DeleteEndpoint(nid, eid string) 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 {
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
|
@ -24,6 +23,7 @@ import (
|
|||
"github.com/docker/docker/libnetwork/osl"
|
||||
"github.com/docker/docker/libnetwork/resolvconf"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vishvananda/netlink"
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
|
@ -415,7 +415,9 @@ func (n *network) destroySandbox() {
|
|||
|
||||
func populateVNITbl() {
|
||||
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)
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
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"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/libkv/store/consul"
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
_ "github.com/docker/docker/libnetwork/testutils"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/libkv/store/consul"
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
)
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ type networkTable map[string]*network
|
|||
type driver struct {
|
||||
config map[string]interface{}
|
||||
networks networkTable
|
||||
store datastore.DataStore
|
||||
vxlanIdm *idm.Idm
|
||||
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 {
|
||||
logrus.Warnf("Peer key scan on network %s failed: %v", nid, err)
|
||||
}
|
||||
if f(&pKey, &pEntry) {
|
||||
if f(&pKey, &pEntry) { // nolint:gosec
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/pkg/plugins"
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/drivers/remote/api"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/pkg/plugins"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/ipamapi"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
)
|
||||
|
||||
type driverData struct {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
|
@ -60,7 +59,6 @@ type endpoint struct {
|
|||
anonymous bool
|
||||
disableResolution bool
|
||||
generic map[string]interface{}
|
||||
joinLeaveDone chan struct{}
|
||||
prefAddress net.IP
|
||||
prefAddressV6 net.IP
|
||||
ipamOptions map[string]string
|
||||
|
@ -117,19 +115,25 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) {
|
|||
ep.name = epMap["name"].(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"])
|
||||
json.Unmarshal(ib, &ep.iface)
|
||||
json.Unmarshal(ib, &ep.iface) // nolint:errcheck
|
||||
|
||||
jb, _ := json.Marshal(epMap["joinInfo"])
|
||||
json.Unmarshal(jb, &ep.joinInfo)
|
||||
json.Unmarshal(jb, &ep.joinInfo) // nolint:errcheck
|
||||
|
||||
tb, _ := json.Marshal(epMap["exposed_ports"])
|
||||
var tPorts []types.TransportPort
|
||||
json.Unmarshal(tb, &tPorts)
|
||||
json.Unmarshal(tb, &tPorts) // nolint:errcheck
|
||||
ep.exposedPorts = tPorts
|
||||
|
||||
cb, _ := json.Marshal(epMap["sandbox"])
|
||||
json.Unmarshal(cb, &ep.sandboxID)
|
||||
json.Unmarshal(cb, &ep.sandboxID) // nolint:errcheck
|
||||
|
||||
if v, ok := epMap["generic"]; ok {
|
||||
ep.generic = v.(map[string]interface{})
|
||||
|
@ -208,17 +212,17 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) {
|
|||
|
||||
sal, _ := json.Marshal(epMap["svcAliases"])
|
||||
var svcAliases []string
|
||||
json.Unmarshal(sal, &svcAliases)
|
||||
json.Unmarshal(sal, &svcAliases) // nolint:errcheck
|
||||
ep.svcAliases = svcAliases
|
||||
|
||||
pc, _ := json.Marshal(epMap["ingressPorts"])
|
||||
var ingressPorts []*PortConfig
|
||||
json.Unmarshal(pc, &ingressPorts)
|
||||
json.Unmarshal(pc, &ingressPorts) // nolint:errcheck
|
||||
ep.ingressPorts = ingressPorts
|
||||
|
||||
ma, _ := json.Marshal(epMap["myAliases"])
|
||||
var myAliases []string
|
||||
json.Unmarshal(ma, &myAliases)
|
||||
json.Unmarshal(ma, &myAliases) // nolint:errcheck
|
||||
ep.myAliases = myAliases
|
||||
return nil
|
||||
}
|
||||
|
@ -253,12 +257,16 @@ func (ep *endpoint) CopyTo(o datastore.KVObject) error {
|
|||
|
||||
if ep.iface != nil {
|
||||
dstEp.iface = &endpointInterface{}
|
||||
ep.iface.CopyTo(dstEp.iface)
|
||||
if err := ep.iface.CopyTo(dstEp.iface); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if ep.joinInfo != nil {
|
||||
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))
|
||||
|
@ -354,17 +362,6 @@ func (ep *endpoint) KeyPrefix() []string {
|
|||
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 {
|
||||
b, err := json.Marshal(ep)
|
||||
if err != nil {
|
||||
|
@ -650,10 +647,14 @@ func (ep *endpoint) rename(name string) error {
|
|||
}
|
||||
defer func() {
|
||||
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.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 {
|
||||
|
@ -679,7 +680,7 @@ func (ep *endpoint) rename(name string) error {
|
|||
// benign error. Besides there is no meaningful recovery that
|
||||
// we can do. When the cluster recovers subsequent EpCnt update
|
||||
// will force the peers to get the correct EP name.
|
||||
n.getEpCnt().updateStore()
|
||||
n.getEpCnt().updateStore() // nolint:errcheck
|
||||
|
||||
return err
|
||||
}
|
||||
|
@ -1226,7 +1227,9 @@ func (c *controller) cleanupLocalEndpoints() {
|
|||
epCnt := n.getEpCnt().EndpointCnt()
|
||||
if epCnt != uint64(len(epl)) {
|
||||
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"])
|
||||
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)
|
||||
for _, route := range routes {
|
||||
ip, ipr, err := net.ParseCIDR(route)
|
||||
|
@ -436,11 +439,16 @@ func (epj *endpointJoinInfo) UnmarshalJSON(b []byte) error {
|
|||
if v, ok := epMap["StaticRoutes"]; ok {
|
||||
tb, _ := json.Marshal(v)
|
||||
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
|
||||
for _, r := range tStaticRoute {
|
||||
StaticRoutes = append(StaticRoutes, &r)
|
||||
StaticRoutes = append(StaticRoutes, &r) // nolint:gosec
|
||||
}
|
||||
epj.StaticRoutes = StaticRoutes
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
_ "github.com/docker/docker/libnetwork/testutils"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func TestBuildDefault(t *testing.T) {
|
||||
|
@ -431,12 +431,10 @@ func TestConcurrentWrites(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
group := new(errgroup.Group)
|
||||
for i := 0; i < 10; i++ {
|
||||
wg.Add(1)
|
||||
go func(i int) {
|
||||
defer wg.Done()
|
||||
|
||||
i := i
|
||||
group.Go(func() error {
|
||||
rec := []Record{
|
||||
{
|
||||
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++ {
|
||||
if err := Add(file.Name(), rec); err != nil {
|
||||
t.Fatal(err)
|
||||
return err
|
||||
}
|
||||
|
||||
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())
|
||||
if err != nil {
|
||||
|
|
|
@ -8,12 +8,13 @@ import (
|
|||
|
||||
mapset "github.com/deckarep/golang-set"
|
||||
"github.com/docker/docker/pkg/discovery"
|
||||
|
||||
// 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/etcd"
|
||||
"github.com/docker/libkv/store/zookeeper"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
)
|
||||
|
||||
type hostDiscovery struct {
|
||||
|
|
|
@ -18,9 +18,6 @@ import (
|
|||
const (
|
||||
localAddressSpace = "LocalDefault"
|
||||
globalAddressSpace = "GlobalDefault"
|
||||
// The biggest configurable host subnets
|
||||
minNetSize = 8
|
||||
minNetSizeV6 = 64
|
||||
// datastore keyes for ipam objects
|
||||
dsConfigKey = "ipam/" + ipamapi.DefaultIPAM + "/config"
|
||||
dsDataKey = "ipam/" + ipamapi.DefaultIPAM + "/data"
|
||||
|
@ -103,11 +100,9 @@ func (a *Allocator) updateBitMasks(aSpace *addrSpace) error {
|
|||
aSpace.Unlock()
|
||||
|
||||
// Add the bitmasks (data could come from datastore)
|
||||
if inserterList != nil {
|
||||
for _, f := range inserterList {
|
||||
if err := f(); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, f := range inserterList {
|
||||
if err := f(); err != nil {
|
||||
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)
|
||||
base = types.GetIPNetCopy(nw)
|
||||
|
||||
if bitmask.Unselected() <= 0 {
|
||||
if bitmask.Unselected() == 0 {
|
||||
return nil, ipamapi.ErrNoAvailableIPs
|
||||
}
|
||||
if ipr == nil && prefAddress == nil {
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/libkv/store"
|
||||
"github.com/docker/libkv/store/boltdb"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
@ -307,7 +308,7 @@ func TestAddReleasePoolID(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
|
||||
var k0, k1 SubnetKey
|
||||
aSpace, err := a.getAddrSpace(localAddressSpace)
|
||||
_, err = a.getAddrSpace(localAddressSpace)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -320,7 +321,7 @@ func TestAddReleasePoolID(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
aSpace, err = a.getAddrSpace(localAddressSpace)
|
||||
aSpace, err := a.getAddrSpace(localAddressSpace)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -1070,8 +1071,6 @@ func TestRelease(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
bm := a.addresses[SubnetKey{localAddressSpace, subnet, ""}]
|
||||
|
||||
// Allocate all addresses
|
||||
for err != ipamapi.ErrNoAvailableIPs {
|
||||
_, _, err = a.RequestAddress(pid, nil, nil)
|
||||
|
@ -1108,7 +1107,7 @@ func TestRelease(t *testing.T) {
|
|||
for i, inp := range toRelease {
|
||||
ip0 := net.ParseIP(inp.address)
|
||||
a.ReleaseAddress(pid, ip0)
|
||||
bm = a.addresses[SubnetKey{localAddressSpace, subnet, ""}]
|
||||
bm := a.addresses[SubnetKey{localAddressSpace, subnet, ""}]
|
||||
if bm.Unselected() != 1 {
|
||||
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) {
|
||||
|
||||
subnets := []string{
|
||||
|
@ -1442,10 +1434,7 @@ func runParallelTests(t *testing.T, instance int) {
|
|||
}
|
||||
|
||||
if instance != first {
|
||||
select {
|
||||
case <-start:
|
||||
}
|
||||
|
||||
<-start
|
||||
instDone := make(chan struct{})
|
||||
done <- instDone
|
||||
defer close(instDone)
|
||||
|
@ -1462,9 +1451,7 @@ func runParallelTests(t *testing.T, instance int) {
|
|||
|
||||
if instance == first {
|
||||
for instDone := range done {
|
||||
select {
|
||||
case <-instDone:
|
||||
}
|
||||
<-instDone
|
||||
}
|
||||
// Now check each instance got a different pool
|
||||
for i := 0; i < numInstances; i++ {
|
||||
|
@ -1495,7 +1482,7 @@ func TestRequestReleaseAddressDuplicate(t *testing.T) {
|
|||
scope: a.addrSpaces[localAddressSpace].scope,
|
||||
subnets: map[SubnetKey]*PoolData{},
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
|
||||
opts := map[string]string{
|
||||
ipamapi.AllocSerialPrefix: "true",
|
||||
}
|
||||
|
@ -1506,6 +1493,7 @@ func TestRequestReleaseAddressDuplicate(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
group := new(errgroup.Group)
|
||||
for err == nil {
|
||||
var c *net.IPNet
|
||||
if c, _, err = a.RequestAddress(poolID, nil, opts); err == nil {
|
||||
|
@ -1515,21 +1503,26 @@ func TestRequestReleaseAddressDuplicate(t *testing.T) {
|
|||
allocatedIPs = append(allocatedIPs, c)
|
||||
if len(allocatedIPs) > 500 {
|
||||
i := rand.Intn(len(allocatedIPs) - 1)
|
||||
wg.Add(1)
|
||||
go func(ip *net.IPNet) {
|
||||
ip := allocatedIPs[i]
|
||||
group.Go(func() error {
|
||||
if err = a.ReleaseAddress(poolID, ip.IP); err != nil {
|
||||
t.Fatal(err)
|
||||
return err
|
||||
}
|
||||
l.Lock()
|
||||
ips = append(ips, IP{ip, -1})
|
||||
l.Unlock()
|
||||
wg.Done()
|
||||
}(allocatedIPs[i])
|
||||
return nil
|
||||
})
|
||||
|
||||
allocatedIPs = append(allocatedIPs[:i], allocatedIPs[i+1:]...)
|
||||
}
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
if err := group.Wait(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
refMap := make(map[string]int)
|
||||
for _, ip := range ips {
|
||||
refMap[ip.ip.String()] = refMap[ip.ip.String()] + ip.ref
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/libnetwork/ipamapi"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"golang.org/x/sync/semaphore"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
|
@ -89,11 +90,20 @@ func TestRequestPoolParallel(t *testing.T) {
|
|||
}
|
||||
var operationIndex int32
|
||||
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++ {
|
||||
go func(t *testing.T, a *Allocator, ch chan *op) {
|
||||
group.Go(func() error {
|
||||
name, _, _, err := a.RequestPool("GlobalDefault", "", "", nil, false)
|
||||
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)
|
||||
ch <- &op{idx, true, name}
|
||||
|
@ -101,10 +111,12 @@ func TestRequestPoolParallel(t *testing.T) {
|
|||
idx = atomic.AddInt32(&operationIndex, 1)
|
||||
err = a.ReleasePool(name)
|
||||
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}
|
||||
}(t, a, ch)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// map of events
|
||||
|
@ -258,24 +270,25 @@ func release(t *testing.T, tctx *testContext, mode releaseMode, parallel int64)
|
|||
var id int
|
||||
parallelExec := semaphore.NewWeighted(parallel)
|
||||
ch := make(chan *net.IPNet, len(ipIndex))
|
||||
wg := sync.WaitGroup{}
|
||||
group := new(errgroup.Group)
|
||||
for index := range ipIndex {
|
||||
wg.Add(1)
|
||||
go func(id, index int) {
|
||||
index := index
|
||||
group.Go(func() error {
|
||||
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)
|
||||
if err != nil {
|
||||
t.Fatalf("routine %d got %v", id, err)
|
||||
return fmt.Errorf("routine %d got %v", id, err)
|
||||
}
|
||||
ch <- tctx.ipList[index]
|
||||
parallelExec.Release(1)
|
||||
wg.Done()
|
||||
}(id, index)
|
||||
return nil
|
||||
})
|
||||
id++
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
if err := group.Wait(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for i := 0; i < len(ipIndex); i++ {
|
||||
ip := <-ch
|
||||
|
|
|
@ -116,17 +116,6 @@ func (a *Allocator) writeToStore(aSpace *addrSpace) error {
|
|||
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
|
||||
func (aSpace *addrSpace) DataScope() string {
|
||||
aSpace.Lock()
|
||||
|
|
|
@ -159,7 +159,7 @@ func (aSpace *addrSpace) MarshalJSON() ([]byte, error) {
|
|||
defer aSpace.Unlock()
|
||||
|
||||
m := map[string]interface{}{
|
||||
"Scope": string(aSpace.scope),
|
||||
"Scope": aSpace.scope,
|
||||
}
|
||||
|
||||
if aSpace.subnets != nil {
|
||||
|
|
|
@ -4,9 +4,9 @@ package ipamapi
|
|||
import (
|
||||
"net"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
)
|
||||
|
||||
/********************
|
||||
|
|
|
@ -4,12 +4,12 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/pkg/plugins"
|
||||
"github.com/docker/docker/libnetwork/discoverapi"
|
||||
"github.com/docker/docker/libnetwork/ipamapi"
|
||||
"github.com/docker/docker/libnetwork/ipams/remote/api"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/plugingetter"
|
||||
"github.com/docker/docker/pkg/plugins"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
|
|
@ -54,6 +54,8 @@ func purgeConntrackState(nlh *netlink.Handle, family netlink.InetFamily, ipAddre
|
|||
filter := &netlink.ConntrackFilter{}
|
||||
// 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
|
||||
filter.AddIP(netlink.ConntrackNatAnyIP, ipAddress)
|
||||
if err := filter.AddIP(netlink.ConntrackNatAnyIP, ipAddress); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return nlh.ConntrackDeleteFilter(netlink.ConntrackTable, family, filter)
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ import (
|
|||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
_ "github.com/docker/docker/libnetwork/testutils"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
const chainName = "DOCKEREST"
|
||||
|
@ -194,8 +194,6 @@ func TestConcurrencyNoWait(t *testing.T) {
|
|||
// Note that if iptables does not support the xtable lock on this
|
||||
// system, then allowXlock has no effect -- it will always be off.
|
||||
func RunConcurrencyTest(t *testing.T, allowXlock bool) {
|
||||
var wg sync.WaitGroup
|
||||
|
||||
if !allowXlock && supportsXlock {
|
||||
supportsXlock = false
|
||||
defer func() { supportsXlock = true }()
|
||||
|
@ -207,17 +205,15 @@ func RunConcurrencyTest(t *testing.T, allowXlock bool) {
|
|||
dstPort := 4321
|
||||
proto := "tcp"
|
||||
|
||||
group := new(errgroup.Group)
|
||||
for i := 0; i < 10; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
err := natChain.Forward(Append, ip, port, proto, dstAddr, dstPort, "lo")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
group.Go(func() error {
|
||||
return natChain.Forward(Append, ip, port, proto, dstAddr, dstPort, "lo")
|
||||
})
|
||||
}
|
||||
if err := group.Wait(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func TestCleanup(t *testing.T) {
|
||||
|
|
|
@ -156,7 +156,7 @@ func TestNetworkMarshalling(t *testing.T) {
|
|||
}
|
||||
|
||||
func printIpamConf(list []*IpamConf) string {
|
||||
s := fmt.Sprintf("\n[]*IpamConfig{")
|
||||
s := "\n[]*IpamConfig{"
|
||||
for _, i := range list {
|
||||
s = fmt.Sprintf("%s %v,", s, i)
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ func printIpamConf(list []*IpamConf) string {
|
|||
}
|
||||
|
||||
func printIpamInfo(list []*IpamInfo) string {
|
||||
s := fmt.Sprintf("\n[]*IpamInfo{")
|
||||
s := "\n[]*IpamInfo{"
|
||||
for _, i := range list {
|
||||
s = fmt.Sprintf("%s\n{\n%s\n}", s, i)
|
||||
}
|
||||
|
@ -586,7 +586,9 @@ func TestIpamReleaseOnNetDriverFailures(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
gnw.Delete()
|
||||
if err := gnw.Delete(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Now check whether ipam release works on endpoint creation failure
|
||||
bd.failNetworkCreation = false
|
||||
|
@ -594,7 +596,11 @@ func TestIpamReleaseOnNetDriverFailures(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer bnw.Delete()
|
||||
defer func() {
|
||||
if err := bnw.Delete(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
if _, err := bnw.CreateEndpoint("ep0"); err == nil {
|
||||
t.Fatalf("bad network driver should have failed endpoint creation")
|
||||
|
@ -606,13 +612,17 @@ func TestIpamReleaseOnNetDriverFailures(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer gnw.Delete()
|
||||
defer func() {
|
||||
if err := gnw.Delete(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
ep, err := gnw.CreateEndpoint("ep1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer ep.Delete(false)
|
||||
defer ep.Delete(false) // nolint:errcheck
|
||||
|
||||
expectedIP, _ := types.ParseCIDR("10.35.0.1/16")
|
||||
if !types.CompareIPNet(ep.Info().Iface().Address(), expectedIP) {
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/docker/docker/libnetwork"
|
||||
"github.com/docker/docker/libnetwork/ipamapi"
|
||||
"github.com/docker/docker/libnetwork/netlabel"
|
||||
|
@ -22,6 +21,7 @@ import (
|
|||
"github.com/docker/docker/libnetwork/osl"
|
||||
"github.com/docker/docker/libnetwork/testutils"
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vishvananda/netlink"
|
||||
"github.com/vishvananda/netns"
|
||||
|
@ -920,7 +920,17 @@ func runParallelTests(t *testing.T, thrNumber int) {
|
|||
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")
|
||||
if err != nil {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue