From 710e0664c447b0a7595b71fdd65038aa058f24b6 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Wed, 26 Jul 2017 14:18:31 -0700 Subject: [PATCH] Update logrus to v1.0.1 Fix case sensitivity issue Update docker and runc vendors Signed-off-by: Derek McGowan --- libnetwork/agent.go | 2 +- libnetwork/bitseq/sequence.go | 2 +- libnetwork/cmd/dnet/dnet.go | 2 +- libnetwork/cmd/dnet/dnet_windows.go | 2 +- libnetwork/cmd/dnet/flags.go | 2 +- libnetwork/config/config.go | 2 +- libnetwork/controller.go | 2 +- libnetwork/default_gateway.go | 2 +- libnetwork/diagnose/diagnose.go | 2 +- libnetwork/drivers/bridge/bridge.go | 2 +- libnetwork/drivers/bridge/bridge_store.go | 2 +- libnetwork/drivers/bridge/interface.go | 2 +- libnetwork/drivers/bridge/link.go | 2 +- libnetwork/drivers/bridge/port_mapping.go | 2 +- .../bridge/setup_bridgenetfiltering.go | 2 +- libnetwork/drivers/bridge/setup_device.go | 2 +- .../drivers/bridge/setup_ip_forwarding.go | 2 +- libnetwork/drivers/bridge/setup_ip_tables.go | 2 +- libnetwork/drivers/bridge/setup_ipv4.go | 2 +- libnetwork/drivers/bridge/setup_ipv6.go | 2 +- libnetwork/drivers/bridge/setup_verify.go | 2 +- libnetwork/drivers/ipvlan/ipvlan_endpoint.go | 2 +- libnetwork/drivers/ipvlan/ipvlan_joinleave.go | 2 +- libnetwork/drivers/ipvlan/ipvlan_network.go | 2 +- libnetwork/drivers/ipvlan/ipvlan_setup.go | 2 +- libnetwork/drivers/ipvlan/ipvlan_state.go | 2 +- libnetwork/drivers/ipvlan/ipvlan_store.go | 2 +- .../drivers/macvlan/macvlan_endpoint.go | 2 +- .../drivers/macvlan/macvlan_joinleave.go | 2 +- libnetwork/drivers/macvlan/macvlan_network.go | 2 +- libnetwork/drivers/macvlan/macvlan_setup.go | 2 +- libnetwork/drivers/macvlan/macvlan_state.go | 2 +- libnetwork/drivers/macvlan/macvlan_store.go | 2 +- libnetwork/drivers/overlay/encryption.go | 2 +- libnetwork/drivers/overlay/filter.go | 2 +- libnetwork/drivers/overlay/joinleave.go | 2 +- libnetwork/drivers/overlay/ostweaks_linux.go | 2 +- libnetwork/drivers/overlay/ov_endpoint.go | 2 +- libnetwork/drivers/overlay/ov_network.go | 2 +- libnetwork/drivers/overlay/ov_serf.go | 2 +- libnetwork/drivers/overlay/ov_utils.go | 2 +- libnetwork/drivers/overlay/overlay.go | 2 +- .../drivers/overlay/ovmanager/ovmanager.go | 2 +- libnetwork/drivers/overlay/peerdb.go | 2 +- libnetwork/drivers/remote/driver.go | 2 +- libnetwork/drivers/solaris/bridge/bridge.go | 2 +- .../drivers/solaris/bridge/bridge_store.go | 2 +- .../drivers/solaris/bridge/port_mapping.go | 2 +- .../drivers/solaris/overlay/encryption.go | 2 +- .../drivers/solaris/overlay/joinleave.go | 2 +- .../drivers/solaris/overlay/ov_endpoint.go | 2 +- .../drivers/solaris/overlay/ov_network.go | 2 +- libnetwork/drivers/solaris/overlay/ov_serf.go | 2 +- libnetwork/drivers/solaris/overlay/overlay.go | 2 +- .../solaris/overlay/ovmanager/ovmanager.go | 2 +- libnetwork/drivers/solaris/overlay/peerdb.go | 2 +- .../windows/overlay/joinleave_windows.go | 2 +- .../windows/overlay/ov_endpoint_windows.go | 2 +- .../windows/overlay/ov_network_windows.go | 2 +- .../windows/overlay/overlay_windows.go | 2 +- .../drivers/windows/overlay/peerdb_windows.go | 2 +- libnetwork/drivers/windows/windows.go | 2 +- libnetwork/drivers/windows/windows_store.go | 2 +- libnetwork/endpoint.go | 2 +- libnetwork/firewall_linux.go | 2 +- libnetwork/hostdiscovery/hostdiscovery.go | 2 +- libnetwork/ipam/allocator.go | 2 +- libnetwork/ipam/store.go | 2 +- libnetwork/ipams/remote/remote.go | 2 +- libnetwork/ipams/windowsipam/windowsipam.go | 2 +- libnetwork/iptables/conntrack.go | 2 +- libnetwork/iptables/firewalld.go | 2 +- libnetwork/iptables/iptables.go | 2 +- libnetwork/ipvs/netlink.go | 2 +- libnetwork/libnetwork_linux_test.go | 2 +- libnetwork/libnetwork_test.go | 2 +- libnetwork/network.go | 2 +- libnetwork/network_windows.go | 2 +- libnetwork/networkdb/cluster.go | 2 +- libnetwork/networkdb/delegate.go | 2 +- libnetwork/networkdb/event_delegate.go | 2 +- libnetwork/networkdb/networkdb.go | 2 +- libnetwork/networkdb/networkdb_test.go | 2 +- libnetwork/ns/init_linux.go | 2 +- libnetwork/osl/interface_linux.go | 2 +- libnetwork/osl/namespace_linux.go | 2 +- libnetwork/osl/neigh_linux.go | 2 +- libnetwork/portmapper/mapper.go | 2 +- libnetwork/resolvconf/resolvconf.go | 2 +- libnetwork/resolver.go | 2 +- libnetwork/resolver_unix.go | 2 +- libnetwork/sandbox.go | 2 +- libnetwork/sandbox_dns_unix.go | 2 +- libnetwork/sandbox_externalkey_unix.go | 2 +- libnetwork/sandbox_store.go | 2 +- libnetwork/service_common.go | 2 +- libnetwork/service_linux.go | 2 +- libnetwork/store.go | 2 +- .../test/networkDb/dbclient/ndbClient.go | 2 +- .../test/networkDb/dbserver/ndbServer.go | 2 +- .../test/networkDb/dummyclient/dummyClient.go | 2 +- libnetwork/test/networkDb/testMain.go | 2 +- libnetwork/vendor.conf | 14 +- .../github.com/Azure/go-ansiterm/README.md | 3 + .../github.com/Azure/go-ansiterm/parser.go | 2 +- .../go-ansiterm/winterm/win_event_handler.go | 2 +- .../github.com/Microsoft/hcsshim/LICENSE | 3 +- .../Microsoft/hcsshim/activatelayer.go | 2 +- .../github.com/Microsoft/hcsshim/container.go | 234 +++++++++++-- .../Microsoft/hcsshim/createlayer.go | 2 +- .../Microsoft/hcsshim/createsandboxlayer.go | 2 +- .../Microsoft/hcsshim/deactivatelayer.go | 2 +- .../Microsoft/hcsshim/destroylayer.go | 2 +- .../github.com/Microsoft/hcsshim/errors.go | 34 ++ .../Microsoft/hcsshim/expandsandboxsize.go | 2 +- .../Microsoft/hcsshim/exportlayer.go | 4 +- .../Microsoft/hcsshim/getlayermountpath.go | 2 +- .../Microsoft/hcsshim/getsharedbaseimages.go | 2 +- .../github.com/Microsoft/hcsshim/hcsshim.go | 2 +- .../Microsoft/hcsshim/hnsendpoint.go | 183 ++++++++++ .../github.com/Microsoft/hcsshim/hnsfuncs.go | 126 +------ .../Microsoft/hcsshim/hnsnetwork.go | 142 ++++++++ .../github.com/Microsoft/hcsshim/hnspolicy.go | 95 ++++++ .../Microsoft/hcsshim/hnspolicylist.go | 187 +++++++++++ .../Microsoft/hcsshim/importlayer.go | 4 +- .../github.com/Microsoft/hcsshim/interface.go | 103 ++++-- .../Microsoft/hcsshim/layerexists.go | 2 +- .../Microsoft/hcsshim/layerutils.go | 2 +- .../github.com/Microsoft/hcsshim/legacy.go | 48 +-- .../Microsoft/hcsshim/mksyscall_windows.go | 136 +++++++- .../Microsoft/hcsshim/nametoguid.go | 2 +- .../Microsoft/hcsshim/preparelayer.go | 2 +- .../github.com/Microsoft/hcsshim/process.go | 9 +- .../Microsoft/hcsshim/unpreparelayer.go | 2 +- .../Microsoft/hcsshim/waithelper.go | 3 +- .../github.com/Microsoft/hcsshim/zhcsshim.go | 41 ++- .../Sirupsen/logrus/json_formatter.go | 41 --- .../github.com/Sirupsen/logrus/logger.go | 212 ------------ .../Sirupsen/logrus/terminal_solaris.go | 15 - .../Sirupsen/logrus/terminal_windows.go | 27 -- .../github.com/Sirupsen/logrus/writer.go | 31 -- .../docker/docker/pkg/discovery/backends.go | 2 +- .../docker/docker/pkg/discovery/kv/kv.go | 2 +- .../docker/pkg/parsers/kernel/kernel_unix.go | 2 +- .../docker/docker/pkg/plugins/client.go | 2 +- .../docker/docker/pkg/plugins/plugins.go | 2 +- .../docker/docker/pkg/signal/trap.go | 2 +- .../docker/pkg/system/syscall_windows.go | 2 +- .../docker/docker/pkg/term/windows/windows.go | 2 +- .../github.com/docker/docker/vendor.conf | 142 ++++++++ .../docker/go-connections/nat/nat.go | 177 +++++----- .../docker/go-connections/nat/parse.go | 1 + .../go-connections/sockets/inmem_socket.go | 8 - .../docker/go-connections/sockets/sockets.go | 16 +- .../go-connections/sockets/sockets_unix.go | 20 ++ .../go-connections/sockets/sockets_windows.go | 14 + .../go-connections/sockets/tcp_socket.go | 2 +- .../go-connections/sockets/unix_socket.go | 56 +--- .../go-connections/tlsconfig/certpool_go17.go | 18 + .../tlsconfig/certpool_other.go | 14 + .../docker/go-connections/tlsconfig/config.go | 185 ++++++++-- .../github.com/docker/go-events/LICENSE | 2 +- .../github.com/docker/go-events/README.md | 5 + .../github.com/docker/go-events/broadcast.go | 62 ++-- .../github.com/docker/go-events/channel.go | 28 +- .../github.com/docker/go-events/filter.go | 2 +- .../github.com/docker/go-events/queue.go | 15 +- .../github.com/docker/go-events/retry.go | 130 +++++-- .../runc/libcontainer/container_linux.go | 2 +- .../runc/libcontainer/init_linux.go | 2 +- .../{Sirupsen => sirupsen}/logrus/LICENSE | 0 .../{Sirupsen => sirupsen}/logrus/README.md | 224 ++++++++++--- .../github.com/sirupsen/logrus/alt_exit.go | 64 ++++ .../{Sirupsen => sirupsen}/logrus/doc.go | 4 +- .../{Sirupsen => sirupsen}/logrus/entry.go | 93 ++--- .../{Sirupsen => sirupsen}/logrus/exported.go | 4 +- .../logrus/formatter.go | 15 +- .../{Sirupsen => sirupsen}/logrus/hooks.go | 0 .../sirupsen/logrus/json_formatter.go | 74 ++++ .../github.com/sirupsen/logrus/logger.go | 317 ++++++++++++++++++ .../{Sirupsen => sirupsen}/logrus/logrus.go | 2 +- .../sirupsen/logrus/terminal_appengine.go | 10 + .../logrus/terminal_bsd.go | 1 + .../logrus/terminal_linux.go | 2 + .../logrus/terminal_notwindows.go | 15 +- .../sirupsen/logrus/terminal_solaris.go | 21 ++ .../sirupsen/logrus/terminal_windows.go | 82 +++++ .../logrus/text_formatter.go | 83 +++-- .../github.com/sirupsen/logrus/writer.go | 62 ++++ 189 files changed, 2843 insertions(+), 1078 deletions(-) create mode 100644 libnetwork/vendor/github.com/Microsoft/hcsshim/hnsendpoint.go create mode 100644 libnetwork/vendor/github.com/Microsoft/hcsshim/hnsnetwork.go create mode 100644 libnetwork/vendor/github.com/Microsoft/hcsshim/hnspolicy.go create mode 100644 libnetwork/vendor/github.com/Microsoft/hcsshim/hnspolicylist.go delete mode 100644 libnetwork/vendor/github.com/Sirupsen/logrus/json_formatter.go delete mode 100644 libnetwork/vendor/github.com/Sirupsen/logrus/logger.go delete mode 100644 libnetwork/vendor/github.com/Sirupsen/logrus/terminal_solaris.go delete mode 100644 libnetwork/vendor/github.com/Sirupsen/logrus/terminal_windows.go delete mode 100644 libnetwork/vendor/github.com/Sirupsen/logrus/writer.go create mode 100644 libnetwork/vendor/github.com/docker/docker/vendor.conf create mode 100644 libnetwork/vendor/github.com/docker/go-connections/tlsconfig/certpool_go17.go create mode 100644 libnetwork/vendor/github.com/docker/go-connections/tlsconfig/certpool_other.go rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/LICENSE (100%) rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/README.md (61%) create mode 100644 libnetwork/vendor/github.com/sirupsen/logrus/alt_exit.go rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/doc.go (83%) rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/entry.go (78%) rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/exported.go (99%) rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/formatter.go (85%) rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/hooks.go (100%) create mode 100644 libnetwork/vendor/github.com/sirupsen/logrus/json_formatter.go create mode 100644 libnetwork/vendor/github.com/sirupsen/logrus/logger.go rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/logrus.go (99%) create mode 100644 libnetwork/vendor/github.com/sirupsen/logrus/terminal_appengine.go rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_bsd.go (88%) rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_linux.go (92%) rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/terminal_notwindows.go (57%) create mode 100644 libnetwork/vendor/github.com/sirupsen/logrus/terminal_solaris.go create mode 100644 libnetwork/vendor/github.com/sirupsen/logrus/terminal_windows.go rename libnetwork/vendor/github.com/{Sirupsen => sirupsen}/logrus/text_formatter.go (63%) create mode 100644 libnetwork/vendor/github.com/sirupsen/logrus/writer.go diff --git a/libnetwork/agent.go b/libnetwork/agent.go index 0ccdd87de7..1328f0bade 100644 --- a/libnetwork/agent.go +++ b/libnetwork/agent.go @@ -10,7 +10,6 @@ import ( "sort" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/stringid" "github.com/docker/go-events" "github.com/docker/libnetwork/cluster" @@ -20,6 +19,7 @@ import ( "github.com/docker/libnetwork/networkdb" "github.com/docker/libnetwork/types" "github.com/gogo/protobuf/proto" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/bitseq/sequence.go b/libnetwork/bitseq/sequence.go index 6accc8acc3..3946473d8b 100644 --- a/libnetwork/bitseq/sequence.go +++ b/libnetwork/bitseq/sequence.go @@ -10,9 +10,9 @@ import ( "fmt" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // block sequence constants diff --git a/libnetwork/cmd/dnet/dnet.go b/libnetwork/cmd/dnet/dnet.go index 0762de3349..8086137347 100644 --- a/libnetwork/cmd/dnet/dnet.go +++ b/libnetwork/cmd/dnet/dnet.go @@ -22,7 +22,6 @@ import ( "github.com/docker/docker/pkg/discovery" "github.com/docker/docker/pkg/reexec" - "github.com/Sirupsen/logrus" "github.com/docker/docker/api/types/network" "github.com/docker/docker/pkg/term" "github.com/docker/libnetwork" @@ -36,6 +35,7 @@ import ( "github.com/docker/libnetwork/options" "github.com/docker/libnetwork/types" "github.com/gorilla/mux" + "github.com/sirupsen/logrus" "golang.org/x/net/context" ) diff --git a/libnetwork/cmd/dnet/dnet_windows.go b/libnetwork/cmd/dnet/dnet_windows.go index 54788e923b..1c31f765df 100644 --- a/libnetwork/cmd/dnet/dnet_windows.go +++ b/libnetwork/cmd/dnet/dnet_windows.go @@ -5,9 +5,9 @@ import ( "os" "syscall" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/signal" "github.com/docker/docker/pkg/system" + "github.com/sirupsen/logrus" ) // Copied over from docker/daemon/debugtrap_windows.go diff --git a/libnetwork/cmd/dnet/flags.go b/libnetwork/cmd/dnet/flags.go index 50c341746c..a59bd9d1fd 100644 --- a/libnetwork/cmd/dnet/flags.go +++ b/libnetwork/cmd/dnet/flags.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" + "github.com/sirupsen/logrus" ) var ( diff --git a/libnetwork/config/config.go b/libnetwork/config/config.go index a2e43e3a53..96a157a1fb 100644 --- a/libnetwork/config/config.go +++ b/libnetwork/config/config.go @@ -4,7 +4,6 @@ import ( "strings" "github.com/BurntSushi/toml" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/discovery" "github.com/docker/docker/pkg/plugingetter" "github.com/docker/go-connections/tlsconfig" @@ -13,6 +12,7 @@ import ( "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/osl" + "github.com/sirupsen/logrus" ) // Config encapsulates configurations of various Libnetwork components diff --git a/libnetwork/controller.go b/libnetwork/controller.go index 1696e07067..801097ab99 100644 --- a/libnetwork/controller.go +++ b/libnetwork/controller.go @@ -52,7 +52,6 @@ import ( "sync" "time" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/discovery" "github.com/docker/docker/pkg/locker" "github.com/docker/docker/pkg/plugingetter" @@ -69,6 +68,7 @@ import ( "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // NetworkController provides the interface for controller instance which manages diff --git a/libnetwork/default_gateway.go b/libnetwork/default_gateway.go index bf1592435f..9a60fd6758 100644 --- a/libnetwork/default_gateway.go +++ b/libnetwork/default_gateway.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/diagnose/diagnose.go b/libnetwork/diagnose/diagnose.go index 0ce7a491bf..2849397486 100644 --- a/libnetwork/diagnose/diagnose.go +++ b/libnetwork/diagnose/diagnose.go @@ -6,7 +6,7 @@ import ( "net/http" "sync" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // HTTPHandlerFunc TODO diff --git a/libnetwork/drivers/bridge/bridge.go b/libnetwork/drivers/bridge/bridge.go index dd79f04d91..64a2743dcf 100644 --- a/libnetwork/drivers/bridge/bridge.go +++ b/libnetwork/drivers/bridge/bridge.go @@ -12,7 +12,6 @@ import ( "sync" "syscall" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" @@ -24,6 +23,7 @@ import ( "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/portmapper" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/bridge/bridge_store.go b/libnetwork/drivers/bridge/bridge_store.go index c7c83d8369..b0e4ff02b5 100644 --- a/libnetwork/drivers/bridge/bridge_store.go +++ b/libnetwork/drivers/bridge/bridge_store.go @@ -5,11 +5,11 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/bridge/interface.go b/libnetwork/drivers/bridge/interface.go index 9b20900416..c9f3e8dfb7 100644 --- a/libnetwork/drivers/bridge/interface.go +++ b/libnetwork/drivers/bridge/interface.go @@ -4,7 +4,7 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/bridge/link.go b/libnetwork/drivers/bridge/link.go index 53e9eeef99..d364516f1a 100644 --- a/libnetwork/drivers/bridge/link.go +++ b/libnetwork/drivers/bridge/link.go @@ -4,9 +4,9 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/iptables" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) type link struct { diff --git a/libnetwork/drivers/bridge/port_mapping.go b/libnetwork/drivers/bridge/port_mapping.go index 965cc9a039..48010e9c59 100644 --- a/libnetwork/drivers/bridge/port_mapping.go +++ b/libnetwork/drivers/bridge/port_mapping.go @@ -6,8 +6,8 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) var ( diff --git a/libnetwork/drivers/bridge/setup_bridgenetfiltering.go b/libnetwork/drivers/bridge/setup_bridgenetfiltering.go index 884c7115ec..9b90acfac2 100644 --- a/libnetwork/drivers/bridge/setup_bridgenetfiltering.go +++ b/libnetwork/drivers/bridge/setup_bridgenetfiltering.go @@ -7,7 +7,7 @@ import ( "os" "syscall" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // Enumeration type saying which versions of IP protocol to process. diff --git a/libnetwork/drivers/bridge/setup_device.go b/libnetwork/drivers/bridge/setup_device.go index 0961bea55d..a9dfd06771 100644 --- a/libnetwork/drivers/bridge/setup_device.go +++ b/libnetwork/drivers/bridge/setup_device.go @@ -3,9 +3,9 @@ package bridge import ( "fmt" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/libnetwork/netutils" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/bridge/setup_ip_forwarding.go b/libnetwork/drivers/bridge/setup_ip_forwarding.go index d46f8ddf83..355a14d996 100644 --- a/libnetwork/drivers/bridge/setup_ip_forwarding.go +++ b/libnetwork/drivers/bridge/setup_ip_forwarding.go @@ -4,8 +4,8 @@ import ( "fmt" "io/ioutil" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/iptables" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/bridge/setup_ip_tables.go b/libnetwork/drivers/bridge/setup_ip_tables.go index 769debcb80..f01b08dea0 100644 --- a/libnetwork/drivers/bridge/setup_ip_tables.go +++ b/libnetwork/drivers/bridge/setup_ip_tables.go @@ -5,8 +5,8 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/iptables" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/bridge/setup_ipv4.go b/libnetwork/drivers/bridge/setup_ipv4.go index 7f8707266d..671bd3302e 100644 --- a/libnetwork/drivers/bridge/setup_ipv4.go +++ b/libnetwork/drivers/bridge/setup_ipv4.go @@ -7,8 +7,8 @@ import ( "net" "path/filepath" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/bridge/setup_ipv6.go b/libnetwork/drivers/bridge/setup_ipv6.go index ee3d753ac1..b944be081e 100644 --- a/libnetwork/drivers/bridge/setup_ipv6.go +++ b/libnetwork/drivers/bridge/setup_ipv6.go @@ -6,8 +6,8 @@ import ( "net" "os" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/bridge/setup_verify.go b/libnetwork/drivers/bridge/setup_verify.go index 330a5b4560..de77c38a66 100644 --- a/libnetwork/drivers/bridge/setup_verify.go +++ b/libnetwork/drivers/bridge/setup_verify.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/ipvlan/ipvlan_endpoint.go b/libnetwork/drivers/ipvlan/ipvlan_endpoint.go index d30aeac9b5..1fe44f2e71 100644 --- a/libnetwork/drivers/ipvlan/ipvlan_endpoint.go +++ b/libnetwork/drivers/ipvlan/ipvlan_endpoint.go @@ -3,12 +3,12 @@ package ipvlan import ( "fmt" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // CreateEndpoint assigns the mac, ip and endpoint id for the new container diff --git a/libnetwork/drivers/ipvlan/ipvlan_joinleave.go b/libnetwork/drivers/ipvlan/ipvlan_joinleave.go index 0c08dfce5d..9d229a245e 100644 --- a/libnetwork/drivers/ipvlan/ipvlan_joinleave.go +++ b/libnetwork/drivers/ipvlan/ipvlan_joinleave.go @@ -4,12 +4,12 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netutils" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) type staticRoute struct { diff --git a/libnetwork/drivers/ipvlan/ipvlan_network.go b/libnetwork/drivers/ipvlan/ipvlan_network.go index 801fc20a7e..a9544b5a95 100644 --- a/libnetwork/drivers/ipvlan/ipvlan_network.go +++ b/libnetwork/drivers/ipvlan/ipvlan_network.go @@ -3,7 +3,6 @@ package ipvlan import ( "fmt" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/stringid" "github.com/docker/libnetwork/driverapi" @@ -12,6 +11,7 @@ import ( "github.com/docker/libnetwork/options" "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // CreateNetwork the network for the specified driver type diff --git a/libnetwork/drivers/ipvlan/ipvlan_setup.go b/libnetwork/drivers/ipvlan/ipvlan_setup.go index 75f08210fb..0c39ec9d27 100644 --- a/libnetwork/drivers/ipvlan/ipvlan_setup.go +++ b/libnetwork/drivers/ipvlan/ipvlan_setup.go @@ -5,8 +5,8 @@ import ( "strconv" "strings" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/ns" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/ipvlan/ipvlan_state.go b/libnetwork/drivers/ipvlan/ipvlan_state.go index 2d8cb2d8f6..2a4ad25b40 100644 --- a/libnetwork/drivers/ipvlan/ipvlan_state.go +++ b/libnetwork/drivers/ipvlan/ipvlan_state.go @@ -3,9 +3,9 @@ package ipvlan import ( "fmt" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) func (d *driver) network(nid string) *network { diff --git a/libnetwork/drivers/ipvlan/ipvlan_store.go b/libnetwork/drivers/ipvlan/ipvlan_store.go index de994fa7f8..197e29966a 100644 --- a/libnetwork/drivers/ipvlan/ipvlan_store.go +++ b/libnetwork/drivers/ipvlan/ipvlan_store.go @@ -5,11 +5,11 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/macvlan/macvlan_endpoint.go b/libnetwork/drivers/macvlan/macvlan_endpoint.go index 3e5ccb29f8..d9fae57185 100644 --- a/libnetwork/drivers/macvlan/macvlan_endpoint.go +++ b/libnetwork/drivers/macvlan/macvlan_endpoint.go @@ -3,13 +3,13 @@ package macvlan import ( "fmt" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/netutils" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // CreateEndpoint assigns the mac, ip and endpoint id for the new container diff --git a/libnetwork/drivers/macvlan/macvlan_joinleave.go b/libnetwork/drivers/macvlan/macvlan_joinleave.go index cf5c2a4bf9..778613db77 100644 --- a/libnetwork/drivers/macvlan/macvlan_joinleave.go +++ b/libnetwork/drivers/macvlan/macvlan_joinleave.go @@ -4,11 +4,11 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netutils" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/osl" + "github.com/sirupsen/logrus" ) // Join method is invoked when a Sandbox is attached to an endpoint. diff --git a/libnetwork/drivers/macvlan/macvlan_network.go b/libnetwork/drivers/macvlan/macvlan_network.go index c455b9124d..914c6cdf64 100644 --- a/libnetwork/drivers/macvlan/macvlan_network.go +++ b/libnetwork/drivers/macvlan/macvlan_network.go @@ -3,7 +3,6 @@ package macvlan import ( "fmt" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/stringid" "github.com/docker/libnetwork/driverapi" @@ -12,6 +11,7 @@ import ( "github.com/docker/libnetwork/options" "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // CreateNetwork the network for the specified driver type diff --git a/libnetwork/drivers/macvlan/macvlan_setup.go b/libnetwork/drivers/macvlan/macvlan_setup.go index b5b4be3499..843a2e73bf 100644 --- a/libnetwork/drivers/macvlan/macvlan_setup.go +++ b/libnetwork/drivers/macvlan/macvlan_setup.go @@ -5,8 +5,8 @@ import ( "strconv" "strings" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/ns" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/macvlan/macvlan_state.go b/libnetwork/drivers/macvlan/macvlan_state.go index 8ac3d282f9..8fd1a9e4dc 100644 --- a/libnetwork/drivers/macvlan/macvlan_state.go +++ b/libnetwork/drivers/macvlan/macvlan_state.go @@ -3,9 +3,9 @@ package macvlan import ( "fmt" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) func (d *driver) network(nid string) *network { diff --git a/libnetwork/drivers/macvlan/macvlan_store.go b/libnetwork/drivers/macvlan/macvlan_store.go index 3fd92786bf..655a49c08b 100644 --- a/libnetwork/drivers/macvlan/macvlan_store.go +++ b/libnetwork/drivers/macvlan/macvlan_store.go @@ -5,11 +5,11 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/overlay/encryption.go b/libnetwork/drivers/overlay/encryption.go index 1d59f238b0..f12d7a8c67 100644 --- a/libnetwork/drivers/overlay/encryption.go +++ b/libnetwork/drivers/overlay/encryption.go @@ -12,10 +12,10 @@ import ( "strconv" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/iptables" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/drivers/overlay/filter.go b/libnetwork/drivers/overlay/filter.go index 40cd7d9f28..1601803aa0 100644 --- a/libnetwork/drivers/overlay/filter.go +++ b/libnetwork/drivers/overlay/filter.go @@ -4,8 +4,8 @@ import ( "fmt" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/iptables" + "github.com/sirupsen/logrus" ) const globalChain = "DOCKER-OVERLAY" diff --git a/libnetwork/drivers/overlay/joinleave.go b/libnetwork/drivers/overlay/joinleave.go index 31c311f4fc..39c2056a9b 100644 --- a/libnetwork/drivers/overlay/joinleave.go +++ b/libnetwork/drivers/overlay/joinleave.go @@ -5,11 +5,11 @@ import ( "net" "syscall" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/types" "github.com/gogo/protobuf/proto" + "github.com/sirupsen/logrus" ) // Join method is invoked when a Sandbox is attached to an endpoint. diff --git a/libnetwork/drivers/overlay/ostweaks_linux.go b/libnetwork/drivers/overlay/ostweaks_linux.go index 85840cf8c4..c00243ad2c 100644 --- a/libnetwork/drivers/overlay/ostweaks_linux.go +++ b/libnetwork/drivers/overlay/ostweaks_linux.go @@ -5,7 +5,7 @@ import ( "path" "strings" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) var sysctlConf = map[string]string{ diff --git a/libnetwork/drivers/overlay/ov_endpoint.go b/libnetwork/drivers/overlay/ov_endpoint.go index ebcab51501..d0e63f6b7e 100644 --- a/libnetwork/drivers/overlay/ov_endpoint.go +++ b/libnetwork/drivers/overlay/ov_endpoint.go @@ -5,12 +5,12 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netutils" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) type endpointTable map[string]*endpoint diff --git a/libnetwork/drivers/overlay/ov_network.go b/libnetwork/drivers/overlay/ov_network.go index 9575350bf6..d12dfc72f7 100644 --- a/libnetwork/drivers/overlay/ov_network.go +++ b/libnetwork/drivers/overlay/ov_network.go @@ -14,7 +14,6 @@ import ( "syscall" "time" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/reexec" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/driverapi" @@ -24,6 +23,7 @@ import ( "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/resolvconf" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" "github.com/vishvananda/netlink/nl" "github.com/vishvananda/netns" diff --git a/libnetwork/drivers/overlay/ov_serf.go b/libnetwork/drivers/overlay/ov_serf.go index 20954ef237..5b96c515c9 100644 --- a/libnetwork/drivers/overlay/ov_serf.go +++ b/libnetwork/drivers/overlay/ov_serf.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/Sirupsen/logrus" "github.com/hashicorp/serf/serf" + "github.com/sirupsen/logrus" ) type ovNotify struct { diff --git a/libnetwork/drivers/overlay/ov_utils.go b/libnetwork/drivers/overlay/ov_utils.go index 8a01914fa4..27f57c1fe2 100644 --- a/libnetwork/drivers/overlay/ov_utils.go +++ b/libnetwork/drivers/overlay/ov_utils.go @@ -5,10 +5,10 @@ import ( "strings" "syscall" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/netutils" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/osl" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" "github.com/vishvananda/netns" ) diff --git a/libnetwork/drivers/overlay/overlay.go b/libnetwork/drivers/overlay/overlay.go index 11eda6781b..0b22439ca7 100644 --- a/libnetwork/drivers/overlay/overlay.go +++ b/libnetwork/drivers/overlay/overlay.go @@ -8,7 +8,6 @@ import ( "net" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" @@ -17,6 +16,7 @@ import ( "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" "github.com/hashicorp/serf/serf" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/overlay/ovmanager/ovmanager.go b/libnetwork/drivers/overlay/ovmanager/ovmanager.go index 3c3c0bb257..a80f335892 100644 --- a/libnetwork/drivers/overlay/ovmanager/ovmanager.go +++ b/libnetwork/drivers/overlay/ovmanager/ovmanager.go @@ -7,13 +7,13 @@ import ( "strings" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/idm" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/overlay/peerdb.go b/libnetwork/drivers/overlay/peerdb.go index 4b41bf7658..f8f8493743 100644 --- a/libnetwork/drivers/overlay/peerdb.go +++ b/libnetwork/drivers/overlay/peerdb.go @@ -7,8 +7,8 @@ import ( "sync" "syscall" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/common" + "github.com/sirupsen/logrus" ) const ovPeerTable = "overlay_peer_table" diff --git a/libnetwork/drivers/remote/driver.go b/libnetwork/drivers/remote/driver.go index ffe0730c95..b52163025a 100644 --- a/libnetwork/drivers/remote/driver.go +++ b/libnetwork/drivers/remote/driver.go @@ -5,13 +5,13 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/plugins" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/drivers/remote/api" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) type driver struct { diff --git a/libnetwork/drivers/solaris/bridge/bridge.go b/libnetwork/drivers/solaris/bridge/bridge.go index 2547016a4b..558157abe4 100644 --- a/libnetwork/drivers/solaris/bridge/bridge.go +++ b/libnetwork/drivers/solaris/bridge/bridge.go @@ -13,7 +13,6 @@ import ( "strings" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" @@ -23,6 +22,7 @@ import ( "github.com/docker/libnetwork/options" "github.com/docker/libnetwork/portmapper" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/solaris/bridge/bridge_store.go b/libnetwork/drivers/solaris/bridge/bridge_store.go index 956e82902f..6f5db4f5b9 100644 --- a/libnetwork/drivers/solaris/bridge/bridge_store.go +++ b/libnetwork/drivers/solaris/bridge/bridge_store.go @@ -7,11 +7,11 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/solaris/bridge/port_mapping.go b/libnetwork/drivers/solaris/bridge/port_mapping.go index 1cf22c13c9..3b67db388a 100644 --- a/libnetwork/drivers/solaris/bridge/port_mapping.go +++ b/libnetwork/drivers/solaris/bridge/port_mapping.go @@ -10,8 +10,8 @@ import ( "os" "os/exec" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) var ( diff --git a/libnetwork/drivers/solaris/overlay/encryption.go b/libnetwork/drivers/solaris/overlay/encryption.go index ca7b60b4c7..0af3474b93 100644 --- a/libnetwork/drivers/solaris/overlay/encryption.go +++ b/libnetwork/drivers/solaris/overlay/encryption.go @@ -9,8 +9,8 @@ import ( "net" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/solaris/overlay/joinleave.go b/libnetwork/drivers/solaris/overlay/joinleave.go index fd411988d1..ff03f3ccb6 100644 --- a/libnetwork/drivers/solaris/overlay/joinleave.go +++ b/libnetwork/drivers/solaris/overlay/joinleave.go @@ -4,10 +4,10 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/types" "github.com/gogo/protobuf/proto" + "github.com/sirupsen/logrus" ) // Join method is invoked when a Sandbox is attached to an endpoint. diff --git a/libnetwork/drivers/solaris/overlay/ov_endpoint.go b/libnetwork/drivers/solaris/overlay/ov_endpoint.go index ca0c477dcd..21b33ffe85 100644 --- a/libnetwork/drivers/solaris/overlay/ov_endpoint.go +++ b/libnetwork/drivers/solaris/overlay/ov_endpoint.go @@ -5,11 +5,11 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netutils" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) type endpointTable map[string]*endpoint diff --git a/libnetwork/drivers/solaris/overlay/ov_network.go b/libnetwork/drivers/solaris/overlay/ov_network.go index b0567261c7..b545bc8903 100644 --- a/libnetwork/drivers/solaris/overlay/ov_network.go +++ b/libnetwork/drivers/solaris/overlay/ov_network.go @@ -10,7 +10,6 @@ import ( "strings" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netlabel" @@ -18,6 +17,7 @@ import ( "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/resolvconf" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) var ( diff --git a/libnetwork/drivers/solaris/overlay/ov_serf.go b/libnetwork/drivers/solaris/overlay/ov_serf.go index 53c59b4df2..ddc0509064 100644 --- a/libnetwork/drivers/solaris/overlay/ov_serf.go +++ b/libnetwork/drivers/solaris/overlay/ov_serf.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/Sirupsen/logrus" "github.com/hashicorp/serf/serf" + "github.com/sirupsen/logrus" ) type ovNotify struct { diff --git a/libnetwork/drivers/solaris/overlay/overlay.go b/libnetwork/drivers/solaris/overlay/overlay.go index 0a5a1bfdce..45b62b1835 100644 --- a/libnetwork/drivers/solaris/overlay/overlay.go +++ b/libnetwork/drivers/solaris/overlay/overlay.go @@ -7,7 +7,6 @@ import ( "net" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" @@ -16,6 +15,7 @@ import ( "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" "github.com/hashicorp/serf/serf" + "github.com/sirupsen/logrus" ) // XXX OVERLAY_SOLARIS diff --git a/libnetwork/drivers/solaris/overlay/ovmanager/ovmanager.go b/libnetwork/drivers/solaris/overlay/ovmanager/ovmanager.go index a3a7cd4cf8..c39f53aefa 100644 --- a/libnetwork/drivers/solaris/overlay/ovmanager/ovmanager.go +++ b/libnetwork/drivers/solaris/overlay/ovmanager/ovmanager.go @@ -7,13 +7,13 @@ import ( "strings" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/idm" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/solaris/overlay/peerdb.go b/libnetwork/drivers/solaris/overlay/peerdb.go index d1499e2132..23d9a9729b 100644 --- a/libnetwork/drivers/solaris/overlay/peerdb.go +++ b/libnetwork/drivers/solaris/overlay/peerdb.go @@ -5,7 +5,7 @@ import ( "net" "sync" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) const ovPeerTable = "overlay_peer_table" diff --git a/libnetwork/drivers/windows/overlay/joinleave_windows.go b/libnetwork/drivers/windows/overlay/joinleave_windows.go index 91dcf28b32..cded48af64 100644 --- a/libnetwork/drivers/windows/overlay/joinleave_windows.go +++ b/libnetwork/drivers/windows/overlay/joinleave_windows.go @@ -4,10 +4,10 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/types" "github.com/gogo/protobuf/proto" + "github.com/sirupsen/logrus" ) // Join method is invoked when a Sandbox is attached to an endpoint. diff --git a/libnetwork/drivers/windows/overlay/ov_endpoint_windows.go b/libnetwork/drivers/windows/overlay/ov_endpoint_windows.go index 3e45115df7..47af64cb9a 100644 --- a/libnetwork/drivers/windows/overlay/ov_endpoint_windows.go +++ b/libnetwork/drivers/windows/overlay/ov_endpoint_windows.go @@ -6,8 +6,8 @@ import ( "net" "github.com/Microsoft/hcsshim" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/driverapi" + "github.com/sirupsen/logrus" ) type endpointTable map[string]*endpoint diff --git a/libnetwork/drivers/windows/overlay/ov_network_windows.go b/libnetwork/drivers/windows/overlay/ov_network_windows.go index 65b7e38d3b..70c4f02eda 100644 --- a/libnetwork/drivers/windows/overlay/ov_network_windows.go +++ b/libnetwork/drivers/windows/overlay/ov_network_windows.go @@ -9,10 +9,10 @@ import ( "sync" "github.com/Microsoft/hcsshim" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) var ( diff --git a/libnetwork/drivers/windows/overlay/overlay_windows.go b/libnetwork/drivers/windows/overlay/overlay_windows.go index 111e517dbd..d415bebcbd 100644 --- a/libnetwork/drivers/windows/overlay/overlay_windows.go +++ b/libnetwork/drivers/windows/overlay/overlay_windows.go @@ -8,12 +8,12 @@ import ( "sync" "github.com/Microsoft/hcsshim" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/drivers/windows/overlay/peerdb_windows.go b/libnetwork/drivers/windows/overlay/peerdb_windows.go index 04581f784a..0abc232432 100644 --- a/libnetwork/drivers/windows/overlay/peerdb_windows.go +++ b/libnetwork/drivers/windows/overlay/peerdb_windows.go @@ -6,8 +6,8 @@ import ( "encoding/json" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/Microsoft/hcsshim" ) diff --git a/libnetwork/drivers/windows/windows.go b/libnetwork/drivers/windows/windows.go index 19b2e685b4..45f835ee07 100644 --- a/libnetwork/drivers/windows/windows.go +++ b/libnetwork/drivers/windows/windows.go @@ -20,12 +20,12 @@ import ( "sync" "github.com/Microsoft/hcsshim" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // networkConfiguration for network specific configuration diff --git a/libnetwork/drivers/windows/windows_store.go b/libnetwork/drivers/windows/windows_store.go index bbed5aeaa2..caa93c68fb 100644 --- a/libnetwork/drivers/windows/windows_store.go +++ b/libnetwork/drivers/windows/windows_store.go @@ -7,11 +7,11 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/endpoint.go b/libnetwork/endpoint.go index 111b747352..724d0e5315 100644 --- a/libnetwork/endpoint.go +++ b/libnetwork/endpoint.go @@ -8,12 +8,12 @@ import ( "strings" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/ipamapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/options" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // Endpoint represents a logical connection between a network and a sandbox. diff --git a/libnetwork/firewall_linux.go b/libnetwork/firewall_linux.go index 8c27c1dd25..b2232ac7a5 100644 --- a/libnetwork/firewall_linux.go +++ b/libnetwork/firewall_linux.go @@ -1,8 +1,8 @@ package libnetwork import ( - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/iptables" + "github.com/sirupsen/logrus" ) const userChain = "DOCKER-USER" diff --git a/libnetwork/hostdiscovery/hostdiscovery.go b/libnetwork/hostdiscovery/hostdiscovery.go index a45ecb60a3..452b5628c1 100644 --- a/libnetwork/hostdiscovery/hostdiscovery.go +++ b/libnetwork/hostdiscovery/hostdiscovery.go @@ -4,7 +4,7 @@ import ( "net" "sync" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" mapset "github.com/deckarep/golang-set" "github.com/docker/docker/pkg/discovery" diff --git a/libnetwork/ipam/allocator.go b/libnetwork/ipam/allocator.go index b3876ffded..71c9f39531 100644 --- a/libnetwork/ipam/allocator.go +++ b/libnetwork/ipam/allocator.go @@ -6,13 +6,13 @@ import ( "sort" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/bitseq" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/ipamapi" "github.com/docker/libnetwork/ipamutils" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/ipam/store.go b/libnetwork/ipam/store.go index d05e1b70b9..124d585518 100644 --- a/libnetwork/ipam/store.go +++ b/libnetwork/ipam/store.go @@ -3,9 +3,9 @@ package ipam import ( "encoding/json" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // Key provides the Key to be used in KV Store diff --git a/libnetwork/ipams/remote/remote.go b/libnetwork/ipams/remote/remote.go index d2e2b4f3c8..9f2f1d5fed 100644 --- a/libnetwork/ipams/remote/remote.go +++ b/libnetwork/ipams/remote/remote.go @@ -4,12 +4,12 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/plugins" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/ipamapi" "github.com/docker/libnetwork/ipams/remote/api" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) type allocator struct { diff --git a/libnetwork/ipams/windowsipam/windowsipam.go b/libnetwork/ipams/windowsipam/windowsipam.go index 6b124d40d2..9cf99d42b1 100644 --- a/libnetwork/ipams/windowsipam/windowsipam.go +++ b/libnetwork/ipams/windowsipam/windowsipam.go @@ -3,11 +3,11 @@ package windowsipam import ( "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/ipamapi" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/iptables/conntrack.go b/libnetwork/iptables/conntrack.go index 5731c53c04..08317c33ee 100644 --- a/libnetwork/iptables/conntrack.go +++ b/libnetwork/iptables/conntrack.go @@ -5,7 +5,7 @@ import ( "net" "syscall" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/iptables/firewalld.go b/libnetwork/iptables/firewalld.go index 7dc5127fa4..c9838d5b65 100644 --- a/libnetwork/iptables/firewalld.go +++ b/libnetwork/iptables/firewalld.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/Sirupsen/logrus" "github.com/godbus/dbus" + "github.com/sirupsen/logrus" ) // IPV defines the table string diff --git a/libnetwork/iptables/iptables.go b/libnetwork/iptables/iptables.go index caa202b366..ecce0d3b2a 100644 --- a/libnetwork/iptables/iptables.go +++ b/libnetwork/iptables/iptables.go @@ -10,7 +10,7 @@ import ( "strings" "sync" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // Action signifies the iptable action. diff --git a/libnetwork/ipvs/netlink.go b/libnetwork/ipvs/netlink.go index 5450679c3b..b8d33dcdc4 100644 --- a/libnetwork/ipvs/netlink.go +++ b/libnetwork/ipvs/netlink.go @@ -14,7 +14,7 @@ import ( "syscall" "unsafe" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink/nl" "github.com/vishvananda/netns" ) diff --git a/libnetwork/libnetwork_linux_test.go b/libnetwork/libnetwork_linux_test.go index 679b004fe2..8d779f4e68 100644 --- a/libnetwork/libnetwork_linux_test.go +++ b/libnetwork/libnetwork_linux_test.go @@ -14,7 +14,6 @@ import ( "strings" "testing" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/reexec" "github.com/docker/libnetwork" "github.com/docker/libnetwork/ipamapi" @@ -25,6 +24,7 @@ import ( "github.com/docker/libnetwork/types" "github.com/opencontainers/runc/libcontainer" "github.com/opencontainers/runc/libcontainer/configs" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" "github.com/vishvananda/netns" ) diff --git a/libnetwork/libnetwork_test.go b/libnetwork/libnetwork_test.go index 1b3fa43172..2b04f58fe9 100644 --- a/libnetwork/libnetwork_test.go +++ b/libnetwork/libnetwork_test.go @@ -10,7 +10,6 @@ import ( "sync" "testing" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/plugins" "github.com/docker/docker/pkg/reexec" "github.com/docker/libnetwork" @@ -22,6 +21,7 @@ import ( "github.com/docker/libnetwork/options" "github.com/docker/libnetwork/testutils" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/vishvananda/netns" ) diff --git a/libnetwork/network.go b/libnetwork/network.go index 72deeea660..3f44553b9d 100644 --- a/libnetwork/network.go +++ b/libnetwork/network.go @@ -8,7 +8,6 @@ import ( "sync" "time" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/stringid" "github.com/docker/libnetwork/common" "github.com/docker/libnetwork/config" @@ -21,6 +20,7 @@ import ( "github.com/docker/libnetwork/networkdb" "github.com/docker/libnetwork/options" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // A Network represents a logical connectivity zone that containers may diff --git a/libnetwork/network_windows.go b/libnetwork/network_windows.go index ddcd3345f2..388b811421 100644 --- a/libnetwork/network_windows.go +++ b/libnetwork/network_windows.go @@ -7,10 +7,10 @@ import ( "time" "github.com/Microsoft/hcsshim" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/drivers/windows" "github.com/docker/libnetwork/ipamapi" "github.com/docker/libnetwork/ipams/windowsipam" + "github.com/sirupsen/logrus" ) func executeInCompartment(compartmentID uint32, x func()) { diff --git a/libnetwork/networkdb/cluster.go b/libnetwork/networkdb/cluster.go index ba9d91826f..d15a5767ff 100644 --- a/libnetwork/networkdb/cluster.go +++ b/libnetwork/networkdb/cluster.go @@ -12,8 +12,8 @@ import ( "strings" "time" - "github.com/Sirupsen/logrus" "github.com/hashicorp/memberlist" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/networkdb/delegate.go b/libnetwork/networkdb/delegate.go index c48c779558..ffaf94e8c8 100644 --- a/libnetwork/networkdb/delegate.go +++ b/libnetwork/networkdb/delegate.go @@ -5,8 +5,8 @@ import ( "net" "strings" - "github.com/Sirupsen/logrus" "github.com/gogo/protobuf/proto" + "github.com/sirupsen/logrus" ) type delegate struct { diff --git a/libnetwork/networkdb/event_delegate.go b/libnetwork/networkdb/event_delegate.go index 0f32194cf3..74aa465294 100644 --- a/libnetwork/networkdb/event_delegate.go +++ b/libnetwork/networkdb/event_delegate.go @@ -4,8 +4,8 @@ import ( "encoding/json" "net" - "github.com/Sirupsen/logrus" "github.com/hashicorp/memberlist" + "github.com/sirupsen/logrus" ) type eventDelegate struct { diff --git a/libnetwork/networkdb/networkdb.go b/libnetwork/networkdb/networkdb.go index 4f1860ff91..73dd999097 100644 --- a/libnetwork/networkdb/networkdb.go +++ b/libnetwork/networkdb/networkdb.go @@ -10,12 +10,12 @@ import ( "sync" "time" - "github.com/Sirupsen/logrus" "github.com/armon/go-radix" "github.com/docker/go-events" "github.com/docker/libnetwork/types" "github.com/hashicorp/memberlist" "github.com/hashicorp/serf/serf" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/networkdb/networkdb_test.go b/libnetwork/networkdb/networkdb_test.go index cb93eefd08..326aaadecd 100644 --- a/libnetwork/networkdb/networkdb_test.go +++ b/libnetwork/networkdb/networkdb_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" - "github.com/Sirupsen/logrus" "github.com/docker/go-events" + "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/libnetwork/ns/init_linux.go b/libnetwork/ns/init_linux.go index 84d4950750..567a6242ac 100644 --- a/libnetwork/ns/init_linux.go +++ b/libnetwork/ns/init_linux.go @@ -9,7 +9,7 @@ import ( "syscall" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" "github.com/vishvananda/netns" ) diff --git a/libnetwork/osl/interface_linux.go b/libnetwork/osl/interface_linux.go index 8e8a830ce9..60583bd80f 100644 --- a/libnetwork/osl/interface_linux.go +++ b/libnetwork/osl/interface_linux.go @@ -8,9 +8,9 @@ import ( "syscall" "time" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" "github.com/vishvananda/netns" ) diff --git a/libnetwork/osl/namespace_linux.go b/libnetwork/osl/namespace_linux.go index d6b9d78234..33a84f598b 100644 --- a/libnetwork/osl/namespace_linux.go +++ b/libnetwork/osl/namespace_linux.go @@ -14,10 +14,10 @@ import ( "syscall" "time" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/reexec" "github.com/docker/libnetwork/ns" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" "github.com/vishvananda/netns" ) diff --git a/libnetwork/osl/neigh_linux.go b/libnetwork/osl/neigh_linux.go index c105e52232..4e479489fa 100644 --- a/libnetwork/osl/neigh_linux.go +++ b/libnetwork/osl/neigh_linux.go @@ -5,7 +5,7 @@ import ( "fmt" "net" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/portmapper/mapper.go b/libnetwork/portmapper/mapper.go index 7f2a67c89f..f480edae03 100644 --- a/libnetwork/portmapper/mapper.go +++ b/libnetwork/portmapper/mapper.go @@ -6,9 +6,9 @@ import ( "net" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/iptables" "github.com/docker/libnetwork/portallocator" + "github.com/sirupsen/logrus" ) type mapping struct { diff --git a/libnetwork/resolvconf/resolvconf.go b/libnetwork/resolvconf/resolvconf.go index 9da6922e2b..5cb251b131 100644 --- a/libnetwork/resolvconf/resolvconf.go +++ b/libnetwork/resolvconf/resolvconf.go @@ -8,10 +8,10 @@ import ( "strings" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/ioutils" "github.com/docker/libnetwork/resolvconf/dns" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) var ( diff --git a/libnetwork/resolver.go b/libnetwork/resolver.go index ff472d0019..d382e7f67d 100644 --- a/libnetwork/resolver.go +++ b/libnetwork/resolver.go @@ -8,9 +8,9 @@ import ( "sync" "time" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/types" "github.com/miekg/dns" + "github.com/sirupsen/logrus" ) // Resolver represents the embedded DNS server in Docker. It operates diff --git a/libnetwork/resolver_unix.go b/libnetwork/resolver_unix.go index 5fcc6b9fa9..b35009ee74 100644 --- a/libnetwork/resolver_unix.go +++ b/libnetwork/resolver_unix.go @@ -9,9 +9,9 @@ import ( "os/exec" "runtime" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/reexec" "github.com/docker/libnetwork/iptables" + "github.com/sirupsen/logrus" "github.com/vishvananda/netns" ) diff --git a/libnetwork/sandbox.go b/libnetwork/sandbox.go index 46674067a1..167bc301a2 100644 --- a/libnetwork/sandbox.go +++ b/libnetwork/sandbox.go @@ -9,11 +9,11 @@ import ( "sync" "time" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/etchosts" "github.com/docker/libnetwork/netlabel" "github.com/docker/libnetwork/osl" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) // Sandbox provides the control over the network container entity. It is a one to one mapping with the container. diff --git a/libnetwork/sandbox_dns_unix.go b/libnetwork/sandbox_dns_unix.go index 867cc8abb4..f18f0b3ee6 100644 --- a/libnetwork/sandbox_dns_unix.go +++ b/libnetwork/sandbox_dns_unix.go @@ -11,11 +11,11 @@ import ( "strconv" "strings" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/etchosts" "github.com/docker/libnetwork/resolvconf" "github.com/docker/libnetwork/resolvconf/dns" "github.com/docker/libnetwork/types" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/sandbox_externalkey_unix.go b/libnetwork/sandbox_externalkey_unix.go index c33398f953..f4c4276848 100644 --- a/libnetwork/sandbox_externalkey_unix.go +++ b/libnetwork/sandbox_externalkey_unix.go @@ -10,9 +10,9 @@ import ( "net" "os" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/types" "github.com/opencontainers/runc/libcontainer/configs" + "github.com/sirupsen/logrus" ) const udsBase = "/run/docker/libnetwork/" diff --git a/libnetwork/sandbox_store.go b/libnetwork/sandbox_store.go index b92a544dc9..a083644598 100644 --- a/libnetwork/sandbox_store.go +++ b/libnetwork/sandbox_store.go @@ -5,9 +5,9 @@ import ( "encoding/json" "sync" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/osl" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/service_common.go b/libnetwork/service_common.go index 7e3367c71c..64d283e541 100644 --- a/libnetwork/service_common.go +++ b/libnetwork/service_common.go @@ -5,8 +5,8 @@ package libnetwork import ( "net" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/common" + "github.com/sirupsen/logrus" ) func (c *controller) addEndpointNameResolution(svcName, svcID, nID, eID, containerName string, vip net.IP, serviceAliases, taskAliases []string, ip net.IP, addService bool, method string) error { diff --git a/libnetwork/service_linux.go b/libnetwork/service_linux.go index 784c1784ec..00665941ed 100644 --- a/libnetwork/service_linux.go +++ b/libnetwork/service_linux.go @@ -14,12 +14,12 @@ import ( "sync" "syscall" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/reexec" "github.com/docker/libnetwork/iptables" "github.com/docker/libnetwork/ipvs" "github.com/docker/libnetwork/ns" "github.com/gogo/protobuf/proto" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink/nl" "github.com/vishvananda/netns" ) diff --git a/libnetwork/store.go b/libnetwork/store.go index 398794bfef..1a897bfe01 100644 --- a/libnetwork/store.go +++ b/libnetwork/store.go @@ -4,12 +4,12 @@ import ( "fmt" "strings" - "github.com/Sirupsen/logrus" "github.com/docker/libkv/store/boltdb" "github.com/docker/libkv/store/consul" "github.com/docker/libkv/store/etcd" "github.com/docker/libkv/store/zookeeper" "github.com/docker/libnetwork/datastore" + "github.com/sirupsen/logrus" ) func registerKVStores() { diff --git a/libnetwork/test/networkDb/dbclient/ndbClient.go b/libnetwork/test/networkDb/dbclient/ndbClient.go index 4550abb8cf..beeee2a4c6 100644 --- a/libnetwork/test/networkDb/dbclient/ndbClient.go +++ b/libnetwork/test/networkDb/dbclient/ndbClient.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) var servicePort string diff --git a/libnetwork/test/networkDb/dbserver/ndbServer.go b/libnetwork/test/networkDb/dbserver/ndbServer.go index dab8b3dbb5..f96474bd3a 100644 --- a/libnetwork/test/networkDb/dbserver/ndbServer.go +++ b/libnetwork/test/networkDb/dbserver/ndbServer.go @@ -9,10 +9,10 @@ import ( "os" "strconv" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/diagnose" "github.com/docker/libnetwork/networkdb" "github.com/docker/libnetwork/test/networkDb/dummyclient" + "github.com/sirupsen/logrus" ) var nDB *networkdb.NetworkDB diff --git a/libnetwork/test/networkDb/dummyclient/dummyClient.go b/libnetwork/test/networkDb/dummyclient/dummyClient.go index 510042a074..c62c45974f 100644 --- a/libnetwork/test/networkDb/dummyclient/dummyClient.go +++ b/libnetwork/test/networkDb/dummyclient/dummyClient.go @@ -5,10 +5,10 @@ import ( "log" "net/http" - "github.com/Sirupsen/logrus" events "github.com/docker/go-events" "github.com/docker/libnetwork/diagnose" "github.com/docker/libnetwork/networkdb" + "github.com/sirupsen/logrus" ) // DummyClientPaths2Func exported paths for the client diff --git a/libnetwork/test/networkDb/testMain.go b/libnetwork/test/networkDb/testMain.go index 4ec3064fa0..320673e97c 100644 --- a/libnetwork/test/networkDb/testMain.go +++ b/libnetwork/test/networkDb/testMain.go @@ -4,9 +4,9 @@ import ( "log" "os" - "github.com/Sirupsen/logrus" "github.com/docker/libnetwork/test/networkDb/dbclient" "github.com/docker/libnetwork/test/networkDb/dbserver" + "github.com/sirupsen/logrus" ) func main() { diff --git a/libnetwork/vendor.conf b/libnetwork/vendor.conf index 203e1cebf5..6751cba47e 100644 --- a/libnetwork/vendor.conf +++ b/libnetwork/vendor.conf @@ -1,8 +1,7 @@ -github.com/Azure/go-ansiterm 04b7f292a41fcb5da32dda536c0807fc13e8351c +github.com/Azure/go-ansiterm 19f72df4d05d31cbe1c56bfc8045c96babff6c7e github.com/BurntSushi/toml f706d00e3de6abe700c994cdd545a1a4915af060 github.com/Microsoft/go-winio ce2922f643c8fd76b46cadc7f404a06282678b34 -github.com/Microsoft/hcsshim e439b7d2b63f036d3a50c93a9e0b154a0d50e788 -github.com/Sirupsen/logrus 4b6ea7319e214d98c938f12692336f7ca9348d6b +github.com/Microsoft/hcsshim v0.6.1 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 github.com/boltdb/bolt c6ba97b89e0454fec9aa92e1d33a4e2c5fc1f631 @@ -11,9 +10,9 @@ github.com/coreos/etcd 925d1d74cec8c3b169c52fd4b2dc234a35934fce github.com/coreos/go-systemd b4a58d95188dd092ae20072bac14cece0e67c388 github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d -github.com/docker/docker 9c96768eae4b3a65147b47a55c850c103ab8972d -github.com/docker/go-connections 34b5052da6b11e27f5f2e357b38b571ddddd3928 -github.com/docker/go-events 2e7d352816128aa84f4d29b2a21d400133701a0d +github.com/docker/docker 2cac43e3573893cf8fd816e0ad5615426acb87f4 https://github.com/dmcgowan/docker.git +github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d +github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/docker/go-units 8e2d4523730c73120e10d4652f36ad6010998f4e github.com/docker/libkv 1d8431073ae03cdaedb198a89722f3aab6d418ef @@ -31,9 +30,10 @@ github.com/hashicorp/go-sockaddr acd314c5781ea706c710d9ea70069fd2e110d61d github.com/hashicorp/serf 598c54895cc5a7b1a24a398d635e8c0ea0959870 github.com/mattn/go-shellwords 525bedee691b5a8df547cb5cf9f86b7fb1883e24 github.com/miekg/dns d27455715200c7d3e321a1e5cadb27c9ee0b0f02 -github.com/opencontainers/runc ba1568de399395774ad84c2ace65937814c542ed +github.com/opencontainers/runc 8694d576ea3ce3c9e2c804b7f91b4e1e9a575d1c https://github.com/dmcgowan/runc.git github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374 github.com/seccomp/libseccomp-golang 1b506fc7c24eec5a3693cdcbed40d9c226cfc6a1 +github.com/sirupsen/logrus v1.0.1 github.com/stretchr/testify dab07ac62d4905d3e48d17dc549c684ac3b7c15a github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852 github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065 diff --git a/libnetwork/vendor/github.com/Azure/go-ansiterm/README.md b/libnetwork/vendor/github.com/Azure/go-ansiterm/README.md index e25e382101..261c041e7a 100644 --- a/libnetwork/vendor/github.com/Azure/go-ansiterm/README.md +++ b/libnetwork/vendor/github.com/Azure/go-ansiterm/README.md @@ -7,3 +7,6 @@ For example the parser might receive "ESC, [, A" as a stream of three characters The parser (parser.go) is a partial implementation of this state machine (http://vt100.net/emu/vt500_parser.png). There are also two event handler implementations, one for tests (test_event_handler.go) to validate that the expected events are being produced and called, the other is a Windows implementation (winterm/win_event_handler.go). See parser_test.go for examples exercising the state machine and generating appropriate function calls. + +----- +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/libnetwork/vendor/github.com/Azure/go-ansiterm/parser.go b/libnetwork/vendor/github.com/Azure/go-ansiterm/parser.go index 169f68dbef..3286a9cb5e 100644 --- a/libnetwork/vendor/github.com/Azure/go-ansiterm/parser.go +++ b/libnetwork/vendor/github.com/Azure/go-ansiterm/parser.go @@ -5,7 +5,7 @@ import ( "io/ioutil" "os" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) var logger *logrus.Logger diff --git a/libnetwork/vendor/github.com/Azure/go-ansiterm/winterm/win_event_handler.go b/libnetwork/vendor/github.com/Azure/go-ansiterm/winterm/win_event_handler.go index 4d858ed611..48998bb051 100644 --- a/libnetwork/vendor/github.com/Azure/go-ansiterm/winterm/win_event_handler.go +++ b/libnetwork/vendor/github.com/Azure/go-ansiterm/winterm/win_event_handler.go @@ -9,7 +9,7 @@ import ( "strconv" "github.com/Azure/go-ansiterm" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) var logger *logrus.Logger diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/LICENSE b/libnetwork/vendor/github.com/Microsoft/hcsshim/LICENSE index b8b569d774..49d21669ae 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/LICENSE +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/LICENSE @@ -18,5 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - +SOFTWARE. \ No newline at end of file diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/activatelayer.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/activatelayer.go index efc4d8029c..6d824d7a79 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/activatelayer.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/activatelayer.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // ActivateLayer will find the layer with the given id and mount it's filesystem. // For a read/write layer, the mounted filesystem will appear as a volume on the diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/container.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/container.go index 48a7549704..b924d39f46 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/container.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/container.go @@ -2,12 +2,13 @@ package hcsshim import ( "encoding/json" - "runtime" + "fmt" + "os" "sync" "syscall" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) var ( @@ -15,9 +16,10 @@ var ( ) const ( - pendingUpdatesQuery = `{ "PropertyTypes" : ["PendingUpdates"]}` - statisticsQuery = `{ "PropertyTypes" : ["Statistics"]}` - processListQuery = `{ "PropertyTypes" : ["ProcessList"]}` + pendingUpdatesQuery = `{ "PropertyTypes" : ["PendingUpdates"]}` + statisticsQuery = `{ "PropertyTypes" : ["Statistics"]}` + processListQuery = `{ "PropertyTypes" : ["ProcessList"]}` + mappedVirtualDiskQuery = `{ "PropertyTypes" : ["MappedVirtualDisk"]}` ) type container struct { @@ -29,21 +31,21 @@ type container struct { // ContainerProperties holds the properties for a container and the processes running in that container type ContainerProperties struct { - ID string `json:"Id"` - Name string - SystemType string - Owner string - SiloGUID string `json:"SiloGuid,omitempty"` - IsDummy bool `json:",omitempty"` - RuntimeID string `json:"RuntimeId,omitempty"` - IsRuntimeTemplate bool `json:",omitempty"` - RuntimeImagePath string `json:",omitempty"` - Stopped bool `json:",omitempty"` - ExitType string `json:",omitempty"` - AreUpdatesPending bool `json:",omitempty"` - ObRoot string `json:",omitempty"` - Statistics Statistics `json:",omitempty"` - ProcessList []ProcessListItem `json:",omitempty"` + ID string `json:"Id"` + Name string + SystemType string + Owner string + SiloGUID string `json:"SiloGuid,omitempty"` + RuntimeID string `json:"RuntimeId,omitempty"` + IsRuntimeTemplate bool `json:",omitempty"` + RuntimeImagePath string `json:",omitempty"` + Stopped bool `json:",omitempty"` + ExitType string `json:",omitempty"` + AreUpdatesPending bool `json:",omitempty"` + ObRoot string `json:",omitempty"` + Statistics Statistics `json:",omitempty"` + ProcessList []ProcessListItem `json:",omitempty"` + MappedVirtualDiskControllers map[int]MappedVirtualDiskController `json:",omitempty"` } // MemoryStats holds the memory statistics for a container @@ -103,8 +105,53 @@ type ProcessListItem struct { UserTime100ns uint64 `json:",omitempty"` } +// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container +type MappedVirtualDiskController struct { + MappedVirtualDisks map[int]MappedVirtualDisk `json:",omitempty"` +} + +// Type of Request Support in ModifySystem +type RequestType string + +// Type of Resource Support in ModifySystem +type ResourceType string + +// RequestType const +const ( + Add RequestType = "Add" + Remove RequestType = "Remove" + Network ResourceType = "Network" +) + +// ResourceModificationRequestResponse is the structure used to send request to the container to modify the system +// Supported resource types are Network and Request Types are Add/Remove +type ResourceModificationRequestResponse struct { + Resource ResourceType `json:"ResourceType"` + Data interface{} `json:"Settings"` + Request RequestType `json:"RequestType,omitempty"` +} + +// createContainerAdditionalJSON is read from the environment at initialisation +// time. It allows an environment variable to define additional JSON which +// is merged in the CreateContainer call to HCS. +var createContainerAdditionalJSON string + +func init() { + createContainerAdditionalJSON = os.Getenv("HCSSHIM_CREATECONTAINER_ADDITIONALJSON") +} + // CreateContainer creates a new container with the given configuration but does not start it. func CreateContainer(id string, c *ContainerConfig) (Container, error) { + return createContainerWithJSON(id, c, "") +} + +// CreateContainerWithJSON creates a new container with the given configuration but does not start it. +// It is identical to CreateContainer except that optional additional JSON can be merged before passing to HCS. +func CreateContainerWithJSON(id string, c *ContainerConfig, additionalJSON string) (Container, error) { + return createContainerWithJSON(id, c, additionalJSON) +} + +func createContainerWithJSON(id string, c *ContainerConfig, additionalJSON string) (Container, error) { operation := "CreateContainer" title := "HCSShim::" + operation @@ -120,6 +167,32 @@ func CreateContainer(id string, c *ContainerConfig) (Container, error) { configuration := string(configurationb) logrus.Debugf(title+" id=%s config=%s", id, configuration) + // Merge any additional JSON. Priority is given to what is passed in explicitly, + // falling back to what's set in the environment. + if additionalJSON == "" && createContainerAdditionalJSON != "" { + additionalJSON = createContainerAdditionalJSON + } + if additionalJSON != "" { + configurationMap := map[string]interface{}{} + if err := json.Unmarshal([]byte(configuration), &configurationMap); err != nil { + return nil, fmt.Errorf("failed to unmarshal %s: %s", configuration, err) + } + + additionalMap := map[string]interface{}{} + if err := json.Unmarshal([]byte(additionalJSON), &additionalMap); err != nil { + return nil, fmt.Errorf("failed to unmarshal %s: %s", additionalJSON, err) + } + + mergedMap := mergeMaps(additionalMap, configurationMap) + mergedJSON, err := json.Marshal(mergedMap) + if err != nil { + return nil, fmt.Errorf("failed to marshal merged configuration map %+v: %s", mergedMap, err) + } + + configuration = string(mergedJSON) + logrus.Debugf(title+" id=%s merged config=%s", id, configuration) + } + var ( resultp *uint16 identity syscall.Handle @@ -138,10 +211,36 @@ func CreateContainer(id string, c *ContainerConfig) (Container, error) { } logrus.Debugf(title+" succeeded id=%s handle=%d", id, container.handle) - runtime.SetFinalizer(container, closeContainer) return container, nil } +// mergeMaps recursively merges map `fromMap` into map `ToMap`. Any pre-existing values +// in ToMap are overwritten. Values in fromMap are added to ToMap. +// From http://stackoverflow.com/questions/40491438/merging-two-json-strings-in-golang +func mergeMaps(fromMap, ToMap interface{}) interface{} { + switch fromMap := fromMap.(type) { + case map[string]interface{}: + ToMap, ok := ToMap.(map[string]interface{}) + if !ok { + return fromMap + } + for keyToMap, valueToMap := range ToMap { + if valueFromMap, ok := fromMap[keyToMap]; ok { + fromMap[keyToMap] = mergeMaps(valueFromMap, valueToMap) + } else { + fromMap[keyToMap] = valueToMap + } + } + case nil: + // merge(nil, map[string]interface{...}) -> map[string]interface{...} + ToMap, ok := ToMap.(map[string]interface{}) + if ok { + return ToMap + } + } + return fromMap +} + // OpenContainer opens an existing container by ID. func OpenContainer(id string) (Container, error) { operation := "OpenContainer" @@ -169,7 +268,6 @@ func OpenContainer(id string) (Container, error) { } logrus.Debugf(title+" succeeded id=%s handle=%d", id, handle) - runtime.SetFinalizer(container, closeContainer) return container, nil } @@ -192,6 +290,10 @@ func GetContainers(q ComputeSystemQuery) ([]ContainerProperties, error) { ) err = hcsEnumerateComputeSystems(query, &computeSystemsp, &resultp) err = processHcsResult(err, resultp) + if err != nil { + return nil, err + } + if computeSystemsp == nil { return nil, ErrUnexpectedValue } @@ -392,6 +494,55 @@ func (container *container) ProcessList() ([]ProcessListItem, error) { return properties.ProcessList, nil } +// MappedVirtualDisks returns a map of the controllers and the disks mapped +// to a container. +// +// Example of JSON returned by the query. +//{ +// "Id":"1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3_svm", +// "SystemType":"Container", +// "RuntimeOsType":"Linux", +// "RuntimeId":"00000000-0000-0000-0000-000000000000", +// "State":"Running", +// "MappedVirtualDiskControllers":{ +// "0":{ +// "MappedVirtualDisks":{ +// "2":{ +// "HostPath":"C:\\lcow\\lcow\\scratch\\1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3.vhdx", +// "ContainerPath":"/mnt/gcs/LinuxServiceVM/scratch", +// "Lun":2, +// "CreateInUtilityVM":true +// }, +// "3":{ +// "HostPath":"C:\\lcow\\lcow\\1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3\\sandbox.vhdx", +// "Lun":3, +// "CreateInUtilityVM":true, +// "AttachOnly":true +// } +// } +// } +// } +//} +func (container *container) MappedVirtualDisks() (map[int]MappedVirtualDiskController, error) { + container.handleLock.RLock() + defer container.handleLock.RUnlock() + operation := "MappedVirtualDiskList" + title := "HCSShim::Container::" + operation + logrus.Debugf(title+" id=%s", container.id) + + if container.handle == 0 { + return nil, makeContainerError(container, operation, "", ErrAlreadyClosed) + } + + properties, err := container.properties(mappedVirtualDiskQuery) + if err != nil { + return nil, makeContainerError(container, operation, "", err) + } + + logrus.Debugf(title+" succeeded id=%s", container.id) + return properties.MappedVirtualDiskControllers, nil +} + // Pause pauses the execution of the container. This feature is not enabled in TP5. func (container *container) Pause() error { container.handleLock.RLock() @@ -489,8 +640,7 @@ func (container *container) CreateProcess(c *ProcessConfig) (Process, error) { return nil, makeContainerError(container, operation, "", err) } - logrus.Debugf(title+" succeeded id=%s processid=%s", container.id, process.processID) - runtime.SetFinalizer(process, closeProcess) + logrus.Debugf(title+" succeeded id=%s processid=%d", container.id, process.processID) return process, nil } @@ -527,7 +677,6 @@ func (container *container) OpenProcess(pid int) (Process, error) { } logrus.Debugf(title+" succeeded id=%s processid=%s", container.id, process.processID) - runtime.SetFinalizer(process, closeProcess) return process, nil } @@ -553,17 +702,11 @@ func (container *container) Close() error { } container.handle = 0 - runtime.SetFinalizer(container, nil) logrus.Debugf(title+" succeeded id=%s", container.id) return nil } -// closeContainer wraps container.Close for use by a finalizer -func closeContainer(container *container) { - container.Close() -} - func (container *container) registerCallback() error { context := ¬ifcationWatcherContext{ channels: newChannels(), @@ -620,3 +763,32 @@ func (container *container) unregisterCallback() error { return nil } + +// Modifies the System by sending a request to HCS +func (container *container) Modify(config *ResourceModificationRequestResponse) error { + container.handleLock.RLock() + defer container.handleLock.RUnlock() + operation := "Modify" + title := "HCSShim::Container::" + operation + + if container.handle == 0 { + return makeContainerError(container, operation, "", ErrAlreadyClosed) + } + + requestJSON, err := json.Marshal(config) + if err != nil { + return err + } + + requestString := string(requestJSON) + logrus.Debugf(title+" id=%s request=%s", container.id, requestString) + + var resultp *uint16 + err = hcsModifyComputeSystem(container.handle, requestString, &resultp) + err = processHcsResult(err, resultp) + if err != nil { + return makeContainerError(container, operation, "", err) + } + logrus.Debugf(title+" succeeded id=%s", container.id) + return nil +} diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/createlayer.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/createlayer.go index 9ecffb1cb0..035d9c3947 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/createlayer.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/createlayer.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // CreateLayer creates a new, empty, read-only layer on the filesystem based on // the parent layer provided. diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/createsandboxlayer.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/createsandboxlayer.go index b69c3da368..7a6a8854cf 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/createsandboxlayer.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/createsandboxlayer.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // CreateSandboxLayer creates and populates new read-write layer for use by a container. // This requires both the id of the direct parent layer, as well as the full list diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/deactivatelayer.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/deactivatelayer.go index c02bcb3a0b..fd785030fb 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/deactivatelayer.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/deactivatelayer.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // DeactivateLayer will dismount a layer that was mounted via ActivateLayer. func DeactivateLayer(info DriverInfo, id string) error { diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/destroylayer.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/destroylayer.go index 91ed269eef..b1e3b89fc7 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/destroylayer.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/destroylayer.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // DestroyLayer will remove the on-disk files representing the layer with the given // id, including that layer's containing folder, if any. diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/errors.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/errors.go index 19bb97a05b..d2f9cc8bd2 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/errors.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/errors.go @@ -13,6 +13,13 @@ var ( // ErrElementNotFound is an error encountered when the object being referenced does not exist ErrElementNotFound = syscall.Errno(0x490) + // ErrElementNotFound is an error encountered when the object being referenced does not exist + ErrNotSupported = syscall.Errno(0x32) + + // ErrInvalidData is an error encountered when the request being sent to hcs is invalid/unsupported + // decimal -2147024883 / hex 0x8007000d + ErrInvalidData = syscall.Errno(0xd) + // ErrHandleClose is an error encountered when the handle generating the notification being waited on has been closed ErrHandleClose = errors.New("hcsshim: the handle generating this notification has been closed") @@ -50,6 +57,19 @@ var ( // ErrProcNotFound is an error encountered when the the process cannot be found ErrProcNotFound = syscall.Errno(0x7f) + + // ErrVmcomputeOperationAccessIsDenied is an error which can be encountered when enumerating compute systems in RS1/RS2 + // builds when the underlying silo might be in the process of terminating. HCS was fixed in RS3. + ErrVmcomputeOperationAccessIsDenied = syscall.Errno(0x5) + + // ErrVmcomputeInvalidJSON is an error encountered when the compute system does not support/understand the messages sent by management + ErrVmcomputeInvalidJSON = syscall.Errno(0xc037010d) + + // ErrVmcomputeUnknownMessage is an error encountered guest compute system doesn't support the message + ErrVmcomputeUnknownMessage = syscall.Errno(0xc037010b) + + // ErrNotSupported is an error encountered when hcs doesn't support the request + ErrPlatformNotSupported = errors.New("unsupported platform request") ) // ProcessError is an error encountered in HCS during an operation on a Process object @@ -192,6 +212,20 @@ func IsAlreadyStopped(err error) bool { err == ErrProcNotFound } +// IsNotSupported returns a boolean indicating whether the error is caused by +// unsupported platform requests +// Note: Currently Unsupported platform requests can be mean either +// ErrVmcomputeInvalidJSON, ErrInvalidData, ErrNotSupported or ErrVmcomputeUnknownMessage +// is thrown from the Platform +func IsNotSupported(err error) bool { + err = getInnerError(err) + // If Platform doesn't recognize or support the request sent, below errors are seen + return err == ErrVmcomputeInvalidJSON || + err == ErrInvalidData || + err == ErrNotSupported || + err == ErrVmcomputeUnknownMessage +} + func getInnerError(err error) error { switch pe := err.(type) { case nil: diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/expandsandboxsize.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/expandsandboxsize.go index e168921841..6946c6a84f 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/expandsandboxsize.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/expandsandboxsize.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // ExpandSandboxSize expands the size of a layer to at least size bytes. func ExpandSandboxSize(info DriverInfo, layerId string, size uint64) error { diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/exportlayer.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/exportlayer.go index 903e08519d..d7025f20ba 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/exportlayer.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/exportlayer.go @@ -4,11 +4,10 @@ import ( "io" "io/ioutil" "os" - "runtime" "syscall" "github.com/Microsoft/go-winio" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // ExportLayer will create a folder at exportFolderPath and fill that folder with @@ -143,7 +142,6 @@ func NewLayerReader(info DriverInfo, layerID string, parentLayerPaths []string) if err != nil { return nil, makeError(err, "ExportLayerBegin", "") } - runtime.SetFinalizer(r, func(r *FilterLayerReader) { r.Close() }) return r, err } diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/getlayermountpath.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/getlayermountpath.go index 41b5758926..89f8079d0f 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/getlayermountpath.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/getlayermountpath.go @@ -3,7 +3,7 @@ package hcsshim import ( "syscall" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // GetLayerMountPath will look for a mounted layer with the given id and return diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/getsharedbaseimages.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/getsharedbaseimages.go index 01ab4da3dd..05d3d9532a 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/getsharedbaseimages.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/getsharedbaseimages.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // GetSharedBaseImages will enumerate the images stored in the common central // image store and return descriptive info about those images for the purpose diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/hcsshim.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/hcsshim.go index 3cb3a299ff..236ba1fa30 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/hcsshim.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/hcsshim.go @@ -8,7 +8,7 @@ import ( "syscall" "unsafe" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) //go:generate go run mksyscall_windows.go -output zhcsshim.go hcsshim.go diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsendpoint.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsendpoint.go new file mode 100644 index 0000000000..07c6a7bc36 --- /dev/null +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsendpoint.go @@ -0,0 +1,183 @@ +package hcsshim + +import ( + "encoding/json" + "fmt" + "net" + + "github.com/sirupsen/logrus" +) + +// HNSEndpoint represents a network endpoint in HNS +type HNSEndpoint struct { + Id string `json:"ID,omitempty"` + Name string `json:",omitempty"` + VirtualNetwork string `json:",omitempty"` + VirtualNetworkName string `json:",omitempty"` + Policies []json.RawMessage `json:",omitempty"` + MacAddress string `json:",omitempty"` + IPAddress net.IP `json:",omitempty"` + DNSSuffix string `json:",omitempty"` + DNSServerList string `json:",omitempty"` + GatewayAddress string `json:",omitempty"` + EnableInternalDNS bool `json:",omitempty"` + DisableICC bool `json:",omitempty"` + PrefixLength uint8 `json:",omitempty"` + IsRemoteEndpoint bool `json:",omitempty"` +} + +// HNSEndpointRequest makes a HNS call to modify/query a network endpoint +func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) { + endpoint := &HNSEndpoint{} + err := hnsCall(method, "/endpoints/"+path, request, &endpoint) + if err != nil { + return nil, err + } + + return endpoint, nil +} + +// HNSListEndpointRequest makes a HNS call to query the list of available endpoints +func HNSListEndpointRequest() ([]HNSEndpoint, error) { + var endpoint []HNSEndpoint + err := hnsCall("GET", "/endpoints/", "", &endpoint) + if err != nil { + return nil, err + } + + return endpoint, nil +} + +// HotAttachEndpoint makes a HCS Call to attach the endpoint to the container +func HotAttachEndpoint(containerID string, endpointID string) error { + return modifyNetworkEndpoint(containerID, endpointID, Add) +} + +// HotDetachEndpoint makes a HCS Call to detach the endpoint from the container +func HotDetachEndpoint(containerID string, endpointID string) error { + return modifyNetworkEndpoint(containerID, endpointID, Remove) +} + +// ModifyContainer corresponding to the container id, by sending a request +func modifyContainer(id string, request *ResourceModificationRequestResponse) error { + container, err := OpenContainer(id) + if err != nil { + if IsNotExist(err) { + return ErrComputeSystemDoesNotExist + } + return getInnerError(err) + } + defer container.Close() + err = container.Modify(request) + if err != nil { + if IsNotSupported(err) { + return ErrPlatformNotSupported + } + return getInnerError(err) + } + + return nil +} + +func modifyNetworkEndpoint(containerID string, endpointID string, request RequestType) error { + requestMessage := &ResourceModificationRequestResponse{ + Resource: Network, + Request: request, + Data: endpointID, + } + err := modifyContainer(containerID, requestMessage) + + if err != nil { + return err + } + + return nil +} + +// GetHNSEndpointByID +func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) { + return HNSEndpointRequest("GET", endpointID, "") +} + +// GetHNSNetworkName filtered by Name +func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) { + hnsResponse, err := HNSListEndpointRequest() + if err != nil { + return nil, err + } + for _, hnsEndpoint := range hnsResponse { + if hnsEndpoint.Name == endpointName { + return &hnsEndpoint, nil + } + } + return nil, fmt.Errorf("Endpoint %v not found", endpointName) +} + +// Create Endpoint by sending EndpointRequest to HNS. TODO: Create a separate HNS interface to place all these methods +func (endpoint *HNSEndpoint) Create() (*HNSEndpoint, error) { + operation := "Create" + title := "HCSShim::HNSEndpoint::" + operation + logrus.Debugf(title+" id=%s", endpoint.Id) + + jsonString, err := json.Marshal(endpoint) + if err != nil { + return nil, err + } + return HNSEndpointRequest("POST", "", string(jsonString)) +} + +// Delete Endpoint by sending EndpointRequest to HNS +func (endpoint *HNSEndpoint) Delete() (*HNSEndpoint, error) { + operation := "Delete" + title := "HCSShim::HNSEndpoint::" + operation + logrus.Debugf(title+" id=%s", endpoint.Id) + + return HNSEndpointRequest("DELETE", endpoint.Id, "") +} + +// Delete Endpoint by sending EndpointRequest to HNS +func (endpoint *HNSEndpoint) Update() (*HNSEndpoint, error) { + operation := "Update" + title := "HCSShim::HNSEndpoint::" + operation + logrus.Debugf(title+" id=%s", endpoint.Id) + jsonString, err := json.Marshal(endpoint) + if err != nil { + return nil, err + } + err = hnsCall("POST", "/endpoints/"+endpoint.Id+"/update", string(jsonString), &endpoint) + + return endpoint, err +} + +// Hot Attach an endpoint to a container +func (endpoint *HNSEndpoint) HotAttach(containerID string) error { + operation := "HotAttach" + title := "HCSShim::HNSEndpoint::" + operation + logrus.Debugf(title+" id=%s, containerId=%s", endpoint.Id, containerID) + + return modifyNetworkEndpoint(containerID, endpoint.Id, Add) +} + +// Hot Detach an endpoint from a container +func (endpoint *HNSEndpoint) HotDetach(containerID string) error { + operation := "HotDetach" + title := "HCSShim::HNSEndpoint::" + operation + logrus.Debugf(title+" id=%s, containerId=%s", endpoint.Id, containerID) + + return modifyNetworkEndpoint(containerID, endpoint.Id, Remove) +} + +// Apply Acl Policy on the Endpoint +func (endpoint *HNSEndpoint) ApplyACLPolicy(policy *ACLPolicy) error { + operation := "ApplyACLPolicy" + title := "HCSShim::HNSEndpoint::" + operation + logrus.Debugf(title+" id=%s", endpoint.Id) + + jsonString, err := json.Marshal(policy) + if err != nil { + return err + } + endpoint.Policies[0] = jsonString + _, err = endpoint.Update() + return err +} diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsfuncs.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsfuncs.go index e3d8c0b145..2c1b979ae8 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsfuncs.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsfuncs.go @@ -3,101 +3,14 @@ package hcsshim import ( "encoding/json" "fmt" - "net" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) -type NatPolicy struct { - Type string - Protocol string - InternalPort uint16 - ExternalPort uint16 -} - -type QosPolicy struct { - Type string - MaximumOutgoingBandwidthInBytes uint64 -} - -type VlanPolicy struct { - Type string - VLAN uint -} - -type VsidPolicy struct { - Type string - VSID uint -} - -type PaPolicy struct { - Type string - PA string -} - -// Subnet is assoicated with a network and represents a list -// of subnets available to the network -type Subnet struct { - AddressPrefix string `json:",omitempty"` - GatewayAddress string `json:",omitempty"` - Policies []json.RawMessage `json:",omitempty"` -} - -// MacPool is assoicated with a network and represents a list -// of macaddresses available to the network -type MacPool struct { - StartMacAddress string `json:",omitempty"` - EndMacAddress string `json:",omitempty"` -} - -// HNSNetwork represents a network in HNS -type HNSNetwork struct { - Id string `json:"ID,omitempty"` - Name string `json:",omitempty"` - Type string `json:",omitempty"` - NetworkAdapterName string `json:",omitempty"` - SourceMac string `json:",omitempty"` - Policies []json.RawMessage `json:",omitempty"` - MacPools []MacPool `json:",omitempty"` - Subnets []Subnet `json:",omitempty"` - DNSSuffix string `json:",omitempty"` - DNSServerList string `json:",omitempty"` - DNSServerCompartment uint32 `json:",omitempty"` - ManagementIP string `json:",omitempty"` -} - -// HNSEndpoint represents a network endpoint in HNS -type HNSEndpoint struct { - Id string `json:"ID,omitempty"` - Name string `json:",omitempty"` - VirtualNetwork string `json:",omitempty"` - VirtualNetworkName string `json:",omitempty"` - Policies []json.RawMessage `json:",omitempty"` - MacAddress string `json:",omitempty"` - IPAddress net.IP `json:",omitempty"` - DNSSuffix string `json:",omitempty"` - DNSServerList string `json:",omitempty"` - GatewayAddress string `json:",omitempty"` - EnableInternalDNS bool `json:",omitempty"` - DisableICC bool `json:",omitempty"` - PrefixLength uint8 `json:",omitempty"` - IsRemoteEndpoint bool `json:",omitempty"` -} - -type hnsNetworkResponse struct { - Success bool - Error string - Output HNSNetwork -} - -type hnsResponse struct { - Success bool - Error string - Output json.RawMessage -} - func hnsCall(method, path, request string, returnResponse interface{}) error { var responseBuffer *uint16 + logrus.Debugf("[%s]=>[%s] Request : %s", method, path, request) + err := _hnsCall(method, path, request, &responseBuffer) if err != nil { return makeError(err, "hnsCall ", "") @@ -125,36 +38,3 @@ func hnsCall(method, path, request string, returnResponse interface{}) error { return nil } - -// HNSNetworkRequest makes a call into HNS to update/query a single network -func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) { - var network HNSNetwork - err := hnsCall(method, "/networks/"+path, request, &network) - if err != nil { - return nil, err - } - - return &network, nil -} - -// HNSListNetworkRequest makes a HNS call to query the list of available networks -func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) { - var network []HNSNetwork - err := hnsCall(method, "/networks/"+path, request, &network) - if err != nil { - return nil, err - } - - return network, nil -} - -// HNSEndpointRequest makes a HNS call to modify/query a network endpoint -func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) { - endpoint := &HNSEndpoint{} - err := hnsCall(method, "/endpoints/"+path, request, &endpoint) - if err != nil { - return nil, err - } - - return endpoint, nil -} diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsnetwork.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsnetwork.go new file mode 100644 index 0000000000..3345bfa3f2 --- /dev/null +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnsnetwork.go @@ -0,0 +1,142 @@ +package hcsshim + +import ( + "encoding/json" + "fmt" + "net" + + "github.com/sirupsen/logrus" +) + +// Subnet is assoicated with a network and represents a list +// of subnets available to the network +type Subnet struct { + AddressPrefix string `json:",omitempty"` + GatewayAddress string `json:",omitempty"` + Policies []json.RawMessage `json:",omitempty"` +} + +// MacPool is assoicated with a network and represents a list +// of macaddresses available to the network +type MacPool struct { + StartMacAddress string `json:",omitempty"` + EndMacAddress string `json:",omitempty"` +} + +// HNSNetwork represents a network in HNS +type HNSNetwork struct { + Id string `json:"ID,omitempty"` + Name string `json:",omitempty"` + Type string `json:",omitempty"` + NetworkAdapterName string `json:",omitempty"` + SourceMac string `json:",omitempty"` + Policies []json.RawMessage `json:",omitempty"` + MacPools []MacPool `json:",omitempty"` + Subnets []Subnet `json:",omitempty"` + DNSSuffix string `json:",omitempty"` + DNSServerList string `json:",omitempty"` + DNSServerCompartment uint32 `json:",omitempty"` + ManagementIP string `json:",omitempty"` + AutomaticDNS bool `json:",omitempty"` +} + +type hnsNetworkResponse struct { + Success bool + Error string + Output HNSNetwork +} + +type hnsResponse struct { + Success bool + Error string + Output json.RawMessage +} + +// HNSNetworkRequest makes a call into HNS to update/query a single network +func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) { + var network HNSNetwork + err := hnsCall(method, "/networks/"+path, request, &network) + if err != nil { + return nil, err + } + + return &network, nil +} + +// HNSListNetworkRequest makes a HNS call to query the list of available networks +func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) { + var network []HNSNetwork + err := hnsCall(method, "/networks/"+path, request, &network) + if err != nil { + return nil, err + } + + return network, nil +} + +// GetHNSNetworkByID +func GetHNSNetworkByID(networkID string) (*HNSNetwork, error) { + return HNSNetworkRequest("GET", networkID, "") +} + +// GetHNSNetworkName filtered by Name +func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) { + hsnnetworks, err := HNSListNetworkRequest("GET", "", "") + if err != nil { + return nil, err + } + for _, hnsnetwork := range hsnnetworks { + if hnsnetwork.Name == networkName { + return &hnsnetwork, nil + } + } + return nil, fmt.Errorf("Network %v not found", networkName) +} + +// Create Network by sending NetworkRequest to HNS. +func (network *HNSNetwork) Create() (*HNSNetwork, error) { + operation := "Create" + title := "HCSShim::HNSNetwork::" + operation + logrus.Debugf(title+" id=%s", network.Id) + + jsonString, err := json.Marshal(network) + if err != nil { + return nil, err + } + return HNSNetworkRequest("POST", "", string(jsonString)) +} + +// Delete Network by sending NetworkRequest to HNS +func (network *HNSNetwork) Delete() (*HNSNetwork, error) { + operation := "Delete" + title := "HCSShim::HNSNetwork::" + operation + logrus.Debugf(title+" id=%s", network.Id) + + return HNSNetworkRequest("DELETE", network.Id, "") +} + +// Creates an endpoint on the Network. +func (network *HNSNetwork) NewEndpoint(ipAddress net.IP, macAddress net.HardwareAddr) *HNSEndpoint { + return &HNSEndpoint{ + VirtualNetwork: network.Id, + IPAddress: ipAddress, + MacAddress: string(macAddress), + } +} + +func (network *HNSNetwork) CreateEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) { + operation := "CreateEndpoint" + title := "HCSShim::HNSNetwork::" + operation + logrus.Debugf(title+" id=%s, endpointId=%s", network.Id, endpoint.Id) + + endpoint.VirtualNetwork = network.Id + return endpoint.Create() +} + +func (network *HNSNetwork) CreateRemoteEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) { + operation := "CreateRemoteEndpoint" + title := "HCSShim::HNSNetwork::" + operation + logrus.Debugf(title+" id=%s", network.Id) + endpoint.IsRemoteEndpoint = true + return network.CreateEndpoint(endpoint) +} diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/hnspolicy.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnspolicy.go new file mode 100644 index 0000000000..ecfbf0eda3 --- /dev/null +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnspolicy.go @@ -0,0 +1,95 @@ +package hcsshim + +// Type of Request Support in ModifySystem +type PolicyType string + +// RequestType const +const ( + Nat PolicyType = "NAT" + ACL PolicyType = "ACL" + PA PolicyType = "PA" + VLAN PolicyType = "VLAN" + VSID PolicyType = "VSID" + VNet PolicyType = "VNET" + L2Driver PolicyType = "L2Driver" + Isolation PolicyType = "Isolation" + QOS PolicyType = "QOS" + OutboundNat PolicyType = "OutBoundNAT" + ExternalLoadBalancer PolicyType = "ELB" + Route PolicyType = "ROUTE" +) + +type NatPolicy struct { + Type PolicyType `json:"Type"` + Protocol string + InternalPort uint16 + ExternalPort uint16 +} + +type QosPolicy struct { + Type PolicyType `json:"Type"` + MaximumOutgoingBandwidthInBytes uint64 +} + +type IsolationPolicy struct { + Type PolicyType `json:"Type"` + VLAN uint + VSID uint + InDefaultIsolation bool +} + +type VlanPolicy struct { + Type PolicyType `json:"Type"` + VLAN uint +} + +type VsidPolicy struct { + Type PolicyType `json:"Type"` + VSID uint +} + +type PaPolicy struct { + Type PolicyType `json:"Type"` + PA string `json:"PA"` +} + +type OutboundNatPolicy struct { + Policy + VIP string `json:"VIP,omitempty"` + Exceptions []string `json:"ExceptionList,omitempty"` +} + +type ActionType string +type DirectionType string +type RuleType string + +const ( + Allow ActionType = "Allow" + Block ActionType = "Block" + + In DirectionType = "In" + Out DirectionType = "Out" + + Host RuleType = "Host" + Switch RuleType = "Switch" +) + +type ACLPolicy struct { + Type PolicyType `json:"Type"` + Protocol uint16 + InternalPort uint16 + Action ActionType + Direction DirectionType + LocalAddress string + RemoteAddress string + LocalPort uint16 + RemotePort uint16 + RuleType RuleType `json:"RuleType,omitempty"` + + Priority uint16 + ServiceName string +} + +type Policy struct { + Type PolicyType `json:"Type"` +} diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/hnspolicylist.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnspolicylist.go new file mode 100644 index 0000000000..4f2978f680 --- /dev/null +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/hnspolicylist.go @@ -0,0 +1,187 @@ +package hcsshim + +import ( + "encoding/json" + + "github.com/sirupsen/logrus" +) + +type RoutePolicy struct { + Policy + DestinationPrefix string `json:"DestinationPrefix,omitempty"` + NextHop string `json:"NextHop,omitempty"` + EncapEnabled bool `json:"NeedEncap,omitempty"` +} + +type ELBPolicy struct { + LBPolicy + SourceVIP string `json:"SourceVIP,omitempty"` + VIPs []string `json:"VIPs,omitempty"` + ILB bool `json:"ILB,omitempty"` +} + +type LBPolicy struct { + Policy + Protocol uint16 `json:"Protocol,omitempty"` + InternalPort uint16 + ExternalPort uint16 +} + +type PolicyList struct { + Id string `json:"ID,omitempty"` + EndpointReferences []string `json:"References,omitempty"` + Policies []string `json:"Policies,omitempty"` +} + +// HNSPolicyListRequest makes a call into HNS to update/query a single network +func HNSPolicyListRequest(method, path, request string) (*PolicyList, error) { + var policy PolicyList + err := hnsCall(method, "/policylists/"+path, request, &policy) + if err != nil { + return nil, err + } + + return &policy, nil +} + +func HNSListPolicyListRequest() ([]PolicyList, error) { + var plist []PolicyList + err := hnsCall("GET", "/policylists/", "", &plist) + if err != nil { + return nil, err + } + + return plist, nil +} + +// PolicyListRequest makes a HNS call to modify/query a network endpoint +func PolicyListRequest(method, path, request string) (*PolicyList, error) { + policylist := &PolicyList{} + err := hnsCall(method, "/policylists/"+path, request, &policylist) + if err != nil { + return nil, err + } + + return policylist, nil +} + +// Create PolicyList by sending PolicyListRequest to HNS. +func (policylist *PolicyList) Create() (*PolicyList, error) { + operation := "Create" + title := "HCSShim::PolicyList::" + operation + logrus.Debugf(title+" id=%s", policylist.Id) + jsonString, err := json.Marshal(policylist) + if err != nil { + return nil, err + } + return PolicyListRequest("POST", "", string(jsonString)) +} + +// Create PolicyList by sending PolicyListRequest to HNS +func (policylist *PolicyList) Delete() (*PolicyList, error) { + operation := "Delete" + title := "HCSShim::PolicyList::" + operation + logrus.Debugf(title+" id=%s", policylist.Id) + + return PolicyListRequest("DELETE", policylist.Id, "") +} + +// Add an endpoint to a Policy List +func (policylist *PolicyList) AddEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) { + operation := "AddEndpoint" + title := "HCSShim::PolicyList::" + operation + logrus.Debugf(title+" id=%s, endpointId:%s", policylist.Id, endpoint.Id) + + _, err := policylist.Delete() + if err != nil { + return nil, err + } + + // Add Endpoint to the Existing List + policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id) + + return policylist.Create() +} + +// Remove an endpoint from the Policy List +func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) { + operation := "RemoveEndpoint" + title := "HCSShim::PolicyList::" + operation + logrus.Debugf(title+" id=%s, endpointId:%s", policylist.Id, endpoint.Id) + + _, err := policylist.Delete() + if err != nil { + return nil, err + } + + elementToRemove := "/endpoints/" + endpoint.Id + + var references []string + + for _, endpointReference := range policylist.EndpointReferences { + if endpointReference == elementToRemove { + continue + } + references = append(references, endpointReference) + } + policylist.EndpointReferences = references + return policylist.Create() +} + +// AddLoadBalancer policy list for the specified endpoints +func AddLoadBalancer(endpoints []HNSEndpoint, isILB bool, vip string, protocol uint16, internalPort uint16, externalPort uint16) (*PolicyList, error) { + operation := "AddLoadBalancer" + title := "HCSShim::PolicyList::" + operation + logrus.Debugf(title+" Vip:%s", vip) + + policylist := &PolicyList{} + + elbPolicy := &ELBPolicy{ + VIPs: []string{vip}, + ILB: isILB, + } + elbPolicy.Type = ExternalLoadBalancer + elbPolicy.Protocol = protocol + elbPolicy.InternalPort = internalPort + elbPolicy.ExternalPort = externalPort + + for _, endpoint := range endpoints { + policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id) + } + + jsonString, err := json.Marshal(elbPolicy) + if err != nil { + return nil, err + } + + policylist.Policies[0] = string(jsonString) + return policylist.Create() +} + +// AddLoadBalancer policy list for the specified endpoints +func AddRoute(endpoints []HNSEndpoint, destinationPrefix string, nextHop string, encapEnabled bool) (*PolicyList, error) { + operation := "AddRoute" + title := "HCSShim::PolicyList::" + operation + logrus.Debugf(title+" destinationPrefix:%s", destinationPrefix) + + policylist := &PolicyList{} + + rPolicy := &RoutePolicy{ + DestinationPrefix: destinationPrefix, + NextHop: nextHop, + EncapEnabled: encapEnabled, + } + rPolicy.Type = Route + + for _, endpoint := range endpoints { + policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id) + } + + jsonString, err := json.Marshal(rPolicy) + if err != nil { + return nil, err + } + + policylist.Policies[0] = string(jsonString) + return policylist.Create() +} diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/importlayer.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/importlayer.go index 5f826301e1..3aed14376a 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/importlayer.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/importlayer.go @@ -5,10 +5,9 @@ import ( "io/ioutil" "os" "path/filepath" - "runtime" "github.com/Microsoft/go-winio" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // ImportLayer will take the contents of the folder at importFolderPath and import @@ -209,6 +208,5 @@ func NewLayerWriter(info DriverInfo, layerID string, parentLayerPaths []string) if err != nil { return nil, makeError(err, "ImportLayerStart", "") } - runtime.SetFinalizer(w, func(w *FilterLayerWriter) { w.Close() }) return w, nil } diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/interface.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/interface.go index 000a18c1be..a547dd3136 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/interface.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/interface.go @@ -1,6 +1,7 @@ package hcsshim import ( + "encoding/json" "io" "time" ) @@ -8,16 +9,19 @@ import ( // ProcessConfig is used as both the input of Container.CreateProcess // and to convert the parameters to JSON for passing onto the HCS type ProcessConfig struct { - ApplicationName string - CommandLine string - User string - WorkingDirectory string - Environment map[string]string - EmulateConsole bool - CreateStdInPipe bool - CreateStdOutPipe bool - CreateStdErrPipe bool - ConsoleSize [2]uint + ApplicationName string `json:",omitempty"` + CommandLine string `json:",omitempty"` + CommandArgs []string `json:",omitempty"` // Used by Linux Containers on Windows + User string `json:",omitempty"` + WorkingDirectory string `json:",omitempty"` + Environment map[string]string `json:",omitempty"` + EmulateConsole bool `json:",omitempty"` + CreateStdInPipe bool `json:",omitempty"` + CreateStdOutPipe bool `json:",omitempty"` + CreateStdErrPipe bool `json:",omitempty"` + ConsoleSize [2]uint `json:",omitempty"` + CreateInUtilityVm bool `json:",omitempty"` // Used by Linux Containers on Windows + OCISpecification *json.RawMessage `json:",omitempty"` // Used by Linux Containers on Windows } type Layer struct { @@ -33,38 +37,59 @@ type MappedDir struct { IOPSMaximum uint64 } +type MappedPipe struct { + HostPath string + ContainerPipeName string +} + type HvRuntime struct { - ImagePath string `json:",omitempty"` - SkipTemplate bool `json:",omitempty"` + ImagePath string `json:",omitempty"` + SkipTemplate bool `json:",omitempty"` + LinuxInitrdFile string `json:",omitempty"` // File under ImagePath on host containing an initrd image for starting a Linux utility VM + LinuxKernelFile string `json:",omitempty"` // File under ImagePath on host containing a kernel for starting a Linux utility VM + LinuxBootParameters string `json:",omitempty"` // Additional boot parameters for starting a Linux Utility VM in initrd mode +} + +type MappedVirtualDisk struct { + HostPath string `json:",omitempty"` // Path to VHD on the host + ContainerPath string // Platform-specific mount point path in the container + CreateInUtilityVM bool `json:",omitempty"` + ReadOnly bool `json:",omitempty"` + Cache string `json:",omitempty"` // "" (Unspecified); "Disabled"; "Enabled"; "Private"; "PrivateAllowSharing" + AttachOnly bool `json:",omitempty:` } // ContainerConfig is used as both the input of CreateContainer // and to convert the parameters to JSON for passing onto the HCS type ContainerConfig struct { - SystemType string // HCS requires this to be hard-coded to "Container" - Name string // Name of the container. We use the docker ID. - Owner string // The management platform that created this container - IsDummy bool // Used for development purposes. - VolumePath string `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID} - IgnoreFlushesDuringBoot bool // Optimization hint for container startup in Windows - LayerFolderPath string `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format %root%\windowsfilter\containerID - Layers []Layer // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID - Credentials string `json:",omitempty"` // Credentials information - ProcessorCount uint32 `json:",omitempty"` // Number of processors to assign to the container. - ProcessorWeight uint64 `json:",omitempty"` // CPU Shares 0..10000 on Windows; where 0 will be omitted and HCS will default. - ProcessorMaximum int64 `json:",omitempty"` // CPU maximum usage percent 1..100 - StorageIOPSMaximum uint64 `json:",omitempty"` // Maximum Storage IOPS - StorageBandwidthMaximum uint64 `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second - StorageSandboxSize uint64 `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller - MemoryMaximumInMB int64 `json:",omitempty"` // Maximum memory available to the container in Megabytes - HostName string // Hostname - MappedDirectories []MappedDir // List of mapped directories (volumes/mounts) - SandboxPath string `json:",omitempty"` // Location of unmounted sandbox. Used by Hyper-V containers only. Format %root%\windowsfilter - HvPartition bool // True if it a Hyper-V Container - EndpointList []string // List of networking endpoints to be attached to container - HvRuntime *HvRuntime `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM - Servicing bool // True if this container is for servicing - AllowUnqualifiedDNSQuery bool // True to allow unqualified DNS name resolution + SystemType string // HCS requires this to be hard-coded to "Container" + Name string // Name of the container. We use the docker ID. + Owner string `json:",omitempty"` // The management platform that created this container + VolumePath string `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID} + IgnoreFlushesDuringBoot bool `json:",omitempty"` // Optimization hint for container startup in Windows + LayerFolderPath string `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format %root%\windowsfilter\containerID + Layers []Layer // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID + Credentials string `json:",omitempty"` // Credentials information + ProcessorCount uint32 `json:",omitempty"` // Number of processors to assign to the container. + ProcessorWeight uint64 `json:",omitempty"` // CPU shares (relative weight to other containers with cpu shares). Range is from 1 to 10000. A value of 0 results in default shares. + ProcessorMaximum int64 `json:",omitempty"` // Specifies the portion of processor cycles that this container can use as a percentage times 100. Range is from 1 to 10000. A value of 0 results in no limit. + StorageIOPSMaximum uint64 `json:",omitempty"` // Maximum Storage IOPS + StorageBandwidthMaximum uint64 `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second + StorageSandboxSize uint64 `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller + MemoryMaximumInMB int64 `json:",omitempty"` // Maximum memory available to the container in Megabytes + HostName string `json:",omitempty"` // Hostname + MappedDirectories []MappedDir `json:",omitempty"` // List of mapped directories (volumes/mounts) + MappedPipes []MappedPipe `json:",omitempty"` // List of mapped Windows named pipes + HvPartition bool // True if it a Hyper-V Container + NetworkSharedContainerName string `json:",omitempty"` // Name (ID) of the container that we will share the network stack with. + EndpointList []string `json:",omitempty"` // List of networking endpoints to be attached to container + HvRuntime *HvRuntime `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM + Servicing bool `json:",omitempty"` // True if this container is for servicing + AllowUnqualifiedDNSQuery bool `json:",omitempty"` // True to allow unqualified DNS name resolution + DNSSearchList string `json:",omitempty"` // Comma seperated list of DNS suffixes to use for name resolution + ContainerType string `json:",omitempty"` // "Linux" for Linux containers on Windows. Omitted otherwise. + TerminateOnLastHandleClosed bool `json:",omitempty"` // Should HCS terminate the container once all handles have been closed + MappedVirtualDisks []MappedVirtualDisk `json:",omitempty"` // Array of virtual disks to mount at start } type ComputeSystemQuery struct { @@ -107,6 +132,9 @@ type Container interface { // ProcessList returns details for the processes in a container. ProcessList() ([]ProcessListItem, error) + // MappedVirtualDisks returns virtual disks mapped to a utility VM, indexed by controller + MappedVirtualDisks() (map[int]MappedVirtualDiskController, error) + // CreateProcess launches a new process within the container. CreateProcess(c *ProcessConfig) (Process, error) @@ -115,6 +143,9 @@ type Container interface { // Close cleans up any state associated with the container but does not terminate or wait for it. Close() error + + // Modify the System + Modify(config *ResourceModificationRequestResponse) error } // Process represents a running or exited process. diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/layerexists.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/layerexists.go index 522d95cce4..fe46f404c3 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/layerexists.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/layerexists.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // LayerExists will return true if a layer with the given id exists and is known // to the system. diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/layerutils.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/layerutils.go index 47229d22e5..c0e5503773 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/layerutils.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/layerutils.go @@ -7,7 +7,7 @@ import ( "path/filepath" "syscall" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) /* To pass into syscall, we need a struct matching the following: diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/legacy.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/legacy.go index 11d90a7bdd..85761573ca 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/legacy.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/legacy.go @@ -23,6 +23,13 @@ var mutatedUtilityVMFiles = map[string]bool{ `EFI\Microsoft\Boot\BCD.LOG2`: true, } +const ( + filesPath = `Files` + hivesPath = `Hives` + utilityVMPath = `UtilityVM` + utilityVMFilesPath = `UtilityVM\Files` +) + func openFileOrDir(path string, mode uint32, createDisposition uint32) (file *os.File, err error) { return winio.OpenForBackup(path, mode, syscall.FILE_SHARE_READ, createDisposition) } @@ -44,6 +51,10 @@ func makeLongAbsPath(path string) (string, error) { return `\\?\` + path, nil } +func hasPathPrefix(p, prefix string) bool { + return strings.HasPrefix(p, prefix) && len(p) > len(prefix) && p[len(prefix)] == '\\' +} + type fileEntry struct { path string fi os.FileInfo @@ -83,7 +94,7 @@ func readTombstones(path string) (map[string]([]string), error) { ts := make(map[string]([]string)) for s.Scan() { - t := filepath.Join("Files", s.Text()[1:]) // skip leading `\` + t := filepath.Join(filesPath, s.Text()[1:]) // skip leading `\` dir := filepath.Dir(t) ts[dir] = append(ts[dir], t) } @@ -212,7 +223,7 @@ func (r *legacyLayerReader) Next() (path string, size int64, fileInfo *winio.Fil return } - if fe.fi.IsDir() && strings.HasPrefix(path, `Files\`) { + if fe.fi.IsDir() && hasPathPrefix(path, filesPath) { fe.path += ".$wcidirs$" } @@ -231,14 +242,14 @@ func (r *legacyLayerReader) Next() (path string, size int64, fileInfo *winio.Fil return } - if !strings.HasPrefix(path, `Files\`) { + if !hasPathPrefix(path, filesPath) { size = fe.fi.Size() r.backupReader = winio.NewBackupFileReader(f, false) - if path == "Hives" || path == "Files" { + if path == hivesPath || path == filesPath { // The Hives directory has a non-deterministic file time because of the // nature of the import process. Use the times from System_Delta. var g *os.File - g, err = os.Open(filepath.Join(r.root, `Hives\System_Delta`)) + g, err = os.Open(filepath.Join(r.root, hivesPath, `System_Delta`)) if err != nil { return } @@ -357,7 +368,7 @@ func (w *legacyLayerWriter) init() error { func (w *legacyLayerWriter) initUtilityVM() error { if !w.HasUtilityVM { - err := os.Mkdir(filepath.Join(w.destRoot, `UtilityVM`), 0) + err := os.Mkdir(filepath.Join(w.destRoot, utilityVMPath), 0) if err != nil { return err } @@ -365,7 +376,7 @@ func (w *legacyLayerWriter) initUtilityVM() error { // clone the utility VM from the parent layer into this layer. Use hard // links to avoid unnecessary copying, since most of the files are // immutable. - err = cloneTree(filepath.Join(w.parentRoots[0], `UtilityVM\Files`), filepath.Join(w.destRoot, `UtilityVM\Files`), mutatedUtilityVMFiles) + err = cloneTree(filepath.Join(w.parentRoots[0], utilityVMFilesPath), filepath.Join(w.destRoot, utilityVMFilesPath), mutatedUtilityVMFiles) if err != nil { return fmt.Errorf("cloning the parent utility VM image failed: %s", err) } @@ -490,15 +501,15 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro return err } - if name == `UtilityVM` { + if name == utilityVMPath { return w.initUtilityVM() } - if strings.HasPrefix(name, `UtilityVM\`) { + if hasPathPrefix(name, utilityVMPath) { if !w.HasUtilityVM { return errors.New("missing UtilityVM directory") } - if !strings.HasPrefix(name, `UtilityVM\Files\`) && name != `UtilityVM\Files` { + if !hasPathPrefix(name, utilityVMFilesPath) && name != utilityVMFilesPath { return errors.New("invalid UtilityVM layer") } path := filepath.Join(w.destRoot, name) @@ -585,7 +596,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro return err } - if strings.HasPrefix(name, `Hives\`) { + if hasPathPrefix(name, hivesPath) { w.backupWriter = winio.NewBackupFileWriter(f, false) } else { // The file attributes are written before the stream. @@ -608,22 +619,19 @@ func (w *legacyLayerWriter) AddLink(name string, target string) error { return err } - var requiredPrefix string var roots []string - if prefix := `Files\`; strings.HasPrefix(name, prefix) { - requiredPrefix = prefix + if hasPathPrefix(target, filesPath) { // Look for cross-layer hard link targets in the parent layers, since // nothing is in the destination path yet. roots = w.parentRoots - } else if prefix := `UtilityVM\Files\`; strings.HasPrefix(name, prefix) { - requiredPrefix = prefix + } else if hasPathPrefix(target, utilityVMFilesPath) { // Since the utility VM is fully cloned into the destination path // already, look for cross-layer hard link targets directly in the // destination path. roots = []string{w.destRoot} } - if requiredPrefix == "" || !strings.HasPrefix(target, requiredPrefix) { + if roots == nil || (!hasPathPrefix(name, filesPath) && !hasPathPrefix(name, utilityVMFilesPath)) { return errors.New("invalid hard link in layer") } @@ -657,9 +665,9 @@ func (w *legacyLayerWriter) AddLink(name string, target string) error { } func (w *legacyLayerWriter) Remove(name string) error { - if strings.HasPrefix(name, `Files\`) { - w.tombstones = append(w.tombstones, name[len(`Files\`):]) - } else if strings.HasPrefix(name, `UtilityVM\Files\`) { + if hasPathPrefix(name, filesPath) { + w.tombstones = append(w.tombstones, name[len(filesPath)+1:]) + } else if hasPathPrefix(name, utilityVMFilesPath) { err := w.initUtilityVM() if err != nil { return err diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go index a76bb4414c..82393ca367 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go @@ -57,6 +57,9 @@ import ( "io/ioutil" "log" "os" + "path/filepath" + "runtime" + "sort" "strconv" "strings" "text/template" @@ -65,6 +68,7 @@ import ( var ( filename = flag.String("output", "", "output file name (standard output if omitted)") printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall") + systemDLL = flag.Bool("systemdll", true, "whether all DLLs should be loaded from the Windows system directory") ) func trim(s string) string { @@ -277,7 +281,7 @@ func (r *Rets) SetReturnValuesCode() string { func (r *Rets) useLongHandleErrorCode(retvar string) string { const code = `if %s { if e1 != 0 { - err = error(e1) + err = errnoErr(e1) } else { err = %sEINVAL } @@ -607,7 +611,6 @@ func (f *Fn) IsNotDuplicate() bool { uniqDllFuncName[funcName] = true return true } - return false } @@ -621,8 +624,20 @@ func (f *Fn) HelperName() string { // Source files and functions. type Source struct { - Funcs []*Fn - Files []string + Funcs []*Fn + Files []string + StdLibImports []string + ExternalImports []string +} + +func (src *Source) Import(pkg string) { + src.StdLibImports = append(src.StdLibImports, pkg) + sort.Strings(src.StdLibImports) +} + +func (src *Source) ExternalImport(pkg string) { + src.ExternalImports = append(src.ExternalImports, pkg) + sort.Strings(src.ExternalImports) } // ParseFiles parses files listed in fs and extracts all syscall @@ -632,6 +647,10 @@ func ParseFiles(fs []string) (*Source, error) { src := &Source{ Funcs: make([]*Fn, 0), Files: make([]string, 0), + StdLibImports: []string{ + "unsafe", + }, + ExternalImports: make([]string, 0), } for _, file := range fs { if err := src.ParseFile(file); err != nil { @@ -702,14 +721,81 @@ func (src *Source) ParseFile(path string) error { return nil } +// IsStdRepo returns true if src is part of standard library. +func (src *Source) IsStdRepo() (bool, error) { + if len(src.Files) == 0 { + return false, errors.New("no input files provided") + } + abspath, err := filepath.Abs(src.Files[0]) + if err != nil { + return false, err + } + goroot := runtime.GOROOT() + if runtime.GOOS == "windows" { + abspath = strings.ToLower(abspath) + goroot = strings.ToLower(goroot) + } + sep := string(os.PathSeparator) + if !strings.HasSuffix(goroot, sep) { + goroot += sep + } + return strings.HasPrefix(abspath, goroot), nil +} + // Generate output source file from a source set src. func (src *Source) Generate(w io.Writer) error { + const ( + pkgStd = iota // any package in std library + pkgXSysWindows // x/sys/windows package + pkgOther + ) + isStdRepo, err := src.IsStdRepo() + if err != nil { + return err + } + var pkgtype int + switch { + case isStdRepo: + pkgtype = pkgStd + case packageName == "windows": + // TODO: this needs better logic than just using package name + pkgtype = pkgXSysWindows + default: + pkgtype = pkgOther + } + if *systemDLL { + switch pkgtype { + case pkgStd: + src.Import("internal/syscall/windows/sysdll") + case pkgXSysWindows: + default: + src.ExternalImport("golang.org/x/sys/windows") + } + } + src.ExternalImport("github.com/Microsoft/go-winio") + if packageName != "syscall" { + src.Import("syscall") + } funcMap := template.FuncMap{ "packagename": packagename, "syscalldot": syscalldot, + "newlazydll": func(dll string) string { + arg := "\"" + dll + ".dll\"" + if !*systemDLL { + return syscalldot() + "NewLazyDLL(" + arg + ")" + } + switch pkgtype { + case pkgStd: + return syscalldot() + "NewLazyDLL(sysdll.Add(" + arg + "))" + case pkgXSysWindows: + return "NewLazySystemDLL(" + arg + ")" + default: + return "windows.NewLazySystemDLL(" + arg + ")" + } + }, } t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate)) - err := t.Execute(w, src) + err = t.Execute(w, src) if err != nil { return errors.New("Failed to execute template: " + err.Error()) } @@ -761,12 +847,41 @@ const srcTemplate = ` package {{packagename}} -import "github.com/Microsoft/go-winio" -import "unsafe"{{if syscalldot}} -import "syscall"{{end}} +import ( +{{range .StdLibImports}}"{{.}}" +{{end}} + +{{range .ExternalImports}}"{{.}}" +{{end}} +) var _ unsafe.Pointer +// Do the interface allocations only once for common +// Errno values. +const ( + errnoERROR_IO_PENDING = 997 +) + +var ( + errERROR_IO_PENDING error = {{syscalldot}}Errno(errnoERROR_IO_PENDING) +) + +// errnoErr returns common boxed Errno values, to prevent +// allocations at runtime. +func errnoErr(e {{syscalldot}}Errno) error { + switch e { + case 0: + return nil + case errnoERROR_IO_PENDING: + return errERROR_IO_PENDING + } + // TODO: add more here, after collecting data on the common + // error values see on Windows. (perhaps when running + // all.bat?) + return e +} + var ( {{template "dlls" .}} {{template "funcnames" .}}) @@ -775,7 +890,7 @@ var ( {{/* help functions */}} -{{define "dlls"}}{{range .DLLs}} mod{{.}} = {{syscalldot}}NewLazyDLL("{{.}}.dll") +{{define "dlls"}}{{range .DLLs}} mod{{.}} = {{newlazydll .}} {{end}}{{end}} {{define "funcnames"}}{{range .Funcs}}{{if .IsNotDuplicate}} proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}"){{end}} @@ -802,12 +917,13 @@ func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{ {{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}} +{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}} + {{define "syscallcheck"}}{{if .ConfirmProc}}if {{.Rets.ErrorVarName}} = proc{{.DLLFuncName}}.Find(); {{.Rets.ErrorVarName}} != nil { return } {{end}}{{end}} -{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}} {{define "seterror"}}{{if .Rets.SetErrorCode}} {{.Rets.SetErrorCode}} {{end}}{{end}} diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/nametoguid.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/nametoguid.go index 1a522f95e0..b7c6d020c6 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/nametoguid.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/nametoguid.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // NameToGuid converts the given string into a GUID using the algorithm in the // Host Compute Service, ensuring GUIDs generated with the same string are common diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/preparelayer.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/preparelayer.go index 2791683467..5c5b618411 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/preparelayer.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/preparelayer.go @@ -3,7 +3,7 @@ package hcsshim import ( "sync" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) var prepareLayerLock sync.Mutex diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/process.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/process.go index af3fab3526..faee2cfeeb 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/process.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/process.go @@ -3,12 +3,11 @@ package hcsshim import ( "encoding/json" "io" - "runtime" "sync" "syscall" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // ContainerError is an error encountered in HCS @@ -322,17 +321,11 @@ func (process *process) Close() error { } process.handle = 0 - runtime.SetFinalizer(process, nil) logrus.Debugf(title+" succeeded processid=%d", process.processID) return nil } -// closeProcess wraps process.Close for use by a finalizer -func closeProcess(process *process) { - process.Close() -} - func (process *process) registerCallback() error { context := ¬ifcationWatcherContext{ channels: newChannels(), diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/unpreparelayer.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/unpreparelayer.go index d0ead0bdda..e8a3b507bf 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/unpreparelayer.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/unpreparelayer.go @@ -1,6 +1,6 @@ package hcsshim -import "github.com/Sirupsen/logrus" +import "github.com/sirupsen/logrus" // UnprepareLayer disables the filesystem filter for the read-write layer with // the given id. diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/waithelper.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/waithelper.go index 89c94616ad..b7be20ea0c 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/waithelper.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/waithelper.go @@ -3,7 +3,7 @@ package hcsshim import ( "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) func processAsyncHcsResult(err error, resultp *uint16, callbackNumber uintptr, expectedNotification hcsNotification, timeout *time.Duration) error { @@ -59,4 +59,5 @@ func waitForNotification(callbackNumber uintptr, expectedNotification hcsNotific case <-c: return ErrTimeout } + return nil } diff --git a/libnetwork/vendor/github.com/Microsoft/hcsshim/zhcsshim.go b/libnetwork/vendor/github.com/Microsoft/hcsshim/zhcsshim.go index 7c3b7bdf5f..5d1a851ae8 100644 --- a/libnetwork/vendor/github.com/Microsoft/hcsshim/zhcsshim.go +++ b/libnetwork/vendor/github.com/Microsoft/hcsshim/zhcsshim.go @@ -2,16 +2,45 @@ package hcsshim -import "github.com/Microsoft/go-winio" -import "unsafe" -import "syscall" +import ( + "syscall" + "unsafe" + + "github.com/Microsoft/go-winio" + "golang.org/x/sys/windows" +) var _ unsafe.Pointer +// Do the interface allocations only once for common +// Errno values. +const ( + errnoERROR_IO_PENDING = 997 +) + var ( - modole32 = syscall.NewLazyDLL("ole32.dll") - modiphlpapi = syscall.NewLazyDLL("iphlpapi.dll") - modvmcompute = syscall.NewLazyDLL("vmcompute.dll") + errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) +) + +// errnoErr returns common boxed Errno values, to prevent +// allocations at runtime. +func errnoErr(e syscall.Errno) error { + switch e { + case 0: + return nil + case errnoERROR_IO_PENDING: + return errERROR_IO_PENDING + } + // TODO: add more here, after collecting data on the common + // error values see on Windows. (perhaps when running + // all.bat?) + return e +} + +var ( + modole32 = windows.NewLazySystemDLL("ole32.dll") + modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll") + modvmcompute = windows.NewLazySystemDLL("vmcompute.dll") procCoTaskMemFree = modole32.NewProc("CoTaskMemFree") procSetCurrentThreadCompartmentId = modiphlpapi.NewProc("SetCurrentThreadCompartmentId") diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/json_formatter.go b/libnetwork/vendor/github.com/Sirupsen/logrus/json_formatter.go deleted file mode 100644 index 2ad6dc5cf4..0000000000 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/json_formatter.go +++ /dev/null @@ -1,41 +0,0 @@ -package logrus - -import ( - "encoding/json" - "fmt" -) - -type JSONFormatter struct { - // TimestampFormat sets the format used for marshaling timestamps. - TimestampFormat string -} - -func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { - data := make(Fields, len(entry.Data)+3) - for k, v := range entry.Data { - switch v := v.(type) { - case error: - // Otherwise errors are ignored by `encoding/json` - // https://github.com/Sirupsen/logrus/issues/137 - data[k] = v.Error() - default: - data[k] = v - } - } - prefixFieldClashes(data) - - timestampFormat := f.TimestampFormat - if timestampFormat == "" { - timestampFormat = DefaultTimestampFormat - } - - data["time"] = entry.Time.Format(timestampFormat) - data["msg"] = entry.Message - data["level"] = entry.Level.String() - - serialized, err := json.Marshal(data) - if err != nil { - return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) - } - return append(serialized, '\n'), nil -} diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/logger.go b/libnetwork/vendor/github.com/Sirupsen/logrus/logger.go deleted file mode 100644 index 2fdb231761..0000000000 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/logger.go +++ /dev/null @@ -1,212 +0,0 @@ -package logrus - -import ( - "io" - "os" - "sync" -) - -type Logger struct { - // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a - // file, or leave it default which is `os.Stderr`. You can also set this to - // something more adventorous, such as logging to Kafka. - Out io.Writer - // Hooks for the logger instance. These allow firing events based on logging - // levels and log entries. For example, to send errors to an error tracking - // service, log to StatsD or dump the core on fatal errors. - Hooks LevelHooks - // All log entries pass through the formatter before logged to Out. The - // included formatters are `TextFormatter` and `JSONFormatter` for which - // TextFormatter is the default. In development (when a TTY is attached) it - // logs with colors, but to a file it wouldn't. You can easily implement your - // own that implements the `Formatter` interface, see the `README` or included - // formatters for examples. - Formatter Formatter - // The logging level the logger should log at. This is typically (and defaults - // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be - // logged. `logrus.Debug` is useful in - Level Level - // Used to sync writing to the log. - mu sync.Mutex -} - -// Creates a new logger. Configuration should be set by changing `Formatter`, -// `Out` and `Hooks` directly on the default logger instance. You can also just -// instantiate your own: -// -// var log = &Logger{ -// Out: os.Stderr, -// Formatter: new(JSONFormatter), -// Hooks: make(LevelHooks), -// Level: logrus.DebugLevel, -// } -// -// It's recommended to make this a global instance called `log`. -func New() *Logger { - return &Logger{ - Out: os.Stderr, - Formatter: new(TextFormatter), - Hooks: make(LevelHooks), - Level: InfoLevel, - } -} - -// Adds a field to the log entry, note that you it doesn't log until you call -// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry. -// If you want multiple fields, use `WithFields`. -func (logger *Logger) WithField(key string, value interface{}) *Entry { - return NewEntry(logger).WithField(key, value) -} - -// Adds a struct of fields to the log entry. All it does is call `WithField` for -// each `Field`. -func (logger *Logger) WithFields(fields Fields) *Entry { - return NewEntry(logger).WithFields(fields) -} - -// Add an error as single field to the log entry. All it does is call -// `WithError` for the given `error`. -func (logger *Logger) WithError(err error) *Entry { - return NewEntry(logger).WithError(err) -} - -func (logger *Logger) Debugf(format string, args ...interface{}) { - if logger.Level >= DebugLevel { - NewEntry(logger).Debugf(format, args...) - } -} - -func (logger *Logger) Infof(format string, args ...interface{}) { - if logger.Level >= InfoLevel { - NewEntry(logger).Infof(format, args...) - } -} - -func (logger *Logger) Printf(format string, args ...interface{}) { - NewEntry(logger).Printf(format, args...) -} - -func (logger *Logger) Warnf(format string, args ...interface{}) { - if logger.Level >= WarnLevel { - NewEntry(logger).Warnf(format, args...) - } -} - -func (logger *Logger) Warningf(format string, args ...interface{}) { - if logger.Level >= WarnLevel { - NewEntry(logger).Warnf(format, args...) - } -} - -func (logger *Logger) Errorf(format string, args ...interface{}) { - if logger.Level >= ErrorLevel { - NewEntry(logger).Errorf(format, args...) - } -} - -func (logger *Logger) Fatalf(format string, args ...interface{}) { - if logger.Level >= FatalLevel { - NewEntry(logger).Fatalf(format, args...) - } - os.Exit(1) -} - -func (logger *Logger) Panicf(format string, args ...interface{}) { - if logger.Level >= PanicLevel { - NewEntry(logger).Panicf(format, args...) - } -} - -func (logger *Logger) Debug(args ...interface{}) { - if logger.Level >= DebugLevel { - NewEntry(logger).Debug(args...) - } -} - -func (logger *Logger) Info(args ...interface{}) { - if logger.Level >= InfoLevel { - NewEntry(logger).Info(args...) - } -} - -func (logger *Logger) Print(args ...interface{}) { - NewEntry(logger).Info(args...) -} - -func (logger *Logger) Warn(args ...interface{}) { - if logger.Level >= WarnLevel { - NewEntry(logger).Warn(args...) - } -} - -func (logger *Logger) Warning(args ...interface{}) { - if logger.Level >= WarnLevel { - NewEntry(logger).Warn(args...) - } -} - -func (logger *Logger) Error(args ...interface{}) { - if logger.Level >= ErrorLevel { - NewEntry(logger).Error(args...) - } -} - -func (logger *Logger) Fatal(args ...interface{}) { - if logger.Level >= FatalLevel { - NewEntry(logger).Fatal(args...) - } - os.Exit(1) -} - -func (logger *Logger) Panic(args ...interface{}) { - if logger.Level >= PanicLevel { - NewEntry(logger).Panic(args...) - } -} - -func (logger *Logger) Debugln(args ...interface{}) { - if logger.Level >= DebugLevel { - NewEntry(logger).Debugln(args...) - } -} - -func (logger *Logger) Infoln(args ...interface{}) { - if logger.Level >= InfoLevel { - NewEntry(logger).Infoln(args...) - } -} - -func (logger *Logger) Println(args ...interface{}) { - NewEntry(logger).Println(args...) -} - -func (logger *Logger) Warnln(args ...interface{}) { - if logger.Level >= WarnLevel { - NewEntry(logger).Warnln(args...) - } -} - -func (logger *Logger) Warningln(args ...interface{}) { - if logger.Level >= WarnLevel { - NewEntry(logger).Warnln(args...) - } -} - -func (logger *Logger) Errorln(args ...interface{}) { - if logger.Level >= ErrorLevel { - NewEntry(logger).Errorln(args...) - } -} - -func (logger *Logger) Fatalln(args ...interface{}) { - if logger.Level >= FatalLevel { - NewEntry(logger).Fatalln(args...) - } - os.Exit(1) -} - -func (logger *Logger) Panicln(args ...interface{}) { - if logger.Level >= PanicLevel { - NewEntry(logger).Panicln(args...) - } -} diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_solaris.go b/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_solaris.go deleted file mode 100644 index 3e70bf7bf0..0000000000 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_solaris.go +++ /dev/null @@ -1,15 +0,0 @@ -// +build solaris - -package logrus - -import ( - "os" - - "golang.org/x/sys/unix" -) - -// IsTerminal returns true if the given file descriptor is a terminal. -func IsTerminal() bool { - _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) - return err == nil -} diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_windows.go b/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_windows.go deleted file mode 100644 index 0146845d16..0000000000 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_windows.go +++ /dev/null @@ -1,27 +0,0 @@ -// Based on ssh/terminal: -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build windows - -package logrus - -import ( - "syscall" - "unsafe" -) - -var kernel32 = syscall.NewLazyDLL("kernel32.dll") - -var ( - procGetConsoleMode = kernel32.NewProc("GetConsoleMode") -) - -// IsTerminal returns true if stderr's file descriptor is a terminal. -func IsTerminal() bool { - fd := syscall.Stderr - var st uint32 - r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) - return r != 0 && e == 0 -} diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/writer.go b/libnetwork/vendor/github.com/Sirupsen/logrus/writer.go deleted file mode 100644 index 1e30b1c753..0000000000 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/writer.go +++ /dev/null @@ -1,31 +0,0 @@ -package logrus - -import ( - "bufio" - "io" - "runtime" -) - -func (logger *Logger) Writer() *io.PipeWriter { - reader, writer := io.Pipe() - - go logger.writerScanner(reader) - runtime.SetFinalizer(writer, writerFinalizer) - - return writer -} - -func (logger *Logger) writerScanner(reader *io.PipeReader) { - scanner := bufio.NewScanner(reader) - for scanner.Scan() { - logger.Print(scanner.Text()) - } - if err := scanner.Err(); err != nil { - logger.Errorf("Error while reading from Writer: %s", err) - } - reader.Close() -} - -func writerFinalizer(writer *io.PipeWriter) { - writer.Close() -} diff --git a/libnetwork/vendor/github.com/docker/docker/pkg/discovery/backends.go b/libnetwork/vendor/github.com/docker/docker/pkg/discovery/backends.go index 2eab550e29..a25b86c3e6 100644 --- a/libnetwork/vendor/github.com/docker/docker/pkg/discovery/backends.go +++ b/libnetwork/vendor/github.com/docker/docker/pkg/discovery/backends.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) var ( diff --git a/libnetwork/vendor/github.com/docker/docker/pkg/discovery/kv/kv.go b/libnetwork/vendor/github.com/docker/docker/pkg/discovery/kv/kv.go index 77eee7d454..e860b369e7 100644 --- a/libnetwork/vendor/github.com/docker/docker/pkg/discovery/kv/kv.go +++ b/libnetwork/vendor/github.com/docker/docker/pkg/discovery/kv/kv.go @@ -6,7 +6,6 @@ import ( "strings" "time" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/discovery" "github.com/docker/go-connections/tlsconfig" "github.com/docker/libkv" @@ -14,6 +13,7 @@ import ( "github.com/docker/libkv/store/consul" "github.com/docker/libkv/store/etcd" "github.com/docker/libkv/store/zookeeper" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/vendor/github.com/docker/docker/pkg/parsers/kernel/kernel_unix.go b/libnetwork/vendor/github.com/docker/docker/pkg/parsers/kernel/kernel_unix.go index 744d5e1f83..1855f75a84 100644 --- a/libnetwork/vendor/github.com/docker/docker/pkg/parsers/kernel/kernel_unix.go +++ b/libnetwork/vendor/github.com/docker/docker/pkg/parsers/kernel/kernel_unix.go @@ -7,7 +7,7 @@ package kernel import ( "bytes" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // GetKernelVersion gets the current kernel version. diff --git a/libnetwork/vendor/github.com/docker/docker/pkg/plugins/client.go b/libnetwork/vendor/github.com/docker/docker/pkg/plugins/client.go index e8e730eb58..53a4326c49 100644 --- a/libnetwork/vendor/github.com/docker/docker/pkg/plugins/client.go +++ b/libnetwork/vendor/github.com/docker/docker/pkg/plugins/client.go @@ -9,10 +9,10 @@ import ( "net/url" "time" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/plugins/transport" "github.com/docker/go-connections/sockets" "github.com/docker/go-connections/tlsconfig" + "github.com/sirupsen/logrus" ) const ( diff --git a/libnetwork/vendor/github.com/docker/docker/pkg/plugins/plugins.go b/libnetwork/vendor/github.com/docker/docker/pkg/plugins/plugins.go index 861daa3207..933c1b2716 100644 --- a/libnetwork/vendor/github.com/docker/docker/pkg/plugins/plugins.go +++ b/libnetwork/vendor/github.com/docker/docker/pkg/plugins/plugins.go @@ -27,8 +27,8 @@ import ( "sync" "time" - "github.com/Sirupsen/logrus" "github.com/docker/go-connections/tlsconfig" + "github.com/sirupsen/logrus" ) var ( diff --git a/libnetwork/vendor/github.com/docker/docker/pkg/signal/trap.go b/libnetwork/vendor/github.com/docker/docker/pkg/signal/trap.go index 638a1ab66c..172bc1064f 100644 --- a/libnetwork/vendor/github.com/docker/docker/pkg/signal/trap.go +++ b/libnetwork/vendor/github.com/docker/docker/pkg/signal/trap.go @@ -11,8 +11,8 @@ import ( "syscall" "time" - "github.com/Sirupsen/logrus" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) // Trap sets up a simplified signal "trap", appropriate for common diff --git a/libnetwork/vendor/github.com/docker/docker/pkg/system/syscall_windows.go b/libnetwork/vendor/github.com/docker/docker/pkg/system/syscall_windows.go index 1f311874f4..09be33ab82 100644 --- a/libnetwork/vendor/github.com/docker/docker/pkg/system/syscall_windows.go +++ b/libnetwork/vendor/github.com/docker/docker/pkg/system/syscall_windows.go @@ -4,7 +4,7 @@ import ( "syscall" "unsafe" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) var ( diff --git a/libnetwork/vendor/github.com/docker/docker/pkg/term/windows/windows.go b/libnetwork/vendor/github.com/docker/docker/pkg/term/windows/windows.go index ce4cb5990e..58331c4834 100644 --- a/libnetwork/vendor/github.com/docker/docker/pkg/term/windows/windows.go +++ b/libnetwork/vendor/github.com/docker/docker/pkg/term/windows/windows.go @@ -10,7 +10,7 @@ import ( "sync" ansiterm "github.com/Azure/go-ansiterm" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) var logger *logrus.Logger diff --git a/libnetwork/vendor/github.com/docker/docker/vendor.conf b/libnetwork/vendor/github.com/docker/docker/vendor.conf new file mode 100644 index 0000000000..b2276f549a --- /dev/null +++ b/libnetwork/vendor/github.com/docker/docker/vendor.conf @@ -0,0 +1,142 @@ +# the following lines are in sorted order, FYI +github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62 +github.com/Microsoft/hcsshim v0.5.9 +github.com/Microsoft/go-winio v0.3.7 +github.com/Sirupsen/logrus v0.11.0 +github.com/davecgh/go-spew 6d212800a42e8ab5c146b8ace3490ee17e5225f9 +github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a +github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git +github.com/gorilla/context v1.1 +github.com/gorilla/mux v1.1 +github.com/kr/pty 5cf931ef8f +github.com/mattn/go-shellwords v1.0.0 +github.com/mattn/go-sqlite3 v1.1.0 +github.com/tchap/go-patricia v2.2.6 +github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 +# forked golang.org/x/net package includes a patch for lazy loading trace templates +golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://github.com/tonistiigi/net.git +golang.org/x/sys 8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9 +github.com/docker/go-units e30f1e79f3cd72542f2026ceec18d3bd67ab859c +github.com/docker/go-connections 4ccf312bf1d35e5dbda654e57a9be4c3f3cd0366 + +github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5 +github.com/imdario/mergo 0.2.1 + +#get libnetwork packages +github.com/docker/libnetwork 382be38ce860738d80b53d7875d83abd5970d9d6 https://github.com/aaronlehmann/libnetwork +github.com/docker/go-events 18b43f1bc85d9cdd42c05a6cd2d444c7a200a894 +github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 +github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec +github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b +github.com/hashicorp/memberlist 88ac4de0d1a0ca6def284b571342db3b777a4c37 +github.com/hashicorp/go-multierror fcdddc395df1ddf4247c69bd436e84cfa0733f7e +github.com/hashicorp/serf 598c54895cc5a7b1a24a398d635e8c0ea0959870 +github.com/docker/libkv 1d8431073ae03cdaedb198a89722f3aab6d418ef +github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25 +github.com/vishvananda/netlink 482f7a52b758233521878cb6c5904b6bd63f3457 +github.com/BurntSushi/toml f706d00e3de6abe700c994cdd545a1a4915af060 +github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374 +github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d +github.com/coreos/etcd 3a49cbb769ebd8d1dd25abb1e83386e9883a5707 +github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065 +github.com/hashicorp/consul v0.5.2 +github.com/boltdb/bolt fff57c100f4dea1905678da7e90d92429dff2904 +github.com/miekg/dns 75e6e86cc601825c5dbcd4e0c209eab180997cd7 + +# get graph and distribution packages +github.com/docker/distribution 7dba427612198a11b161a27f9d40bb2dca1ccd20 +github.com/vbatts/tar-split v0.10.1 +github.com/opencontainers/go-digest a6d0ee40d4207ea02364bd3b9e8e77b9159ba1eb + +# get go-zfs packages +github.com/mistifyio/go-zfs 22c9b32c84eb0d0c6f4043b6e90fc94073de92fa +github.com/pborman/uuid v1.0 + +# get desired notary commit, might also need to be updated in Dockerfile +github.com/docker/notary v0.4.2 + +google.golang.org/grpc v1.0.2 +github.com/miekg/pkcs11 df8ae6ca730422dba20c768ff38ef7d79077a59f +github.com/docker/go v1.5.1-1-1-gbaf439e +github.com/agl/ed25519 d2b94fd789ea21d12fac1a4443dd3a3f79cda72c + +github.com/opencontainers/runc 51371867a01c467f08af739783b8beafc15 # libcontainer +github.com/opencontainers/runtime-spec 1c7c27d043c2a5e513a44084d2b10d77d1402b8c # specs +github.com/seccomp/libseccomp-golang 32f571b70023028bd57d9288c20efbcb237f3ce0 +# libcontainer deps (see src/github.com/opencontainers/runc/Godeps/Godeps.json) +github.com/coreos/go-systemd v4 +github.com/godbus/dbus v4.0.0 +github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852 +github.com/golang/protobuf 1f49d83d9aa00e6ce4fc8258c71cc7786aec968a + +# gelf logging driver deps +github.com/Graylog2/go-gelf aab2f594e4585d43468ac57287b0dece9d806883 + +github.com/fluent/fluent-logger-golang v1.2.1 +# fluent-logger-golang deps +github.com/philhofer/fwd 899e4efba8eaa1fea74175308f3fae18ff3319fa +github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c + +# fsnotify +github.com/fsnotify/fsnotify v1.2.11 + +# awslogs deps +github.com/aws/aws-sdk-go v1.4.22 +github.com/go-ini/ini 060d7da055ba6ec5ea7a31f116332fe5efa04ce0 +github.com/jmespath/go-jmespath 0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74 + +# logentries +github.com/bsphere/le_go d3308aafe090956bc89a65f0769f58251a1b4f03 + +# gcplogs deps +golang.org/x/oauth2 96382aa079b72d8c014eb0c50f6c223d1e6a2de0 +google.golang.org/api 3cc2e591b550923a2c5f0ab5a803feda924d5823 +cloud.google.com/go 9d965e63e8cceb1b5d7977a202f0fcb8866d6525 +github.com/googleapis/gax-go da06d194a00e19ce00d9011a13931c3f6f6887c7 +google.golang.org/genproto 9359a8d303c45e3212571b77610f1cefb0c6f3eb + +# native credentials +github.com/docker/docker-credential-helpers f72c04f1d8e71959a6d103f808c50ccbad79b9fd + +# containerd +github.com/docker/containerd 03e5862ec0d8d3b3f750e19fca3ee367e13c090e +github.com/tonistiigi/fifo 1405643975692217d6720f8b54aeee1bf2cd5cf4 + +# cluster +github.com/docker/swarmkit 4762d92234d286ae7c9e061470485e4d34ef8ebd +github.com/golang/mock bd3c8e81be01eef76d4b503f5e687d2d1354d2d9 +github.com/gogo/protobuf v0.3 +github.com/cloudflare/cfssl 7fb22c8cba7ecaf98e4082d22d65800cf45e042a +github.com/google/certificate-transparency d90e65c3a07988180c5b1ece71791c0b6506826e +golang.org/x/crypto 3fbbcd23f1cb824e69491a5930cfeff09b12f4d2 +golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb +github.com/mreiferson/go-httpclient 63fe23f7434723dc904c901043af07931f293c47 +github.com/hashicorp/go-memdb 608dda3b1410a73eaf3ac8b517c9ae7ebab6aa87 +github.com/hashicorp/go-immutable-radix 8e8ed81f8f0bf1bdd829593fdd5c29922c1ea990 +github.com/hashicorp/golang-lru a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4 +github.com/coreos/pkg fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8 +github.com/pivotal-golang/clock 3fd3c1944c59d9742e1cd333672181cd1a6f9fa0 +github.com/prometheus/client_golang 52437c81da6b127a9925d17eb3a382a2e5fd395e +github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 +github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6 +github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8 +github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5 +bitbucket.org/ww/goautoneg 75cd24fc2f2c2a2088577d12123ddee5f54e0675 +github.com/matttproud/golang_protobuf_extensions fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a +github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9 + +# cli +github.com/spf13/cobra v1.5 https://github.com/dnephin/cobra.git +github.com/spf13/pflag dabebe21bf790f782ea4c7bbd2efc430de182afd +github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 +github.com/flynn-archive/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff + +# metrics +github.com/docker/go-metrics 86138d05f285fd9737a99bee2d9be30866b59d72 + +# composefile +github.com/mitchellh/mapstructure f3009df150dadf309fdee4a54ed65c124afad715 +github.com/xeipuuv/gojsonpointer e0fe6f68307607d540ed8eac07a342c33fa1b54a +github.com/xeipuuv/gojsonreference e02fc20de94c78484cd5ffb007f8af96be030a45 +github.com/xeipuuv/gojsonschema 93e72a773fade158921402d6a24c819b48aba29d +gopkg.in/yaml.v2 a83829b6f1293c91addabc89d0571c246397bbf4 diff --git a/libnetwork/vendor/github.com/docker/go-connections/nat/nat.go b/libnetwork/vendor/github.com/docker/go-connections/nat/nat.go index 3d469165ab..4d5f5ae63a 100644 --- a/libnetwork/vendor/github.com/docker/go-connections/nat/nat.go +++ b/libnetwork/vendor/github.com/docker/go-connections/nat/nat.go @@ -85,14 +85,10 @@ func (p Port) Port() string { // Int returns the port number of a Port as an int func (p Port) Int() int { portStr := p.Port() - if len(portStr) == 0 { - return 0 - } - // We don't need to check for an error because we're going to // assume that any error would have been found, and reported, in NewPort() - port, _ := strconv.ParseUint(portStr, 10, 16) - return int(port) + port, _ := ParsePort(portStr) + return port } // Range returns the start/end port numbers of a Port range as ints @@ -132,92 +128,115 @@ func ParsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding, exposedPorts = make(map[Port]struct{}, len(ports)) bindings = make(map[Port][]PortBinding) ) - for _, rawPort := range ports { - proto := "tcp" - - if i := strings.LastIndex(rawPort, "/"); i != -1 { - proto = rawPort[i+1:] - rawPort = rawPort[:i] - } - if !strings.Contains(rawPort, ":") { - rawPort = fmt.Sprintf("::%s", rawPort) - } else if len(strings.Split(rawPort, ":")) == 2 { - rawPort = fmt.Sprintf(":%s", rawPort) - } - - parts, err := PartParser(portSpecTemplate, rawPort) + portMappings, err := ParsePortSpec(rawPort) if err != nil { return nil, nil, err } - var ( - containerPort = parts["containerPort"] - rawIP = parts["ip"] - hostPort = parts["hostPort"] - ) - - if rawIP != "" && net.ParseIP(rawIP) == nil { - return nil, nil, fmt.Errorf("Invalid ip address: %s", rawIP) - } - if containerPort == "" { - return nil, nil, fmt.Errorf("No port specified: %s", rawPort) - } - - startPort, endPort, err := ParsePortRange(containerPort) - if err != nil { - return nil, nil, fmt.Errorf("Invalid containerPort: %s", containerPort) - } - - var startHostPort, endHostPort uint64 = 0, 0 - if len(hostPort) > 0 { - startHostPort, endHostPort, err = ParsePortRange(hostPort) - if err != nil { - return nil, nil, fmt.Errorf("Invalid hostPort: %s", hostPort) - } - } - - if hostPort != "" && (endPort-startPort) != (endHostPort-startHostPort) { - // Allow host port range iff containerPort is not a range. - // In this case, use the host port range as the dynamic - // host port range to allocate into. - if endPort != startPort { - return nil, nil, fmt.Errorf("Invalid ranges specified for container and host Ports: %s and %s", containerPort, hostPort) - } - } - - if !validateProto(strings.ToLower(proto)) { - return nil, nil, fmt.Errorf("Invalid proto: %s", proto) - } - - for i := uint64(0); i <= (endPort - startPort); i++ { - containerPort = strconv.FormatUint(startPort+i, 10) - if len(hostPort) > 0 { - hostPort = strconv.FormatUint(startHostPort+i, 10) - } - // Set hostPort to a range only if there is a single container port - // and a dynamic host port. - if startPort == endPort && startHostPort != endHostPort { - hostPort = fmt.Sprintf("%s-%s", hostPort, strconv.FormatUint(endHostPort, 10)) - } - port, err := NewPort(strings.ToLower(proto), containerPort) - if err != nil { - return nil, nil, err - } + for _, portMapping := range portMappings { + port := portMapping.Port if _, exists := exposedPorts[port]; !exists { exposedPorts[port] = struct{}{} } - - binding := PortBinding{ - HostIP: rawIP, - HostPort: hostPort, - } bslice, exists := bindings[port] if !exists { bslice = []PortBinding{} } - bindings[port] = append(bslice, binding) + bindings[port] = append(bslice, portMapping.Binding) } } return exposedPorts, bindings, nil } + +// PortMapping is a data object mapping a Port to a PortBinding +type PortMapping struct { + Port Port + Binding PortBinding +} + +func splitParts(rawport string) (string, string, string) { + parts := strings.Split(rawport, ":") + n := len(parts) + containerport := parts[n-1] + + switch n { + case 1: + return "", "", containerport + case 2: + return "", parts[0], containerport + case 3: + return parts[0], parts[1], containerport + default: + return strings.Join(parts[:n-2], ":"), parts[n-2], containerport + } +} + +// ParsePortSpec parses a port specification string into a slice of PortMappings +func ParsePortSpec(rawPort string) ([]PortMapping, error) { + var proto string + rawIP, hostPort, containerPort := splitParts(rawPort) + proto, containerPort = SplitProtoPort(containerPort) + + // Strip [] from IPV6 addresses + ip, _, err := net.SplitHostPort(rawIP + ":") + if err != nil { + return nil, fmt.Errorf("Invalid ip address %v: %s", rawIP, err) + } + if ip != "" && net.ParseIP(ip) == nil { + return nil, fmt.Errorf("Invalid ip address: %s", ip) + } + if containerPort == "" { + return nil, fmt.Errorf("No port specified: %s", rawPort) + } + + startPort, endPort, err := ParsePortRange(containerPort) + if err != nil { + return nil, fmt.Errorf("Invalid containerPort: %s", containerPort) + } + + var startHostPort, endHostPort uint64 = 0, 0 + if len(hostPort) > 0 { + startHostPort, endHostPort, err = ParsePortRange(hostPort) + if err != nil { + return nil, fmt.Errorf("Invalid hostPort: %s", hostPort) + } + } + + if hostPort != "" && (endPort-startPort) != (endHostPort-startHostPort) { + // Allow host port range iff containerPort is not a range. + // In this case, use the host port range as the dynamic + // host port range to allocate into. + if endPort != startPort { + return nil, fmt.Errorf("Invalid ranges specified for container and host Ports: %s and %s", containerPort, hostPort) + } + } + + if !validateProto(strings.ToLower(proto)) { + return nil, fmt.Errorf("Invalid proto: %s", proto) + } + + ports := []PortMapping{} + for i := uint64(0); i <= (endPort - startPort); i++ { + containerPort = strconv.FormatUint(startPort+i, 10) + if len(hostPort) > 0 { + hostPort = strconv.FormatUint(startHostPort+i, 10) + } + // Set hostPort to a range only if there is a single container port + // and a dynamic host port. + if startPort == endPort && startHostPort != endHostPort { + hostPort = fmt.Sprintf("%s-%s", hostPort, strconv.FormatUint(endHostPort, 10)) + } + port, err := NewPort(strings.ToLower(proto), containerPort) + if err != nil { + return nil, err + } + + binding := PortBinding{ + HostIP: ip, + HostPort: hostPort, + } + ports = append(ports, PortMapping{Port: port, Binding: binding}) + } + return ports, nil +} diff --git a/libnetwork/vendor/github.com/docker/go-connections/nat/parse.go b/libnetwork/vendor/github.com/docker/go-connections/nat/parse.go index 872050205f..892adf8c66 100644 --- a/libnetwork/vendor/github.com/docker/go-connections/nat/parse.go +++ b/libnetwork/vendor/github.com/docker/go-connections/nat/parse.go @@ -8,6 +8,7 @@ import ( // PartParser parses and validates the specified string (data) using the specified template // e.g. ip:public:private -> 192.168.0.1:80:8000 +// DEPRECATED: do not use, this function may be removed in a future version func PartParser(template, data string) (map[string]string, error) { // ip:public:private var ( diff --git a/libnetwork/vendor/github.com/docker/go-connections/sockets/inmem_socket.go b/libnetwork/vendor/github.com/docker/go-connections/sockets/inmem_socket.go index 3395e40229..99846ffddb 100644 --- a/libnetwork/vendor/github.com/docker/go-connections/sockets/inmem_socket.go +++ b/libnetwork/vendor/github.com/docker/go-connections/sockets/inmem_socket.go @@ -79,11 +79,3 @@ func (a dummyAddr) Network() string { func (a dummyAddr) String() string { return string(a) } - -// timeoutError is used when there is a timeout with a connection -// this implements the net.Error interface -type timeoutError struct{} - -func (e *timeoutError) Error() string { return "i/o timeout" } -func (e *timeoutError) Timeout() bool { return true } -func (e *timeoutError) Temporary() bool { return true } diff --git a/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets.go b/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets.go index 1739cecf2a..a1d7beb4d8 100644 --- a/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets.go +++ b/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets.go @@ -2,6 +2,7 @@ package sockets import ( + "errors" "net" "net/http" "time" @@ -10,6 +11,9 @@ import ( // Why 32? See https://github.com/docker/docker/pull/8035. const defaultTimeout = 32 * time.Second +// ErrProtocolNotAvailable is returned when a given transport protocol is not provided by the operating system. +var ErrProtocolNotAvailable = errors.New("protocol not available") + // ConfigureTransport configures the specified Transport according to the // specified proto and addr. // If the proto is unix (using a unix socket to communicate) or npipe the @@ -17,17 +21,9 @@ const defaultTimeout = 32 * time.Second func ConfigureTransport(tr *http.Transport, proto, addr string) error { switch proto { case "unix": - // No need for compression in local communications. - tr.DisableCompression = true - tr.Dial = func(_, _ string) (net.Conn, error) { - return net.DialTimeout(proto, addr, defaultTimeout) - } + return configureUnixTransport(tr, proto, addr) case "npipe": - // No need for compression in local communications. - tr.DisableCompression = true - tr.Dial = func(_, _ string) (net.Conn, error) { - return DialPipe(addr, defaultTimeout) - } + return configureNpipeTransport(tr, proto, addr) default: tr.Proxy = http.ProxyFromEnvironment dialer, err := DialerFromEnvironment(&net.Dialer{ diff --git a/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets_unix.go b/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets_unix.go index b255ac9ac7..386cf0dbbd 100644 --- a/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets_unix.go +++ b/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets_unix.go @@ -3,11 +3,31 @@ package sockets import ( + "fmt" "net" + "net/http" "syscall" "time" ) +const maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path) + +func configureUnixTransport(tr *http.Transport, proto, addr string) error { + if len(addr) > maxUnixSocketPathSize { + return fmt.Errorf("Unix socket path %q is too long", addr) + } + // No need for compression in local communications. + tr.DisableCompression = true + tr.Dial = func(_, _ string) (net.Conn, error) { + return net.DialTimeout(proto, addr, defaultTimeout) + } + return nil +} + +func configureNpipeTransport(tr *http.Transport, proto, addr string) error { + return ErrProtocolNotAvailable +} + // DialPipe connects to a Windows named pipe. // This is not supported on other OSes. func DialPipe(_ string, _ time.Duration) (net.Conn, error) { diff --git a/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets_windows.go b/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets_windows.go index 1f3540b2fe..5c21644e1f 100644 --- a/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets_windows.go +++ b/libnetwork/vendor/github.com/docker/go-connections/sockets/sockets_windows.go @@ -2,11 +2,25 @@ package sockets import ( "net" + "net/http" "time" "github.com/Microsoft/go-winio" ) +func configureUnixTransport(tr *http.Transport, proto, addr string) error { + return ErrProtocolNotAvailable +} + +func configureNpipeTransport(tr *http.Transport, proto, addr string) error { + // No need for compression in local communications. + tr.DisableCompression = true + tr.Dial = func(_, _ string) (net.Conn, error) { + return DialPipe(addr, defaultTimeout) + } + return nil +} + // DialPipe connects to a Windows named pipe. func DialPipe(addr string, timeout time.Duration) (net.Conn, error) { return winio.DialPipe(addr, &timeout) diff --git a/libnetwork/vendor/github.com/docker/go-connections/sockets/tcp_socket.go b/libnetwork/vendor/github.com/docker/go-connections/sockets/tcp_socket.go index 8a82727df0..53cbb6c79e 100644 --- a/libnetwork/vendor/github.com/docker/go-connections/sockets/tcp_socket.go +++ b/libnetwork/vendor/github.com/docker/go-connections/sockets/tcp_socket.go @@ -7,7 +7,7 @@ import ( ) // NewTCPSocket creates a TCP socket listener with the specified address and -// and the specified tls configuration. If TLSConfig is set, will encapsulate the +// the specified tls configuration. If TLSConfig is set, will encapsulate the // TCP listener inside a TLS one. func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error) { l, err := net.Listen("tcp", addr) diff --git a/libnetwork/vendor/github.com/docker/go-connections/sockets/unix_socket.go b/libnetwork/vendor/github.com/docker/go-connections/sockets/unix_socket.go index d1627349f8..a8b5dbb6fd 100644 --- a/libnetwork/vendor/github.com/docker/go-connections/sockets/unix_socket.go +++ b/libnetwork/vendor/github.com/docker/go-connections/sockets/unix_socket.go @@ -1,30 +1,26 @@ -// +build linux freebsd solaris +// +build !windows package sockets import ( - "fmt" "net" "os" - "strconv" "syscall" - - "github.com/Sirupsen/logrus" - "github.com/opencontainers/runc/libcontainer/user" ) // NewUnixSocket creates a unix socket with the specified path and group. -func NewUnixSocket(path, group string) (net.Listener, error) { +func NewUnixSocket(path string, gid int) (net.Listener, error) { if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) { return nil, err } mask := syscall.Umask(0777) defer syscall.Umask(mask) + l, err := net.Listen("unix", path) if err != nil { return nil, err } - if err := setSocketGroup(path, group); err != nil { + if err := os.Chown(path, 0, gid); err != nil { l.Close() return nil, err } @@ -34,47 +30,3 @@ func NewUnixSocket(path, group string) (net.Listener, error) { } return l, nil } - -func setSocketGroup(path, group string) error { - if group == "" { - return nil - } - if err := changeGroup(path, group); err != nil { - if group != "docker" { - return err - } - logrus.Debugf("Warning: could not change group %s to docker: %v", path, err) - } - return nil -} - -func changeGroup(path string, nameOrGid string) error { - gid, err := lookupGidByName(nameOrGid) - if err != nil { - return err - } - logrus.Debugf("%s group found. gid: %d", nameOrGid, gid) - return os.Chown(path, 0, gid) -} - -func lookupGidByName(nameOrGid string) (int, error) { - groupFile, err := user.GetGroupPath() - if err != nil { - return -1, err - } - groups, err := user.ParseGroupFileFilter(groupFile, func(g user.Group) bool { - return g.Name == nameOrGid || strconv.Itoa(g.Gid) == nameOrGid - }) - if err != nil { - return -1, err - } - if groups != nil && len(groups) > 0 { - return groups[0].Gid, nil - } - gid, err := strconv.Atoi(nameOrGid) - if err == nil { - logrus.Warnf("Could not find GID %d", gid) - return gid, nil - } - return -1, fmt.Errorf("Group %s not found", nameOrGid) -} diff --git a/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/certpool_go17.go b/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/certpool_go17.go new file mode 100644 index 0000000000..1ca0965e06 --- /dev/null +++ b/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/certpool_go17.go @@ -0,0 +1,18 @@ +// +build go1.7 + +package tlsconfig + +import ( + "crypto/x509" + "runtime" +) + +// SystemCertPool returns a copy of the system cert pool, +// returns an error if failed to load or empty pool on windows. +func SystemCertPool() (*x509.CertPool, error) { + certpool, err := x509.SystemCertPool() + if err != nil && runtime.GOOS == "windows" { + return x509.NewCertPool(), nil + } + return certpool, err +} diff --git a/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/certpool_other.go b/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/certpool_other.go new file mode 100644 index 0000000000..9ca974539a --- /dev/null +++ b/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/certpool_other.go @@ -0,0 +1,14 @@ +// +build !go1.7 + +package tlsconfig + +import ( + "crypto/x509" + +) + +// SystemCertPool returns an new empty cert pool, +// accessing system cert pool is supported in go 1.7 +func SystemCertPool() (*x509.CertPool, error) { + return x509.NewCertPool(), nil +} diff --git a/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/config.go b/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/config.go index 9378c358e6..1b31bbb8b1 100644 --- a/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/config.go +++ b/libnetwork/vendor/github.com/docker/go-connections/tlsconfig/config.go @@ -8,11 +8,12 @@ package tlsconfig import ( "crypto/tls" "crypto/x509" + "encoding/pem" "fmt" "io/ioutil" "os" - "github.com/Sirupsen/logrus" + "github.com/pkg/errors" ) // Options represents the information needed to create client and server TLS configurations. @@ -29,6 +30,14 @@ type Options struct { InsecureSkipVerify bool // server-only option ClientAuth tls.ClientAuthType + // If ExclusiveRootPools is set, then if a CA file is provided, the root pool used for TLS + // creds will include exclusively the roots in that CA file. If no CA file is provided, + // the system pool will be used. + ExclusiveRootPools bool + MinVersion uint16 + // If Passphrase is set, it will be used to decrypt a TLS private key + // if the key is encrypted + Passphrase string } // Extra (server-side) accepted CBC cipher suites - will phase out in the future @@ -46,67 +55,170 @@ var acceptedCBCCiphers = []uint16{ // known weak algorithms removed. var DefaultServerAcceptedCiphers = append(clientCipherSuites, acceptedCBCCiphers...) -// ServerDefault is a secure-enough TLS configuration for the server TLS configuration. -var ServerDefault = tls.Config{ - // Avoid fallback to SSL protocols < TLS1.0 - MinVersion: tls.VersionTLS10, - PreferServerCipherSuites: true, - CipherSuites: DefaultServerAcceptedCiphers, +// allTLSVersions lists all the TLS versions and is used by the code that validates +// a uint16 value as a TLS version. +var allTLSVersions = map[uint16]struct{}{ + tls.VersionSSL30: {}, + tls.VersionTLS10: {}, + tls.VersionTLS11: {}, + tls.VersionTLS12: {}, } -// ClientDefault is a secure-enough TLS configuration for the client TLS configuration. -var ClientDefault = tls.Config{ - // Prefer TLS1.2 as the client minimum - MinVersion: tls.VersionTLS12, - CipherSuites: clientCipherSuites, +// ServerDefault returns a secure-enough TLS configuration for the server TLS configuration. +func ServerDefault() *tls.Config { + return &tls.Config{ + // Avoid fallback to SSL protocols < TLS1.0 + MinVersion: tls.VersionTLS10, + PreferServerCipherSuites: true, + CipherSuites: DefaultServerAcceptedCiphers, + } +} + +// ClientDefault returns a secure-enough TLS configuration for the client TLS configuration. +func ClientDefault() *tls.Config { + return &tls.Config{ + // Prefer TLS1.2 as the client minimum + MinVersion: tls.VersionTLS12, + CipherSuites: clientCipherSuites, + } } // certPool returns an X.509 certificate pool from `caFile`, the certificate file. -func certPool(caFile string) (*x509.CertPool, error) { +func certPool(caFile string, exclusivePool bool) (*x509.CertPool, error) { // If we should verify the server, we need to load a trusted ca - certPool := x509.NewCertPool() + var ( + certPool *x509.CertPool + err error + ) + if exclusivePool { + certPool = x509.NewCertPool() + } else { + certPool, err = SystemCertPool() + if err != nil { + return nil, fmt.Errorf("failed to read system certificates: %v", err) + } + } pem, err := ioutil.ReadFile(caFile) if err != nil { - return nil, fmt.Errorf("Could not read CA certificate %q: %v", caFile, err) + return nil, fmt.Errorf("could not read CA certificate %q: %v", caFile, err) } if !certPool.AppendCertsFromPEM(pem) { return nil, fmt.Errorf("failed to append certificates from PEM file: %q", caFile) } - s := certPool.Subjects() - subjects := make([]string, len(s)) - for i, subject := range s { - subjects[i] = string(subject) - } - logrus.Debugf("Trusting certs with subjects: %v", subjects) return certPool, nil } +// isValidMinVersion checks that the input value is a valid tls minimum version +func isValidMinVersion(version uint16) bool { + _, ok := allTLSVersions[version] + return ok +} + +// adjustMinVersion sets the MinVersion on `config`, the input configuration. +// It assumes the current MinVersion on the `config` is the lowest allowed. +func adjustMinVersion(options Options, config *tls.Config) error { + if options.MinVersion > 0 { + if !isValidMinVersion(options.MinVersion) { + return fmt.Errorf("Invalid minimum TLS version: %x", options.MinVersion) + } + if options.MinVersion < config.MinVersion { + return fmt.Errorf("Requested minimum TLS version is too low. Should be at-least: %x", config.MinVersion) + } + config.MinVersion = options.MinVersion + } + + return nil +} + +// IsErrEncryptedKey returns true if the 'err' is an error of incorrect +// password when tryin to decrypt a TLS private key +func IsErrEncryptedKey(err error) bool { + return errors.Cause(err) == x509.IncorrectPasswordError +} + +// getPrivateKey returns the private key in 'keyBytes', in PEM-encoded format. +// If the private key is encrypted, 'passphrase' is used to decrypted the +// private key. +func getPrivateKey(keyBytes []byte, passphrase string) ([]byte, error) { + // this section makes some small changes to code from notary/tuf/utils/x509.go + pemBlock, _ := pem.Decode(keyBytes) + if pemBlock == nil { + return nil, fmt.Errorf("no valid private key found") + } + + var err error + if x509.IsEncryptedPEMBlock(pemBlock) { + keyBytes, err = x509.DecryptPEMBlock(pemBlock, []byte(passphrase)) + if err != nil { + return nil, errors.Wrap(err, "private key is encrypted, but could not decrypt it") + } + keyBytes = pem.EncodeToMemory(&pem.Block{Type: pemBlock.Type, Bytes: keyBytes}) + } + + return keyBytes, nil +} + +// getCert returns a Certificate from the CertFile and KeyFile in 'options', +// if the key is encrypted, the Passphrase in 'options' will be used to +// decrypt it. +func getCert(options Options) ([]tls.Certificate, error) { + if options.CertFile == "" && options.KeyFile == "" { + return nil, nil + } + + errMessage := "Could not load X509 key pair" + + cert, err := ioutil.ReadFile(options.CertFile) + if err != nil { + return nil, errors.Wrap(err, errMessage) + } + + prKeyBytes, err := ioutil.ReadFile(options.KeyFile) + if err != nil { + return nil, errors.Wrap(err, errMessage) + } + + prKeyBytes, err = getPrivateKey(prKeyBytes, options.Passphrase) + if err != nil { + return nil, errors.Wrap(err, errMessage) + } + + tlsCert, err := tls.X509KeyPair(cert, prKeyBytes) + if err != nil { + return nil, errors.Wrap(err, errMessage) + } + + return []tls.Certificate{tlsCert}, nil +} + // Client returns a TLS configuration meant to be used by a client. func Client(options Options) (*tls.Config, error) { - tlsConfig := ClientDefault + tlsConfig := ClientDefault() tlsConfig.InsecureSkipVerify = options.InsecureSkipVerify if !options.InsecureSkipVerify && options.CAFile != "" { - CAs, err := certPool(options.CAFile) + CAs, err := certPool(options.CAFile, options.ExclusiveRootPools) if err != nil { return nil, err } tlsConfig.RootCAs = CAs } - if options.CertFile != "" || options.KeyFile != "" { - tlsCert, err := tls.LoadX509KeyPair(options.CertFile, options.KeyFile) - if err != nil { - return nil, fmt.Errorf("Could not load X509 key pair: %v. Make sure the key is not encrypted", err) - } - tlsConfig.Certificates = []tls.Certificate{tlsCert} + tlsCerts, err := getCert(options) + if err != nil { + return nil, err + } + tlsConfig.Certificates = tlsCerts + + if err := adjustMinVersion(options, tlsConfig); err != nil { + return nil, err } - return &tlsConfig, nil + return tlsConfig, nil } // Server returns a TLS configuration meant to be used by a server. func Server(options Options) (*tls.Config, error) { - tlsConfig := ServerDefault + tlsConfig := ServerDefault() tlsConfig.ClientAuth = options.ClientAuth tlsCert, err := tls.LoadX509KeyPair(options.CertFile, options.KeyFile) if err != nil { @@ -116,12 +228,17 @@ func Server(options Options) (*tls.Config, error) { return nil, fmt.Errorf("Error reading X509 key pair (cert: %q, key: %q): %v. Make sure the key is not encrypted.", options.CertFile, options.KeyFile, err) } tlsConfig.Certificates = []tls.Certificate{tlsCert} - if options.ClientAuth >= tls.VerifyClientCertIfGiven { - CAs, err := certPool(options.CAFile) + if options.ClientAuth >= tls.VerifyClientCertIfGiven && options.CAFile != "" { + CAs, err := certPool(options.CAFile, options.ExclusiveRootPools) if err != nil { return nil, err } tlsConfig.ClientCAs = CAs } - return &tlsConfig, nil + + if err := adjustMinVersion(options, tlsConfig); err != nil { + return nil, err + } + + return tlsConfig, nil } diff --git a/libnetwork/vendor/github.com/docker/go-events/LICENSE b/libnetwork/vendor/github.com/docker/go-events/LICENSE index 8dada3edaf..6d630cf595 100644 --- a/libnetwork/vendor/github.com/docker/go-events/LICENSE +++ b/libnetwork/vendor/github.com/docker/go-events/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright 2016 Docker, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/libnetwork/vendor/github.com/docker/go-events/README.md b/libnetwork/vendor/github.com/docker/go-events/README.md index 9e3625da9e..0acafc279a 100644 --- a/libnetwork/vendor/github.com/docker/go-events/README.md +++ b/libnetwork/vendor/github.com/docker/go-events/README.md @@ -110,3 +110,8 @@ Application behavior can be controlled by how `Write` behaves. The examples above are designed to queue the message and return as quickly as possible. Other implementations may block until the event is committed to durable storage. + +## Copyright and license + +Copyright © 2016 Docker, Inc. go-events is licensed under the Apache License, +Version 2.0. See [LICENSE](LICENSE) for the full license text. diff --git a/libnetwork/vendor/github.com/docker/go-events/broadcast.go b/libnetwork/vendor/github.com/docker/go-events/broadcast.go index e73d758bcf..5120078dfb 100644 --- a/libnetwork/vendor/github.com/docker/go-events/broadcast.go +++ b/libnetwork/vendor/github.com/docker/go-events/broadcast.go @@ -1,6 +1,11 @@ package events -import "github.com/Sirupsen/logrus" +import ( + "fmt" + "sync" + + "github.com/sirupsen/logrus" +) // Broadcaster sends events to multiple, reliable Sinks. The goal of this // component is to dispatch events to configured endpoints. Reliability can be @@ -10,7 +15,10 @@ type Broadcaster struct { events chan Event adds chan configureRequest removes chan configureRequest - closed chan chan struct{} + + shutdown chan struct{} + closed chan struct{} + once sync.Once } // NewBroadcaster appends one or more sinks to the list of sinks. The @@ -19,11 +27,12 @@ type Broadcaster struct { // its own. Use of EventQueue and RetryingSink should be used here. func NewBroadcaster(sinks ...Sink) *Broadcaster { b := Broadcaster{ - sinks: sinks, - events: make(chan Event), - adds: make(chan configureRequest), - removes: make(chan configureRequest), - closed: make(chan chan struct{}), + sinks: sinks, + events: make(chan Event), + adds: make(chan configureRequest), + removes: make(chan configureRequest), + shutdown: make(chan struct{}), + closed: make(chan struct{}), } // Start the broadcaster @@ -82,24 +91,19 @@ func (b *Broadcaster) configure(ch chan configureRequest, sink Sink) error { // Close the broadcaster, ensuring that all messages are flushed to the // underlying sink before returning. func (b *Broadcaster) Close() error { - select { - case <-b.closed: - // already closed - return ErrSinkClosed - default: - // do a little chan handoff dance to synchronize closing - closed := make(chan struct{}) - b.closed <- closed - close(b.closed) - <-closed - return nil - } + b.once.Do(func() { + close(b.shutdown) + }) + + <-b.closed + return nil } // run is the main broadcast loop, started when the broadcaster is created. // Under normal conditions, it waits for events on the event channel. After // Close is called, this goroutine will exit. func (b *Broadcaster) run() { + defer close(b.closed) remove := func(target Sink) { for i, sink := range b.sinks { if sink == target { @@ -143,7 +147,7 @@ func (b *Broadcaster) run() { case request := <-b.removes: remove(request.sink) request.response <- nil - case closing := <-b.closed: + case <-b.shutdown: // close all the underlying sinks for _, sink := range b.sinks { if err := sink.Close(); err != nil && err != ErrSinkClosed { @@ -151,8 +155,24 @@ func (b *Broadcaster) run() { Errorf("broadcaster: closing sink failed") } } - closing <- struct{}{} return } } } + +func (b *Broadcaster) String() string { + // Serialize copy of this broadcaster without the sync.Once, to avoid + // a data race. + + b2 := map[string]interface{}{ + "sinks": b.sinks, + "events": b.events, + "adds": b.adds, + "removes": b.removes, + + "shutdown": b.shutdown, + "closed": b.closed, + } + + return fmt.Sprint(b2) +} diff --git a/libnetwork/vendor/github.com/docker/go-events/channel.go b/libnetwork/vendor/github.com/docker/go-events/channel.go index 7ee7ea5e22..802cf51ffe 100644 --- a/libnetwork/vendor/github.com/docker/go-events/channel.go +++ b/libnetwork/vendor/github.com/docker/go-events/channel.go @@ -1,5 +1,10 @@ package events +import ( + "fmt" + "sync" +) + // Channel provides a sink that can be listened on. The writer and channel // listener must operate in separate goroutines. // @@ -8,9 +13,10 @@ type Channel struct { C chan Event closed chan struct{} + once sync.Once } -// NewChannel returns a channel. If buffer is non-zero, the channel is +// NewChannel returns a channel. If buffer is zero, the channel is // unbuffered. func NewChannel(buffer int) *Channel { return &Channel{ @@ -37,11 +43,19 @@ func (ch *Channel) Write(event Event) error { // Close the channel sink. func (ch *Channel) Close() error { - select { - case <-ch.closed: - return ErrSinkClosed - default: + ch.once.Do(func() { close(ch.closed) - return nil - } + }) + + return nil +} + +func (ch *Channel) String() string { + // Serialize a copy of the Channel that doesn't contain the sync.Once, + // to avoid a data race. + ch2 := map[string]interface{}{ + "C": ch.C, + "closed": ch.closed, + } + return fmt.Sprint(ch2) } diff --git a/libnetwork/vendor/github.com/docker/go-events/filter.go b/libnetwork/vendor/github.com/docker/go-events/filter.go index f2765cfe6b..e6c0eb69dd 100644 --- a/libnetwork/vendor/github.com/docker/go-events/filter.go +++ b/libnetwork/vendor/github.com/docker/go-events/filter.go @@ -44,7 +44,7 @@ func (f *Filter) Write(event Event) error { func (f *Filter) Close() error { // TODO(stevvooe): Not all sinks should have Close. if f.closed { - return ErrSinkClosed + return nil } f.closed = true diff --git a/libnetwork/vendor/github.com/docker/go-events/queue.go b/libnetwork/vendor/github.com/docker/go-events/queue.go index 7c5fc8150e..4bb770afc2 100644 --- a/libnetwork/vendor/github.com/docker/go-events/queue.go +++ b/libnetwork/vendor/github.com/docker/go-events/queue.go @@ -4,7 +4,7 @@ import ( "container/list" "sync" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // Queue accepts all messages into a queue for asynchronous consumption @@ -31,7 +31,7 @@ func NewQueue(dst Sink) *Queue { } // Write accepts the events into the queue, only failing if the queue has -// beend closed. +// been closed. func (eq *Queue) Write(event Event) error { eq.mu.Lock() defer eq.mu.Unlock() @@ -52,7 +52,7 @@ func (eq *Queue) Close() error { defer eq.mu.Unlock() if eq.closed { - return ErrSinkClosed + return nil } // set closed flag @@ -72,10 +72,17 @@ func (eq *Queue) run() { } if err := eq.dst.Write(event); err != nil { + // TODO(aaronl): Dropping events could be bad depending + // on the application. We should have a way of + // communicating this condition. However, logging + // at a log level above debug may not be appropriate. + // Eventually, go-events should not use logrus at all, + // and should bubble up conditions like this through + // error values. logrus.WithFields(logrus.Fields{ "event": event, "sink": eq.dst, - }).WithError(err).Warnf("eventqueue: dropped event") + }).WithError(err).Debug("eventqueue: dropped event") } } } diff --git a/libnetwork/vendor/github.com/docker/go-events/retry.go b/libnetwork/vendor/github.com/docker/go-events/retry.go index 501deeb55f..2df55d2160 100644 --- a/libnetwork/vendor/github.com/docker/go-events/retry.go +++ b/libnetwork/vendor/github.com/docker/go-events/retry.go @@ -1,10 +1,13 @@ package events import ( + "fmt" + "math/rand" "sync" + "sync/atomic" "time" - "github.com/Sirupsen/logrus" + "github.com/sirupsen/logrus" ) // RetryingSink retries the write until success or an ErrSinkClosed is @@ -16,6 +19,7 @@ type RetryingSink struct { sink Sink strategy RetryStrategy closed chan struct{} + once sync.Once } // NewRetryingSink returns a sink that will retry writes to a sink, backing @@ -35,7 +39,6 @@ func NewRetryingSink(sink Sink, strategy RetryStrategy) *RetryingSink { // or the sink is closed. func (rs *RetryingSink) Write(event Event) error { logger := logrus.WithField("event", event) - var timer *time.Timer retry: select { @@ -45,16 +48,13 @@ retry: } if backoff := rs.strategy.Proceed(event); backoff > 0 { - if timer == nil { - timer = time.NewTimer(backoff) - defer timer.Stop() - } else { - timer.Reset(backoff) - } - select { - case <-timer.C: - goto retry + case <-time.After(backoff): + // TODO(stevvooe): This branch holds up the next try. Before, we + // would simply break to the "retry" label and then possibly wait + // again. However, this requires all retry strategies to have a + // large probability of probing the sync for success, rather than + // just backing off and sending the request. case <-rs.closed: return ErrSinkClosed } @@ -83,13 +83,22 @@ retry: // Close closes the sink and the underlying sink. func (rs *RetryingSink) Close() error { - select { - case <-rs.closed: - return ErrSinkClosed - default: + rs.once.Do(func() { close(rs.closed) - return rs.sink.Close() + }) + + return nil +} + +func (rs *RetryingSink) String() string { + // Serialize a copy of the RetryingSink without the sync.Once, to avoid + // a data race. + rs2 := map[string]interface{}{ + "sink": rs.sink, + "strategy": rs.strategy, + "closed": rs.closed, } + return fmt.Sprint(rs2) } // RetryStrategy defines a strategy for retrying event sink writes. @@ -111,9 +120,6 @@ type RetryStrategy interface { Success(event Event) } -// TODO(stevvooe): We are using circuit breaker here. May want to provide -// bounded exponential backoff, as well. - // Breaker implements a circuit breaker retry strategy. // // The current implementation never drops events. @@ -166,3 +172,89 @@ func (b *Breaker) Failure(event Event, err error) bool { b.last = time.Now().UTC() return false // never drop events. } + +var ( + // DefaultExponentialBackoffConfig provides a default configuration for + // exponential backoff. + DefaultExponentialBackoffConfig = ExponentialBackoffConfig{ + Base: time.Second, + Factor: time.Second, + Max: 20 * time.Second, + } +) + +// ExponentialBackoffConfig configures backoff parameters. +// +// Note that these parameters operate on the upper bound for choosing a random +// value. For example, at Base=1s, a random value in [0,1s) will be chosen for +// the backoff value. +type ExponentialBackoffConfig struct { + // Base is the minimum bound for backing off after failure. + Base time.Duration + + // Factor sets the amount of time by which the backoff grows with each + // failure. + Factor time.Duration + + // Max is the absolute maxiumum bound for a single backoff. + Max time.Duration +} + +// ExponentialBackoff implements random backoff with exponentially increasing +// bounds as the number consecutive failures increase. +type ExponentialBackoff struct { + config ExponentialBackoffConfig + failures uint64 // consecutive failure counter. +} + +// NewExponentialBackoff returns an exponential backoff strategy with the +// desired config. If config is nil, the default is returned. +func NewExponentialBackoff(config ExponentialBackoffConfig) *ExponentialBackoff { + return &ExponentialBackoff{ + config: config, + } +} + +// Proceed returns the next randomly bound exponential backoff time. +func (b *ExponentialBackoff) Proceed(event Event) time.Duration { + return b.backoff(atomic.LoadUint64(&b.failures)) +} + +// Success resets the failures counter. +func (b *ExponentialBackoff) Success(event Event) { + atomic.StoreUint64(&b.failures, 0) +} + +// Failure increments the failure counter. +func (b *ExponentialBackoff) Failure(event Event, err error) bool { + atomic.AddUint64(&b.failures, 1) + return false +} + +// backoff calculates the amount of time to wait based on the number of +// consecutive failures. +func (b *ExponentialBackoff) backoff(failures uint64) time.Duration { + if failures <= 0 { + // proceed normally when there are no failures. + return 0 + } + + factor := b.config.Factor + if factor <= 0 { + factor = DefaultExponentialBackoffConfig.Factor + } + + backoff := b.config.Base + factor*time.Duration(1<<(failures-1)) + + max := b.config.Max + if max <= 0 { + max = DefaultExponentialBackoffConfig.Max + } + + if backoff > max || backoff < 0 { + backoff = max + } + + // Choose a uniformly distributed value from [0, backoff). + return time.Duration(rand.Int63n(int64(backoff))) +} diff --git a/libnetwork/vendor/github.com/opencontainers/runc/libcontainer/container_linux.go b/libnetwork/vendor/github.com/opencontainers/runc/libcontainer/container_linux.go index 82476ed99a..482ed99a60 100644 --- a/libnetwork/vendor/github.com/opencontainers/runc/libcontainer/container_linux.go +++ b/libnetwork/vendor/github.com/opencontainers/runc/libcontainer/container_linux.go @@ -16,11 +16,11 @@ import ( "sync" "syscall" - "github.com/Sirupsen/logrus" "github.com/golang/protobuf/proto" "github.com/opencontainers/runc/libcontainer/cgroups" "github.com/opencontainers/runc/libcontainer/configs" "github.com/opencontainers/runc/libcontainer/criurpc" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink/nl" ) diff --git a/libnetwork/vendor/github.com/opencontainers/runc/libcontainer/init_linux.go b/libnetwork/vendor/github.com/opencontainers/runc/libcontainer/init_linux.go index ddb1186595..8553937fc9 100644 --- a/libnetwork/vendor/github.com/opencontainers/runc/libcontainer/init_linux.go +++ b/libnetwork/vendor/github.com/opencontainers/runc/libcontainer/init_linux.go @@ -12,12 +12,12 @@ import ( "strings" "syscall" - "github.com/Sirupsen/logrus" "github.com/opencontainers/runc/libcontainer/cgroups" "github.com/opencontainers/runc/libcontainer/configs" "github.com/opencontainers/runc/libcontainer/system" "github.com/opencontainers/runc/libcontainer/user" "github.com/opencontainers/runc/libcontainer/utils" + "github.com/sirupsen/logrus" "github.com/vishvananda/netlink" ) diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/LICENSE b/libnetwork/vendor/github.com/sirupsen/logrus/LICENSE similarity index 100% rename from libnetwork/vendor/github.com/Sirupsen/logrus/LICENSE rename to libnetwork/vendor/github.com/sirupsen/logrus/LICENSE diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/README.md b/libnetwork/vendor/github.com/sirupsen/logrus/README.md similarity index 61% rename from libnetwork/vendor/github.com/Sirupsen/logrus/README.md rename to libnetwork/vendor/github.com/sirupsen/logrus/README.md index 6e1721a743..82aeb4eef3 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/README.md +++ b/libnetwork/vendor/github.com/sirupsen/logrus/README.md @@ -1,11 +1,24 @@ -# Logrus :walrus: [![Build Status](https://travis-ci.org/Sirupsen/logrus.svg?branch=master)](https://travis-ci.org/Sirupsen/logrus) [![GoDoc](https://godoc.org/github.com/Sirupsen/logrus?status.svg)](https://godoc.org/github.com/Sirupsen/logrus) +# Logrus :walrus: [![Build Status](https://travis-ci.org/sirupsen/logrus.svg?branch=master)](https://travis-ci.org/sirupsen/logrus) [![GoDoc](https://godoc.org/github.com/sirupsen/logrus?status.svg)](https://godoc.org/github.com/sirupsen/logrus) Logrus is a structured logger for Go (golang), completely API compatible with -the standard library logger. [Godoc][godoc]. **Please note the Logrus API is not -yet stable (pre 1.0). Logrus itself is completely stable and has been used in -many large deployments. The core API is unlikely to change much but please -version control your Logrus to make sure you aren't fetching latest `master` on -every build.** +the standard library logger. [Godoc][godoc]. + +**Seeing weird case-sensitive problems?** It's in the past been possible to +import Logrus as both upper- and lower-case. Due to the Go package environment, +this caused issues in the community and we needed a standard. Some environments +experienced problems with the upper-case variant, so the lower-case was decided. +Everything using `logrus` will need to use the lower-case: +`github.com/sirupsen/logrus`. Any package that isn't, should be changed. + +To fix Glide, see [these +comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437). +For an in-depth explanation of the casing issue, see [this +comment](https://github.com/sirupsen/logrus/issues/570#issuecomment-313933276). + +**Are you interested in assisting in maintaining Logrus?** Currently I have a +lot of obligations, and I am unable to provide Logrus with the maintainership it +needs. If you'd like to help, please reach out to me at `simon at author's +username dot com`. Nicely color-coded in development (when a TTY is attached, otherwise just plain text): @@ -46,6 +59,12 @@ time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x20822 exit status 1 ``` +#### Case-sensitivity + +The organization's name was changed to lower-case--and this will not be changed +back. If you are getting import conflicts due to case sensitivity, please use +the lower-case import: `github.com/sirupsen/logrus`. + #### Example The simplest way to use Logrus is simply the package-level exported logger: @@ -54,7 +73,7 @@ The simplest way to use Logrus is simply the package-level exported logger: package main import ( - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" ) func main() { @@ -65,7 +84,7 @@ func main() { ``` Note that it's completely api-compatible with the stdlib logger, so you can -replace your `log` imports everywhere with `log "github.com/Sirupsen/logrus"` +replace your `log` imports everywhere with `log "github.com/sirupsen/logrus"` and you'll now have the flexibility of Logrus. You can customize it all you want: @@ -74,15 +93,16 @@ package main import ( "os" - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" ) func init() { // Log as JSON instead of the default ASCII formatter. log.SetFormatter(&log.JSONFormatter{}) - // Output to stderr instead of stdout, could also be a file. - log.SetOutput(os.Stderr) + // Output to stdout instead of the default stderr + // Can be any io.Writer, see below for File example + log.SetOutput(os.Stdout) // Only log the warning severity or above. log.SetLevel(log.WarnLevel) @@ -123,7 +143,8 @@ application, you can also create an instance of the `logrus` Logger: package main import ( - "github.com/Sirupsen/logrus" + "os" + "github.com/sirupsen/logrus" ) // Create a new instance of the logger. You can have any number of instances. @@ -132,7 +153,15 @@ var log = logrus.New() func main() { // The API for setting attributes is a little different than the package level // exported logger. See Godoc. - log.Out = os.Stderr + log.Out = os.Stdout + + // You could set this to any `io.Writer` such as a file + // file, err := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY, 0666) + // if err == nil { + // log.Out = file + // } else { + // log.Info("Failed to log to file, using default stderr") + // } log.WithFields(logrus.Fields{ "animal": "walrus", @@ -143,7 +172,7 @@ func main() { #### Fields -Logrus encourages careful, structured logging though logging fields instead of +Logrus encourages careful, structured logging through logging fields instead of long, unparseable error messages. For example, instead of: `log.Fatalf("Failed to send event %s to topic %s with key %d")`, you should log the much more discoverable: @@ -165,6 +194,20 @@ In general, with Logrus using any of the `printf`-family functions should be seen as a hint you should add a field, however, you can still use the `printf`-family functions with Logrus. +#### Default Fields + +Often it's helpful to have fields _always_ attached to log statements in an +application or parts of one. For example, you may want to always log the +`request_id` and `user_ip` in the context of a request. Instead of writing +`log.WithFields(log.Fields{"request_id": request_id, "user_ip": user_ip})` on +every line, you can create a `logrus.Entry` to pass around instead: + +```go +requestLogger := log.WithFields(log.Fields{"request_id": request_id, "user_ip": user_ip}) +requestLogger.Info("something happened on that request") # will log request_id and user_ip +requestLogger.Warn("something not great happened") +``` + #### Hooks You can add hooks for logging levels. For example to send errors to an exception @@ -176,9 +219,9 @@ Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in ```go import ( - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "aibrake" - logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" + logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" "log/syslog" ) @@ -200,33 +243,52 @@ Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/v | Hook | Description | | ----- | ----------- | -| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. | | [Airbrake "legacy"](https://github.com/gemnasium/logrus-airbrake-legacy-hook) | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. | -| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. | -| [Syslog](https://github.com/Sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. | -| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. | -| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. | -| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. | -| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) | -| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. | -| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` | -| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) | -| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) | -| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem | -| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger | -| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail | -| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar | -| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd | -| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb | -| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb | -| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit | -| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic | -| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) | +| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. | +| [Amazon Kinesis](https://github.com/evalphobia/logrus_kinesis) | Hook for logging to [Amazon Kinesis](https://aws.amazon.com/kinesis/) | | [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) | -| [KafkaLogrus](https://github.com/goibibo/KafkaLogrus) | Hook for logging to kafka | -| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) | +| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. | +| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic | +| [Discordrus](https://github.com/kz/discordrus) | Hook for logging to [Discord](https://discordapp.com/) | | [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch| - +| [Firehose](https://github.com/beaubrewer/logrus_firehose) | Hook for logging to [Amazon Firehose](https://aws.amazon.com/kinesis/firehose/) +| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd | +| [Go-Slack](https://github.com/multiplay/go-slack) | Hook for logging to [Slack](https://slack.com) | +| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) | +| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. | +| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger | +| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb | +| [Influxus](http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB](http://influxdata.com/) | +| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` | +| [KafkaLogrus](https://github.com/goibibo/KafkaLogrus) | Hook for logging to kafka | +| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem | +| [Logentries](https://github.com/jcftang/logentriesrus) | Hook for logging to [Logentries](https://logentries.com/) | +| [Logentrus](https://github.com/puddingfactory/logentrus) | Hook for logging to [Logentries](https://logentries.com/) | +| [Logmatic.io](https://github.com/logmatic/logmatic-go) | Hook for logging to [Logmatic.io](http://logmatic.io/) | +| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) | +| [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) | +| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail | +| [Mattermost](https://github.com/shuLhan/mattermost-integration/tree/master/hooks/logrus) | Hook for logging to [Mattermost](https://mattermost.com/) | +| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb | +| [NATS-Hook](https://github.com/rybit/nats_logrus_hook) | Hook for logging to [NATS](https://nats.io) | +| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit | +| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. | +| [PostgreSQL](https://github.com/gemnasium/logrus-postgresql-hook) | Send logs to [PostgreSQL](http://postgresql.org) | +| [Pushover](https://github.com/toorop/logrus_pushover) | Send error via [Pushover](https://pushover.net) | +| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) | +| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) | +| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar | +| [Scribe](https://github.com/sagar8192/logrus-scribe-hook) | Hook for logging to [Scribe](https://github.com/facebookarchive/scribe)| +| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. | +| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. | +| [Stackdriver](https://github.com/knq/sdhook) | Hook for logging to [Google Stackdriver](https://cloud.google.com/logging/) | +| [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)| +| [Syslog](https://github.com/sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. | +| [Syslog TLS](https://github.com/shinji62/logrus-syslog-ng) | Send errors to remote syslog server with TLS support. | +| [TraceView](https://github.com/evalphobia/logrus_appneta) | Hook for logging to [AppNeta TraceView](https://www.appneta.com/products/traceview/) | +| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) | +| [logz.io](https://github.com/ripcurld00d/logrus-logzio-hook) | Hook for logging to [logz.io](https://logz.io), a Log as a Service using Logstash | +| [SQS-Hook](https://github.com/tsarpaul/logrus_sqs) | Hook for logging to [Amazon Simple Queue Service (SQS)](https://aws.amazon.com/sqs/) | #### Level logging @@ -275,7 +337,7 @@ could do: ```go import ( - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" ) init() { @@ -302,16 +364,15 @@ The built-in logging formatters are: without colors. * *Note:* to force colored output when there is no TTY, set the `ForceColors` field to `true`. To force no colored output even if there is a TTY set the - `DisableColors` field to `true` + `DisableColors` field to `true`. For Windows, see + [github.com/mattn/go-colorable](https://github.com/mattn/go-colorable). + * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#TextFormatter). * `logrus.JSONFormatter`. Logs fields as JSON. -* `logrus/formatters/logstash.LogstashFormatter`. Logs fields as [Logstash](http://logstash.net) Events. - - ```go - logrus.SetFormatter(&logstash.LogstashFormatter{Type: "application_name"}) - ``` + * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#JSONFormatter). Third party logging formatters: +* [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events. * [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout. * [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦. @@ -356,6 +417,18 @@ srv := http.Server{ Each line written to that writer will be printed the usual way, using formatters and hooks. The level for those entries is `info`. +This means that we can override the standard library logger easily: + +```go +logger := logrus.New() +logger.Formatter = &logrus.JSONFormatter{} + +// Use logrus for standard log output +// Note that `log` here references stdlib's log +// Not logrus imported under the name `log`. +log.SetOutput(logger.Writer()) +``` + #### Rotation Log rotation is not provided with Logrus. Log rotation should be done by an @@ -367,6 +440,7 @@ entries. It should not be a feature of the application-level logger. | Tool | Description | | ---- | ----------- | |[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will generated with different config at different environment.| +|[Logrus Viper Helper](https://github.com/heirko/go-contrib/tree/master/logrusHelper)|An Helper around Logrus to wrap with spf13/Viper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https://github.com/gogap/logrus_mate). [sample](https://github.com/heirko/iris-contrib/blob/master/middleware/logrus-logger/example) | #### Testing @@ -376,13 +450,55 @@ Logrus has a built in facility for asserting the presence of log messages. This * a test logger (`test.NewNullLogger`) that just records log messages (and does not output any): ```go -logger, hook := NewNullLogger() -logger.Error("Hello error") +import( + "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus/hooks/test" + "github.com/stretchr/testify/assert" + "testing" +) -assert.Equal(1, len(hook.Entries)) -assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level) -assert.Equal("Hello error", hook.LastEntry().Message) +func TestSomething(t*testing.T){ + logger, hook := test.NewNullLogger() + logger.Error("Helloerror") -hook.Reset() -assert.Nil(hook.LastEntry()) + assert.Equal(t, 1, len(hook.Entries)) + assert.Equal(t, logrus.ErrorLevel, hook.LastEntry().Level) + assert.Equal(t, "Helloerror", hook.LastEntry().Message) + + hook.Reset() + assert.Nil(t, hook.LastEntry()) +} ``` + +#### Fatal handlers + +Logrus can register one or more functions that will be called when any `fatal` +level message is logged. The registered handlers will be executed before +logrus performs a `os.Exit(1)`. This behavior may be helpful if callers need +to gracefully shutdown. Unlike a `panic("Something went wrong...")` call which can be intercepted with a deferred `recover` a call to `os.Exit(1)` can not be intercepted. + +``` +... +handler := func() { + // gracefully shutdown something... +} +logrus.RegisterExitHandler(handler) +... +``` + +#### Thread safety + +By default Logger is protected by mutex for concurrent writes, this mutex is invoked when calling hooks and writing logs. +If you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking. + +Situation when locking is not needed includes: + +* You have no hooks registered, or hooks calling is already thread-safe. + +* Writing to logger.Out is already thread-safe, for example: + + 1) logger.Out is protected by locks. + + 2) logger.Out is a os.File handler opened with `O_APPEND` flag, and every write is smaller than 4k. (This allow multi-thread/multi-process writing) + + (Refer to http://www.notthewizard.com/2014/06/17/are-files-appends-really-atomic/) diff --git a/libnetwork/vendor/github.com/sirupsen/logrus/alt_exit.go b/libnetwork/vendor/github.com/sirupsen/logrus/alt_exit.go new file mode 100644 index 0000000000..8af90637a9 --- /dev/null +++ b/libnetwork/vendor/github.com/sirupsen/logrus/alt_exit.go @@ -0,0 +1,64 @@ +package logrus + +// The following code was sourced and modified from the +// https://github.com/tebeka/atexit package governed by the following license: +// +// Copyright (c) 2012 Miki Tebeka . +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import ( + "fmt" + "os" +) + +var handlers = []func(){} + +func runHandler(handler func()) { + defer func() { + if err := recover(); err != nil { + fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err) + } + }() + + handler() +} + +func runHandlers() { + for _, handler := range handlers { + runHandler(handler) + } +} + +// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code) +func Exit(code int) { + runHandlers() + os.Exit(code) +} + +// RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke +// all handlers. The handlers will also be invoked when any Fatal log entry is +// made. +// +// This method is useful when a caller wishes to use logrus to log a fatal +// message but also needs to gracefully shutdown. An example usecase could be +// closing database connections, or sending a alert that the application is +// closing. +func RegisterExitHandler(handler func()) { + handlers = append(handlers, handler) +} diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/doc.go b/libnetwork/vendor/github.com/sirupsen/logrus/doc.go similarity index 83% rename from libnetwork/vendor/github.com/Sirupsen/logrus/doc.go rename to libnetwork/vendor/github.com/sirupsen/logrus/doc.go index dddd5f877b..da67aba06d 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/doc.go +++ b/libnetwork/vendor/github.com/sirupsen/logrus/doc.go @@ -7,7 +7,7 @@ The simplest way to use Logrus is simply the package-level exported logger: package main import ( - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" ) func main() { @@ -21,6 +21,6 @@ The simplest way to use Logrus is simply the package-level exported logger: Output: time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 -For a full guide visit https://github.com/Sirupsen/logrus +For a full guide visit https://github.com/sirupsen/logrus */ package logrus diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/entry.go b/libnetwork/vendor/github.com/sirupsen/logrus/entry.go similarity index 78% rename from libnetwork/vendor/github.com/Sirupsen/logrus/entry.go rename to libnetwork/vendor/github.com/sirupsen/logrus/entry.go index 89e966e7bf..320e5d5b8b 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/entry.go +++ b/libnetwork/vendor/github.com/sirupsen/logrus/entry.go @@ -3,11 +3,21 @@ package logrus import ( "bytes" "fmt" - "io" "os" + "sync" "time" ) +var bufferPool *sync.Pool + +func init() { + bufferPool = &sync.Pool{ + New: func() interface{} { + return new(bytes.Buffer) + }, + } +} + // Defines the key when adding errors using WithError. var ErrorKey = "error" @@ -29,6 +39,9 @@ type Entry struct { // Message passed to Debug, Info, Warn, Error, Fatal or Panic Message string + + // When formatter is called in entry.log(), an Buffer may be set to entry + Buffer *bytes.Buffer } func NewEntry(logger *Logger) *Entry { @@ -39,21 +52,15 @@ func NewEntry(logger *Logger) *Entry { } } -// Returns a reader for the entry, which is a proxy to the formatter. -func (entry *Entry) Reader() (*bytes.Buffer, error) { - serialized, err := entry.Logger.Formatter.Format(entry) - return bytes.NewBuffer(serialized), err -} - // Returns the string representation from the reader and ultimately the // formatter. func (entry *Entry) String() (string, error) { - reader, err := entry.Reader() + serialized, err := entry.Logger.Formatter.Format(entry) if err != nil { return "", err } - - return reader.String(), err + str := string(serialized) + return str, nil } // Add an error as single field (using the key defined in ErrorKey) to the Entry. @@ -81,6 +88,7 @@ func (entry *Entry) WithFields(fields Fields) *Entry { // This function is not declared with a pointer value because otherwise // race conditions will occur when using multiple goroutines func (entry Entry) log(level Level, msg string) { + var buffer *bytes.Buffer entry.Time = time.Now() entry.Level = level entry.Message = msg @@ -90,20 +98,23 @@ func (entry Entry) log(level Level, msg string) { fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err) entry.Logger.mu.Unlock() } - - reader, err := entry.Reader() + buffer = bufferPool.Get().(*bytes.Buffer) + buffer.Reset() + defer bufferPool.Put(buffer) + entry.Buffer = buffer + serialized, err := entry.Logger.Formatter.Format(&entry) + entry.Buffer = nil if err != nil { entry.Logger.mu.Lock() fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err) entry.Logger.mu.Unlock() - } - - entry.Logger.mu.Lock() - defer entry.Logger.mu.Unlock() - - _, err = io.Copy(entry.Logger.Out, reader) - if err != nil { - fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err) + } else { + entry.Logger.mu.Lock() + _, err = entry.Logger.Out.Write(serialized) + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err) + } + entry.Logger.mu.Unlock() } // To avoid Entry#log() returning a value that only would make sense for @@ -115,7 +126,7 @@ func (entry Entry) log(level Level, msg string) { } func (entry *Entry) Debug(args ...interface{}) { - if entry.Logger.Level >= DebugLevel { + if entry.Logger.level() >= DebugLevel { entry.log(DebugLevel, fmt.Sprint(args...)) } } @@ -125,13 +136,13 @@ func (entry *Entry) Print(args ...interface{}) { } func (entry *Entry) Info(args ...interface{}) { - if entry.Logger.Level >= InfoLevel { + if entry.Logger.level() >= InfoLevel { entry.log(InfoLevel, fmt.Sprint(args...)) } } func (entry *Entry) Warn(args ...interface{}) { - if entry.Logger.Level >= WarnLevel { + if entry.Logger.level() >= WarnLevel { entry.log(WarnLevel, fmt.Sprint(args...)) } } @@ -141,20 +152,20 @@ func (entry *Entry) Warning(args ...interface{}) { } func (entry *Entry) Error(args ...interface{}) { - if entry.Logger.Level >= ErrorLevel { + if entry.Logger.level() >= ErrorLevel { entry.log(ErrorLevel, fmt.Sprint(args...)) } } func (entry *Entry) Fatal(args ...interface{}) { - if entry.Logger.Level >= FatalLevel { + if entry.Logger.level() >= FatalLevel { entry.log(FatalLevel, fmt.Sprint(args...)) } - os.Exit(1) + Exit(1) } func (entry *Entry) Panic(args ...interface{}) { - if entry.Logger.Level >= PanicLevel { + if entry.Logger.level() >= PanicLevel { entry.log(PanicLevel, fmt.Sprint(args...)) } panic(fmt.Sprint(args...)) @@ -163,13 +174,13 @@ func (entry *Entry) Panic(args ...interface{}) { // Entry Printf family functions func (entry *Entry) Debugf(format string, args ...interface{}) { - if entry.Logger.Level >= DebugLevel { + if entry.Logger.level() >= DebugLevel { entry.Debug(fmt.Sprintf(format, args...)) } } func (entry *Entry) Infof(format string, args ...interface{}) { - if entry.Logger.Level >= InfoLevel { + if entry.Logger.level() >= InfoLevel { entry.Info(fmt.Sprintf(format, args...)) } } @@ -179,7 +190,7 @@ func (entry *Entry) Printf(format string, args ...interface{}) { } func (entry *Entry) Warnf(format string, args ...interface{}) { - if entry.Logger.Level >= WarnLevel { + if entry.Logger.level() >= WarnLevel { entry.Warn(fmt.Sprintf(format, args...)) } } @@ -189,20 +200,20 @@ func (entry *Entry) Warningf(format string, args ...interface{}) { } func (entry *Entry) Errorf(format string, args ...interface{}) { - if entry.Logger.Level >= ErrorLevel { + if entry.Logger.level() >= ErrorLevel { entry.Error(fmt.Sprintf(format, args...)) } } func (entry *Entry) Fatalf(format string, args ...interface{}) { - if entry.Logger.Level >= FatalLevel { + if entry.Logger.level() >= FatalLevel { entry.Fatal(fmt.Sprintf(format, args...)) } - os.Exit(1) + Exit(1) } func (entry *Entry) Panicf(format string, args ...interface{}) { - if entry.Logger.Level >= PanicLevel { + if entry.Logger.level() >= PanicLevel { entry.Panic(fmt.Sprintf(format, args...)) } } @@ -210,13 +221,13 @@ func (entry *Entry) Panicf(format string, args ...interface{}) { // Entry Println family functions func (entry *Entry) Debugln(args ...interface{}) { - if entry.Logger.Level >= DebugLevel { + if entry.Logger.level() >= DebugLevel { entry.Debug(entry.sprintlnn(args...)) } } func (entry *Entry) Infoln(args ...interface{}) { - if entry.Logger.Level >= InfoLevel { + if entry.Logger.level() >= InfoLevel { entry.Info(entry.sprintlnn(args...)) } } @@ -226,7 +237,7 @@ func (entry *Entry) Println(args ...interface{}) { } func (entry *Entry) Warnln(args ...interface{}) { - if entry.Logger.Level >= WarnLevel { + if entry.Logger.level() >= WarnLevel { entry.Warn(entry.sprintlnn(args...)) } } @@ -236,20 +247,20 @@ func (entry *Entry) Warningln(args ...interface{}) { } func (entry *Entry) Errorln(args ...interface{}) { - if entry.Logger.Level >= ErrorLevel { + if entry.Logger.level() >= ErrorLevel { entry.Error(entry.sprintlnn(args...)) } } func (entry *Entry) Fatalln(args ...interface{}) { - if entry.Logger.Level >= FatalLevel { + if entry.Logger.level() >= FatalLevel { entry.Fatal(entry.sprintlnn(args...)) } - os.Exit(1) + Exit(1) } func (entry *Entry) Panicln(args ...interface{}) { - if entry.Logger.Level >= PanicLevel { + if entry.Logger.level() >= PanicLevel { entry.Panic(entry.sprintlnn(args...)) } } diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/exported.go b/libnetwork/vendor/github.com/sirupsen/logrus/exported.go similarity index 99% rename from libnetwork/vendor/github.com/Sirupsen/logrus/exported.go rename to libnetwork/vendor/github.com/sirupsen/logrus/exported.go index 9a0120ac1d..1aeaa90ba2 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/exported.go +++ b/libnetwork/vendor/github.com/sirupsen/logrus/exported.go @@ -31,14 +31,14 @@ func SetFormatter(formatter Formatter) { func SetLevel(level Level) { std.mu.Lock() defer std.mu.Unlock() - std.Level = level + std.setLevel(level) } // GetLevel returns the standard logger level. func GetLevel() Level { std.mu.Lock() defer std.mu.Unlock() - return std.Level + return std.level() } // AddHook adds a hook to the standard logger hooks. diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/formatter.go b/libnetwork/vendor/github.com/sirupsen/logrus/formatter.go similarity index 85% rename from libnetwork/vendor/github.com/Sirupsen/logrus/formatter.go rename to libnetwork/vendor/github.com/sirupsen/logrus/formatter.go index 104d689f18..b5fbe934d1 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/formatter.go +++ b/libnetwork/vendor/github.com/sirupsen/logrus/formatter.go @@ -31,18 +31,15 @@ type Formatter interface { // It's not exported because it's still using Data in an opinionated way. It's to // avoid code duplication between the two default formatters. func prefixFieldClashes(data Fields) { - _, ok := data["time"] - if ok { - data["fields.time"] = data["time"] + if t, ok := data["time"]; ok { + data["fields.time"] = t } - _, ok = data["msg"] - if ok { - data["fields.msg"] = data["msg"] + if m, ok := data["msg"]; ok { + data["fields.msg"] = m } - _, ok = data["level"] - if ok { - data["fields.level"] = data["level"] + if l, ok := data["level"]; ok { + data["fields.level"] = l } } diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/hooks.go b/libnetwork/vendor/github.com/sirupsen/logrus/hooks.go similarity index 100% rename from libnetwork/vendor/github.com/Sirupsen/logrus/hooks.go rename to libnetwork/vendor/github.com/sirupsen/logrus/hooks.go diff --git a/libnetwork/vendor/github.com/sirupsen/logrus/json_formatter.go b/libnetwork/vendor/github.com/sirupsen/logrus/json_formatter.go new file mode 100644 index 0000000000..e787ea1750 --- /dev/null +++ b/libnetwork/vendor/github.com/sirupsen/logrus/json_formatter.go @@ -0,0 +1,74 @@ +package logrus + +import ( + "encoding/json" + "fmt" +) + +type fieldKey string +type FieldMap map[fieldKey]string + +const ( + FieldKeyMsg = "msg" + FieldKeyLevel = "level" + FieldKeyTime = "time" +) + +func (f FieldMap) resolve(key fieldKey) string { + if k, ok := f[key]; ok { + return k + } + + return string(key) +} + +type JSONFormatter struct { + // TimestampFormat sets the format used for marshaling timestamps. + TimestampFormat string + + // DisableTimestamp allows disabling automatic timestamps in output + DisableTimestamp bool + + // FieldMap allows users to customize the names of keys for various fields. + // As an example: + // formatter := &JSONFormatter{ + // FieldMap: FieldMap{ + // FieldKeyTime: "@timestamp", + // FieldKeyLevel: "@level", + // FieldKeyMsg: "@message", + // }, + // } + FieldMap FieldMap +} + +func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { + data := make(Fields, len(entry.Data)+3) + for k, v := range entry.Data { + switch v := v.(type) { + case error: + // Otherwise errors are ignored by `encoding/json` + // https://github.com/sirupsen/logrus/issues/137 + data[k] = v.Error() + default: + data[k] = v + } + } + prefixFieldClashes(data) + + timestampFormat := f.TimestampFormat + if timestampFormat == "" { + timestampFormat = DefaultTimestampFormat + } + + if !f.DisableTimestamp { + data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat) + } + data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message + data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String() + + serialized, err := json.Marshal(data) + if err != nil { + return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) + } + return append(serialized, '\n'), nil +} diff --git a/libnetwork/vendor/github.com/sirupsen/logrus/logger.go b/libnetwork/vendor/github.com/sirupsen/logrus/logger.go new file mode 100644 index 0000000000..370fff5d1b --- /dev/null +++ b/libnetwork/vendor/github.com/sirupsen/logrus/logger.go @@ -0,0 +1,317 @@ +package logrus + +import ( + "io" + "os" + "sync" + "sync/atomic" +) + +type Logger struct { + // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a + // file, or leave it default which is `os.Stderr`. You can also set this to + // something more adventorous, such as logging to Kafka. + Out io.Writer + // Hooks for the logger instance. These allow firing events based on logging + // levels and log entries. For example, to send errors to an error tracking + // service, log to StatsD or dump the core on fatal errors. + Hooks LevelHooks + // All log entries pass through the formatter before logged to Out. The + // included formatters are `TextFormatter` and `JSONFormatter` for which + // TextFormatter is the default. In development (when a TTY is attached) it + // logs with colors, but to a file it wouldn't. You can easily implement your + // own that implements the `Formatter` interface, see the `README` or included + // formatters for examples. + Formatter Formatter + // The logging level the logger should log at. This is typically (and defaults + // to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be + // logged. `logrus.Debug` is useful in + Level Level + // Used to sync writing to the log. Locking is enabled by Default + mu MutexWrap + // Reusable empty entry + entryPool sync.Pool +} + +type MutexWrap struct { + lock sync.Mutex + disabled bool +} + +func (mw *MutexWrap) Lock() { + if !mw.disabled { + mw.lock.Lock() + } +} + +func (mw *MutexWrap) Unlock() { + if !mw.disabled { + mw.lock.Unlock() + } +} + +func (mw *MutexWrap) Disable() { + mw.disabled = true +} + +// Creates a new logger. Configuration should be set by changing `Formatter`, +// `Out` and `Hooks` directly on the default logger instance. You can also just +// instantiate your own: +// +// var log = &Logger{ +// Out: os.Stderr, +// Formatter: new(JSONFormatter), +// Hooks: make(LevelHooks), +// Level: logrus.DebugLevel, +// } +// +// It's recommended to make this a global instance called `log`. +func New() *Logger { + return &Logger{ + Out: os.Stderr, + Formatter: new(TextFormatter), + Hooks: make(LevelHooks), + Level: InfoLevel, + } +} + +func (logger *Logger) newEntry() *Entry { + entry, ok := logger.entryPool.Get().(*Entry) + if ok { + return entry + } + return NewEntry(logger) +} + +func (logger *Logger) releaseEntry(entry *Entry) { + logger.entryPool.Put(entry) +} + +// Adds a field to the log entry, note that it doesn't log until you call +// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry. +// If you want multiple fields, use `WithFields`. +func (logger *Logger) WithField(key string, value interface{}) *Entry { + entry := logger.newEntry() + defer logger.releaseEntry(entry) + return entry.WithField(key, value) +} + +// Adds a struct of fields to the log entry. All it does is call `WithField` for +// each `Field`. +func (logger *Logger) WithFields(fields Fields) *Entry { + entry := logger.newEntry() + defer logger.releaseEntry(entry) + return entry.WithFields(fields) +} + +// Add an error as single field to the log entry. All it does is call +// `WithError` for the given `error`. +func (logger *Logger) WithError(err error) *Entry { + entry := logger.newEntry() + defer logger.releaseEntry(entry) + return entry.WithError(err) +} + +func (logger *Logger) Debugf(format string, args ...interface{}) { + if logger.level() >= DebugLevel { + entry := logger.newEntry() + entry.Debugf(format, args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Infof(format string, args ...interface{}) { + if logger.level() >= InfoLevel { + entry := logger.newEntry() + entry.Infof(format, args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Printf(format string, args ...interface{}) { + entry := logger.newEntry() + entry.Printf(format, args...) + logger.releaseEntry(entry) +} + +func (logger *Logger) Warnf(format string, args ...interface{}) { + if logger.level() >= WarnLevel { + entry := logger.newEntry() + entry.Warnf(format, args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Warningf(format string, args ...interface{}) { + if logger.level() >= WarnLevel { + entry := logger.newEntry() + entry.Warnf(format, args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Errorf(format string, args ...interface{}) { + if logger.level() >= ErrorLevel { + entry := logger.newEntry() + entry.Errorf(format, args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Fatalf(format string, args ...interface{}) { + if logger.level() >= FatalLevel { + entry := logger.newEntry() + entry.Fatalf(format, args...) + logger.releaseEntry(entry) + } + Exit(1) +} + +func (logger *Logger) Panicf(format string, args ...interface{}) { + if logger.level() >= PanicLevel { + entry := logger.newEntry() + entry.Panicf(format, args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Debug(args ...interface{}) { + if logger.level() >= DebugLevel { + entry := logger.newEntry() + entry.Debug(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Info(args ...interface{}) { + if logger.level() >= InfoLevel { + entry := logger.newEntry() + entry.Info(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Print(args ...interface{}) { + entry := logger.newEntry() + entry.Info(args...) + logger.releaseEntry(entry) +} + +func (logger *Logger) Warn(args ...interface{}) { + if logger.level() >= WarnLevel { + entry := logger.newEntry() + entry.Warn(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Warning(args ...interface{}) { + if logger.level() >= WarnLevel { + entry := logger.newEntry() + entry.Warn(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Error(args ...interface{}) { + if logger.level() >= ErrorLevel { + entry := logger.newEntry() + entry.Error(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Fatal(args ...interface{}) { + if logger.level() >= FatalLevel { + entry := logger.newEntry() + entry.Fatal(args...) + logger.releaseEntry(entry) + } + Exit(1) +} + +func (logger *Logger) Panic(args ...interface{}) { + if logger.level() >= PanicLevel { + entry := logger.newEntry() + entry.Panic(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Debugln(args ...interface{}) { + if logger.level() >= DebugLevel { + entry := logger.newEntry() + entry.Debugln(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Infoln(args ...interface{}) { + if logger.level() >= InfoLevel { + entry := logger.newEntry() + entry.Infoln(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Println(args ...interface{}) { + entry := logger.newEntry() + entry.Println(args...) + logger.releaseEntry(entry) +} + +func (logger *Logger) Warnln(args ...interface{}) { + if logger.level() >= WarnLevel { + entry := logger.newEntry() + entry.Warnln(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Warningln(args ...interface{}) { + if logger.level() >= WarnLevel { + entry := logger.newEntry() + entry.Warnln(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Errorln(args ...interface{}) { + if logger.level() >= ErrorLevel { + entry := logger.newEntry() + entry.Errorln(args...) + logger.releaseEntry(entry) + } +} + +func (logger *Logger) Fatalln(args ...interface{}) { + if logger.level() >= FatalLevel { + entry := logger.newEntry() + entry.Fatalln(args...) + logger.releaseEntry(entry) + } + Exit(1) +} + +func (logger *Logger) Panicln(args ...interface{}) { + if logger.level() >= PanicLevel { + entry := logger.newEntry() + entry.Panicln(args...) + logger.releaseEntry(entry) + } +} + +//When file is opened with appending mode, it's safe to +//write concurrently to a file (within 4k message on Linux). +//In these cases user can choose to disable the lock. +func (logger *Logger) SetNoLock() { + logger.mu.Disable() +} + +func (logger *Logger) level() Level { + return Level(atomic.LoadUint32((*uint32)(&logger.Level))) +} + +func (logger *Logger) setLevel(level Level) { + atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) +} diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/logrus.go b/libnetwork/vendor/github.com/sirupsen/logrus/logrus.go similarity index 99% rename from libnetwork/vendor/github.com/Sirupsen/logrus/logrus.go rename to libnetwork/vendor/github.com/sirupsen/logrus/logrus.go index e596691116..dd38999741 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/logrus.go +++ b/libnetwork/vendor/github.com/sirupsen/logrus/logrus.go @@ -10,7 +10,7 @@ import ( type Fields map[string]interface{} // Level type -type Level uint8 +type Level uint32 // Convert the Level to a string. E.g. PanicLevel becomes "panic". func (level Level) String() string { diff --git a/libnetwork/vendor/github.com/sirupsen/logrus/terminal_appengine.go b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_appengine.go new file mode 100644 index 0000000000..e011a86945 --- /dev/null +++ b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_appengine.go @@ -0,0 +1,10 @@ +// +build appengine + +package logrus + +import "io" + +// IsTerminal returns true if stderr's file descriptor is a terminal. +func IsTerminal(f io.Writer) bool { + return true +} diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_bsd.go b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_bsd.go similarity index 88% rename from libnetwork/vendor/github.com/Sirupsen/logrus/terminal_bsd.go rename to libnetwork/vendor/github.com/sirupsen/logrus/terminal_bsd.go index 71f8d67a55..5f6be4d3c0 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_bsd.go +++ b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_bsd.go @@ -1,4 +1,5 @@ // +build darwin freebsd openbsd netbsd dragonfly +// +build !appengine package logrus diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_linux.go b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_linux.go similarity index 92% rename from libnetwork/vendor/github.com/Sirupsen/logrus/terminal_linux.go rename to libnetwork/vendor/github.com/sirupsen/logrus/terminal_linux.go index a2c0b40db6..308160ca80 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_linux.go +++ b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_linux.go @@ -3,6 +3,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !appengine + package logrus import "syscall" diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_notwindows.go similarity index 57% rename from libnetwork/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go rename to libnetwork/vendor/github.com/sirupsen/logrus/terminal_notwindows.go index b343b3a375..190297abf3 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go +++ b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_notwindows.go @@ -4,18 +4,25 @@ // license that can be found in the LICENSE file. // +build linux darwin freebsd openbsd netbsd dragonfly +// +build !appengine package logrus import ( + "io" + "os" "syscall" "unsafe" ) // IsTerminal returns true if stderr's file descriptor is a terminal. -func IsTerminal() bool { - fd := syscall.Stderr +func IsTerminal(f io.Writer) bool { var termios Termios - _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) - return err == 0 + switch v := f.(type) { + case *os.File: + _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(v.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) + return err == 0 + default: + return false + } } diff --git a/libnetwork/vendor/github.com/sirupsen/logrus/terminal_solaris.go b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_solaris.go new file mode 100644 index 0000000000..3c86b1abee --- /dev/null +++ b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_solaris.go @@ -0,0 +1,21 @@ +// +build solaris,!appengine + +package logrus + +import ( + "io" + "os" + + "golang.org/x/sys/unix" +) + +// IsTerminal returns true if the given file descriptor is a terminal. +func IsTerminal(f io.Writer) bool { + switch v := f.(type) { + case *os.File: + _, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA) + return err == nil + default: + return false + } +} diff --git a/libnetwork/vendor/github.com/sirupsen/logrus/terminal_windows.go b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_windows.go new file mode 100644 index 0000000000..7a336307e5 --- /dev/null +++ b/libnetwork/vendor/github.com/sirupsen/logrus/terminal_windows.go @@ -0,0 +1,82 @@ +// Based on ssh/terminal: +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows,!appengine + +package logrus + +import ( + "bytes" + "errors" + "io" + "os" + "os/exec" + "strconv" + "strings" + "syscall" + "unsafe" +) + +var kernel32 = syscall.NewLazyDLL("kernel32.dll") + +var ( + procGetConsoleMode = kernel32.NewProc("GetConsoleMode") + procSetConsoleMode = kernel32.NewProc("SetConsoleMode") +) + +const ( + enableProcessedOutput = 0x0001 + enableWrapAtEolOutput = 0x0002 + enableVirtualTerminalProcessing = 0x0004 +) + +func getVersion() (float64, error) { + stdout, stderr := &bytes.Buffer{}, &bytes.Buffer{} + cmd := exec.Command("cmd", "ver") + cmd.Stdout = stdout + cmd.Stderr = stderr + err := cmd.Run() + if err != nil { + return -1, err + } + + // The output should be like "Microsoft Windows [Version XX.X.XXXXXX]" + version := strings.Replace(stdout.String(), "\n", "", -1) + version = strings.Replace(version, "\r\n", "", -1) + + x1 := strings.Index(version, "[Version") + + if x1 == -1 || strings.Index(version, "]") == -1 { + return -1, errors.New("Can't determine Windows version") + } + + return strconv.ParseFloat(version[x1+9:x1+13], 64) +} + +func init() { + ver, err := getVersion() + if err != nil { + return + } + + // Activate Virtual Processing for Windows CMD + // Info: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx + if ver >= 10 { + handle := syscall.Handle(os.Stderr.Fd()) + procSetConsoleMode.Call(uintptr(handle), enableProcessedOutput|enableWrapAtEolOutput|enableVirtualTerminalProcessing) + } +} + +// IsTerminal returns true if stderr's file descriptor is a terminal. +func IsTerminal(f io.Writer) bool { + switch v := f.(type) { + case *os.File: + var st uint32 + r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(v.Fd()), uintptr(unsafe.Pointer(&st)), 0) + return r != 0 && e == 0 + default: + return false + } +} diff --git a/libnetwork/vendor/github.com/Sirupsen/logrus/text_formatter.go b/libnetwork/vendor/github.com/sirupsen/logrus/text_formatter.go similarity index 63% rename from libnetwork/vendor/github.com/Sirupsen/logrus/text_formatter.go rename to libnetwork/vendor/github.com/sirupsen/logrus/text_formatter.go index 06ef202337..26dcc15538 100644 --- a/libnetwork/vendor/github.com/Sirupsen/logrus/text_formatter.go +++ b/libnetwork/vendor/github.com/sirupsen/logrus/text_formatter.go @@ -3,9 +3,9 @@ package logrus import ( "bytes" "fmt" - "runtime" "sort" "strings" + "sync" "time" ) @@ -20,16 +20,10 @@ const ( var ( baseTimestamp time.Time - isTerminal bool ) func init() { baseTimestamp = time.Now() - isTerminal = IsTerminal() -} - -func miniTS() int { - return int(time.Since(baseTimestamp) / time.Second) } type TextFormatter struct { @@ -54,10 +48,32 @@ type TextFormatter struct { // that log extremely frequently and don't use the JSON formatter this may not // be desired. DisableSorting bool + + // QuoteEmptyFields will wrap empty fields in quotes if true + QuoteEmptyFields bool + + // QuoteCharacter can be set to the override the default quoting character " + // with something else. For example: ', or `. + QuoteCharacter string + + // Whether the logger's out is to a terminal + isTerminal bool + + sync.Once +} + +func (f *TextFormatter) init(entry *Entry) { + if len(f.QuoteCharacter) == 0 { + f.QuoteCharacter = "\"" + } + if entry.Logger != nil { + f.isTerminal = IsTerminal(entry.Logger.Out) + } } func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { - var keys []string = make([]string, 0, len(entry.Data)) + var b *bytes.Buffer + keys := make([]string, 0, len(entry.Data)) for k := range entry.Data { keys = append(keys, k) } @@ -65,13 +81,17 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { if !f.DisableSorting { sort.Strings(keys) } - - b := &bytes.Buffer{} + if entry.Buffer != nil { + b = entry.Buffer + } else { + b = &bytes.Buffer{} + } prefixFieldClashes(entry.Data) - isColorTerminal := isTerminal && (runtime.GOOS != "windows") - isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors + f.Do(func() { f.init(entry) }) + + isColored := (f.ForceColors || f.isTerminal) && !f.DisableColors timestampFormat := f.TimestampFormat if timestampFormat == "" { @@ -111,51 +131,66 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin levelText := strings.ToUpper(entry.Level.String())[0:4] - if !f.FullTimestamp { - fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message) + if f.DisableTimestamp { + fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message) + } else if !f.FullTimestamp { + fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, int(entry.Time.Sub(baseTimestamp)/time.Second), entry.Message) } else { fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) } for _, k := range keys { v := entry.Data[k] - fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%+v", levelColor, k, v) + fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=", levelColor, k) + f.appendValue(b, v) } } -func needsQuoting(text string) bool { +func (f *TextFormatter) needsQuoting(text string) bool { + if f.QuoteEmptyFields && len(text) == 0 { + return true + } for _, ch := range text { if !((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '.') { - return false + return true } } - return true + return false } func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { b.WriteString(key) b.WriteByte('=') + f.appendValue(b, value) + b.WriteByte(' ') +} +func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) { switch value := value.(type) { case string: - if needsQuoting(value) { + if !f.needsQuoting(value) { b.WriteString(value) } else { - fmt.Fprintf(b, "%q", value) + b.WriteString(f.quoteString(value)) } case error: errmsg := value.Error() - if needsQuoting(errmsg) { + if !f.needsQuoting(errmsg) { b.WriteString(errmsg) } else { - fmt.Fprintf(b, "%q", value) + b.WriteString(f.quoteString(errmsg)) } default: fmt.Fprint(b, value) } - - b.WriteByte(' ') +} + +func (f *TextFormatter) quoteString(v string) string { + escapedQuote := fmt.Sprintf("\\%s", f.QuoteCharacter) + escapedValue := strings.Replace(v, f.QuoteCharacter, escapedQuote, -1) + + return fmt.Sprintf("%s%v%s", f.QuoteCharacter, escapedValue, f.QuoteCharacter) } diff --git a/libnetwork/vendor/github.com/sirupsen/logrus/writer.go b/libnetwork/vendor/github.com/sirupsen/logrus/writer.go new file mode 100644 index 0000000000..7bdebedc60 --- /dev/null +++ b/libnetwork/vendor/github.com/sirupsen/logrus/writer.go @@ -0,0 +1,62 @@ +package logrus + +import ( + "bufio" + "io" + "runtime" +) + +func (logger *Logger) Writer() *io.PipeWriter { + return logger.WriterLevel(InfoLevel) +} + +func (logger *Logger) WriterLevel(level Level) *io.PipeWriter { + return NewEntry(logger).WriterLevel(level) +} + +func (entry *Entry) Writer() *io.PipeWriter { + return entry.WriterLevel(InfoLevel) +} + +func (entry *Entry) WriterLevel(level Level) *io.PipeWriter { + reader, writer := io.Pipe() + + var printFunc func(args ...interface{}) + + switch level { + case DebugLevel: + printFunc = entry.Debug + case InfoLevel: + printFunc = entry.Info + case WarnLevel: + printFunc = entry.Warn + case ErrorLevel: + printFunc = entry.Error + case FatalLevel: + printFunc = entry.Fatal + case PanicLevel: + printFunc = entry.Panic + default: + printFunc = entry.Print + } + + go entry.writerScanner(reader, printFunc) + runtime.SetFinalizer(writer, writerFinalizer) + + return writer +} + +func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { + scanner := bufio.NewScanner(reader) + for scanner.Scan() { + printFunc(scanner.Text()) + } + if err := scanner.Err(); err != nil { + entry.Errorf("Error while reading from Writer: %s", err) + } + reader.Close() +} + +func writerFinalizer(writer *io.PipeWriter) { + writer.Close() +}