Signed-off-by: Grant Millar <rid@cylo.io>
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
"github.com/docker/docker/daemon/config" |
| 12 | 12 |
"github.com/docker/docker/pkg/idtools" |
| 13 |
+ "github.com/docker/docker/pkg/stringid" |
|
| 13 | 14 |
"github.com/docker/libnetwork" |
| 14 | 15 |
"github.com/moby/buildkit/executor" |
| 15 | 16 |
"github.com/moby/buildkit/executor/oci" |
| ... | ... |
@@ -100,11 +101,12 @@ func (iface *lnInterface) Set(s *specs.Spec) {
|
| 100 | 100 |
logrus.WithError(iface.err).Error("failed to set networking spec")
|
| 101 | 101 |
return |
| 102 | 102 |
} |
| 103 |
+ shortNetCtlrID := stringid.TruncateID(iface.provider.NetworkController.ID()) |
|
| 103 | 104 |
// attach netns to bridge within the container namespace, using reexec in a prestart hook |
| 104 | 105 |
s.Hooks = &specs.Hooks{
|
| 105 | 106 |
Prestart: []specs.Hook{{
|
| 106 | 107 |
Path: filepath.Join("/proc", strconv.Itoa(os.Getpid()), "exe"),
|
| 107 |
- Args: []string{"libnetwork-setkey", "-exec-root=" + iface.provider.Config().Daemon.ExecRoot, iface.sbx.ContainerID(), iface.provider.NetworkController.ID()},
|
|
| 108 |
+ Args: []string{"libnetwork-setkey", "-exec-root=" + iface.provider.Config().Daemon.ExecRoot, iface.sbx.ContainerID(), shortNetCtlrID},
|
|
| 108 | 109 |
}}, |
| 109 | 110 |
} |
| 110 | 111 |
} |
| ... | ... |
@@ -20,6 +20,7 @@ import ( |
| 20 | 20 |
"github.com/docker/docker/oci/caps" |
| 21 | 21 |
"github.com/docker/docker/pkg/idtools" |
| 22 | 22 |
"github.com/docker/docker/pkg/mount" |
| 23 |
+ "github.com/docker/docker/pkg/stringid" |
|
| 23 | 24 |
"github.com/docker/docker/rootless/specconv" |
| 24 | 25 |
volumemounts "github.com/docker/docker/volume/mounts" |
| 25 | 26 |
"github.com/opencontainers/runc/libcontainer/apparmor" |
| ... | ... |
@@ -66,13 +67,14 @@ func WithLibnetwork(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
| 66 | 66 |
for _, ns := range s.Linux.Namespaces {
|
| 67 | 67 |
if ns.Type == "network" && ns.Path == "" && !c.Config.NetworkDisabled {
|
| 68 | 68 |
target := filepath.Join("/proc", strconv.Itoa(os.Getpid()), "exe")
|
| 69 |
+ shortNetCtlrID := stringid.TruncateID(daemon.netController.ID()) |
|
| 69 | 70 |
s.Hooks.Prestart = append(s.Hooks.Prestart, specs.Hook{
|
| 70 | 71 |
Path: target, |
| 71 | 72 |
Args: []string{
|
| 72 | 73 |
"libnetwork-setkey", |
| 73 | 74 |
"-exec-root=" + daemon.configStore.GetExecRoot(), |
| 74 | 75 |
c.ID, |
| 75 |
- daemon.netController.ID(), |
|
| 76 |
+ shortNetCtlrID, |
|
| 76 | 77 |
}, |
| 77 | 78 |
}) |
| 78 | 79 |
} |
| ... | ... |
@@ -3,7 +3,7 @@ |
| 3 | 3 |
# LIBNETWORK_COMMIT is used to build the docker-userland-proxy binary. When |
| 4 | 4 |
# updating the binary version, consider updating github.com/docker/libnetwork |
| 5 | 5 |
# in vendor.conf accordingly |
| 6 |
-: ${LIBNETWORK_COMMIT:=96bcc0dae898308ed659c5095526788a602f4726}
|
|
| 6 |
+: ${LIBNETWORK_COMMIT:=0025177e3dabbe0de151be0957dcaff149d43536}
|
|
| 7 | 7 |
|
| 8 | 8 |
install_proxy() {
|
| 9 | 9 |
case "$1" in |
| ... | ... |
@@ -38,7 +38,7 @@ github.com/gofrs/flock 392e7fae8f1b0bdbd67dad7237d2 |
| 38 | 38 |
# libnetwork |
| 39 | 39 |
|
| 40 | 40 |
# When updating, also update LIBNETWORK_COMMIT in hack/dockerfile/install/proxy.installer accordingly |
| 41 |
-github.com/docker/libnetwork 96bcc0dae898308ed659c5095526788a602f4726 |
|
| 41 |
+github.com/docker/libnetwork 0025177e3dabbe0de151be0957dcaff149d43536 |
|
| 42 | 42 |
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 |
| 43 | 43 |
github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 |
| 44 | 44 |
github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec |
| ... | ... |
@@ -70,7 +70,7 @@ func setupBridgeIPv6(config *networkConfiguration, i *bridgeInterface) error {
|
| 70 | 70 |
Dst: config.AddressIPv6, |
| 71 | 71 |
}) |
| 72 | 72 |
if err != nil && !os.IsExist(err) {
|
| 73 |
- logrus.Errorf("Could not add route to IPv6 network %s via device %s", config.AddressIPv6.String(), config.BridgeName)
|
|
| 73 |
+ logrus.Errorf("Could not add route to IPv6 network %s via device %s: %s", config.AddressIPv6.String(), config.BridgeName, err)
|
|
| 74 | 74 |
} |
| 75 | 75 |
|
| 76 | 76 |
return nil |
| ... | ... |
@@ -144,6 +144,17 @@ const ( |
| 144 | 144 |
// a statically assigned hash table by their source IP |
| 145 | 145 |
// addresses. |
| 146 | 146 |
SourceHashing = "sh" |
| 147 |
+ |
|
| 148 |
+ // WeightedRoundRobin assigns jobs to real servers proportionally |
|
| 149 |
+ // to there real servers' weight. Servers with higher weights |
|
| 150 |
+ // receive new jobs first and get more jobs than servers |
|
| 151 |
+ // with lower weights. Servers with equal weights get |
|
| 152 |
+ // an equal distribution of new jobs |
|
| 153 |
+ WeightedRoundRobin = "wrr" |
|
| 154 |
+ |
|
| 155 |
+ // WeightedLeastConnection assigns more jobs to servers |
|
| 156 |
+ // with fewer jobs and relative to the real servers' weight |
|
| 157 |
+ WeightedLeastConnection = "wlc" |
|
| 147 | 158 |
) |
| 148 | 159 |
|
| 149 | 160 |
const ( |
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"os" |
| 13 | 13 |
"path/filepath" |
| 14 | 14 |
|
| 15 |
+ "github.com/docker/docker/pkg/stringid" |
|
| 15 | 16 |
"github.com/docker/libnetwork/types" |
| 16 | 17 |
"github.com/opencontainers/runtime-spec/specs-go" |
| 17 | 18 |
"github.com/sirupsen/logrus" |
| ... | ... |
@@ -24,7 +25,7 @@ const ( |
| 24 | 24 |
) |
| 25 | 25 |
|
| 26 | 26 |
// processSetKeyReexec is a private function that must be called only on an reexec path |
| 27 |
-// It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <controller-id> }
|
|
| 27 |
+// It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <short-controller-id> }
|
|
| 28 | 28 |
// It also expects specs.State as a json string in <stdin> |
| 29 | 29 |
// Refer to https://github.com/opencontainers/runc/pull/160/ for more information |
| 30 | 30 |
// The docker exec-root can be specified as "-exec-root" flag. The default value is "/run/docker". |
| ... | ... |
@@ -41,14 +42,14 @@ func processSetKeyReexec() {
|
| 41 | 41 |
execRoot := flag.String("exec-root", defaultExecRoot, "docker exec root")
|
| 42 | 42 |
flag.Parse() |
| 43 | 43 |
|
| 44 |
- // expecting 3 os.Args {[0]="libnetwork-setkey", [1]=<container-id>, [2]=<controller-id> }
|
|
| 44 |
+ // expecting 3 os.Args {[0]="libnetwork-setkey", [1]=<container-id>, [2]=<short-controller-id> }
|
|
| 45 | 45 |
// (i.e. expecting 2 flag.Args()) |
| 46 | 46 |
args := flag.Args() |
| 47 | 47 |
if len(args) < 2 {
|
| 48 | 48 |
err = fmt.Errorf("Re-exec expects 2 args (after parsing flags), received : %d", len(args))
|
| 49 | 49 |
return |
| 50 | 50 |
} |
| 51 |
- containerID, controllerID := args[0], args[1] |
|
| 51 |
+ containerID, shortCtlrID := args[0], args[1] |
|
| 52 | 52 |
|
| 53 | 53 |
// We expect specs.State as a json string in <stdin> |
| 54 | 54 |
stateBuf, err := ioutil.ReadAll(os.Stdin) |
| ... | ... |
@@ -60,16 +61,16 @@ func processSetKeyReexec() {
|
| 60 | 60 |
return |
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 |
- err = SetExternalKey(controllerID, containerID, fmt.Sprintf("/proc/%d/ns/net", state.Pid), *execRoot)
|
|
| 63 |
+ err = SetExternalKey(shortCtlrID, containerID, fmt.Sprintf("/proc/%d/ns/net", state.Pid), *execRoot)
|
|
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 | 66 |
// SetExternalKey provides a convenient way to set an External key to a sandbox |
| 67 |
-func SetExternalKey(controllerID string, containerID string, key string, execRoot string) error {
|
|
| 67 |
+func SetExternalKey(shortCtlrID string, containerID string, key string, execRoot string) error {
|
|
| 68 | 68 |
keyData := setKeyData{
|
| 69 | 69 |
ContainerID: containerID, |
| 70 | 70 |
Key: key} |
| 71 | 71 |
|
| 72 |
- uds := filepath.Join(execRoot, execSubdir, controllerID+".sock") |
|
| 72 |
+ uds := filepath.Join(execRoot, execSubdir, shortCtlrID+".sock") |
|
| 73 | 73 |
c, err := net.Dial("unix", uds)
|
| 74 | 74 |
if err != nil {
|
| 75 | 75 |
return err |
| ... | ... |
@@ -120,7 +121,8 @@ func (c *controller) startExternalKeyListener() error {
|
| 120 | 120 |
if err := os.MkdirAll(udsBase, 0600); err != nil {
|
| 121 | 121 |
return err |
| 122 | 122 |
} |
| 123 |
- uds := filepath.Join(udsBase, c.id+".sock") |
|
| 123 |
+ shortCtlrID := stringid.TruncateID(c.id) |
|
| 124 |
+ uds := filepath.Join(udsBase, shortCtlrID+".sock") |
|
| 124 | 125 |
l, err := net.Listen("unix", uds)
|
| 125 | 126 |
if err != nil {
|
| 126 | 127 |
return err |
| ... | ... |
@@ -80,30 +80,15 @@ func (c *controller) getStores() []datastore.DataStore {
|
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 | 82 |
func (c *controller) getNetworkFromStore(nid string) (*network, error) {
|
| 83 |
- for _, store := range c.getStores() {
|
|
| 84 |
- n := &network{id: nid, ctrlr: c}
|
|
| 85 |
- err := store.GetObject(datastore.Key(n.Key()...), n) |
|
| 86 |
- // Continue searching in the next store if the key is not found in this store |
|
| 87 |
- if err != nil {
|
|
| 88 |
- if err != datastore.ErrKeyNotFound {
|
|
| 89 |
- logrus.Debugf("could not find network %s: %v", nid, err)
|
|
| 90 |
- } |
|
| 91 |
- continue |
|
| 92 |
- } |
|
| 93 |
- |
|
| 94 |
- ec := &endpointCnt{n: n}
|
|
| 95 |
- err = store.GetObject(datastore.Key(ec.Key()...), ec) |
|
| 96 |
- if err != nil && !n.inDelete {
|
|
| 97 |
- return nil, fmt.Errorf("could not find endpoint count for network %s: %v", n.Name(), err)
|
|
| 98 |
- } |
|
| 99 |
- |
|
| 100 |
- n.epCnt = ec |
|
| 101 |
- if n.scope == "" {
|
|
| 102 |
- n.scope = store.Scope() |
|
| 83 |
+ ns, err := c.getNetworksFromStore() |
|
| 84 |
+ if err != nil {
|
|
| 85 |
+ return nil, err |
|
| 86 |
+ } |
|
| 87 |
+ for _, n := range ns {
|
|
| 88 |
+ if n.id == nid {
|
|
| 89 |
+ return n, nil |
|
| 103 | 90 |
} |
| 104 |
- return n, nil |
|
| 105 | 91 |
} |
| 106 |
- |
|
| 107 | 92 |
return nil, fmt.Errorf("network %s not found", nid)
|
| 108 | 93 |
} |
| 109 | 94 |
|