From 955b8b4593d336269413705fc3a10f7144369459 Mon Sep 17 00:00:00 2001 From: Pradip Dhara Date: Mon, 2 Oct 2017 16:08:59 -0700 Subject: [PATCH] Changing containerID to sandboxID based off feedback/conversation with Madhu. Signed-off-by: Pradip Dhara --- libnetwork/drivers/windows/windows.go | 22 ++++++++++++++-------- libnetwork/sandbox.go | 7 +++++++ libnetwork/sandbox_others.go | 12 ------------ libnetwork/sandbox_windows.go | 12 ------------ 4 files changed, 21 insertions(+), 32 deletions(-) delete mode 100644 libnetwork/sandbox_others.go delete mode 100644 libnetwork/sandbox_windows.go diff --git a/libnetwork/drivers/windows/windows.go b/libnetwork/drivers/windows/windows.go index 0a4d9b9666..16d1ca2cb9 100644 --- a/libnetwork/drivers/windows/windows.go +++ b/libnetwork/drivers/windows/windows.go @@ -62,11 +62,17 @@ type EndpointConnectivity struct { } type hnsEndpoint struct { - id string - nid string - profileID string - Type string - containerID string + id string + nid string + profileID string + Type string + //Note: Currently, the sandboxID is the same as the containerID since windows does + //not expose the sandboxID. + //In the future, windows will support a proper sandboxID that is different + //than the containerID. + //Therefore, we are using sandboxID now, so that we won't have to change this code + //when windows properly supports a sandboxID. + sandboxID string macAddress net.HardwareAddr epOption *endpointOption // User specified parameters epConnectivity *EndpointConnectivity // User specified parameters @@ -731,9 +737,9 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, return err } - endpoint.containerID = sboxKey + endpoint.sandboxID = sboxKey - err = hcsshim.HotAttachEndpoint(endpoint.containerID, endpoint.profileID) + err = hcsshim.HotAttachEndpoint(endpoint.sandboxID, endpoint.profileID) if err != nil { // If container doesn't exists in hcs, do not throw error for hot add/remove if err != hcsshim.ErrComputeSystemDoesNotExist { @@ -758,7 +764,7 @@ func (d *driver) Leave(nid, eid string) error { return err } - err = hcsshim.HotDetachEndpoint(endpoint.containerID, endpoint.profileID) + err = hcsshim.HotDetachEndpoint(endpoint.sandboxID, endpoint.profileID) if err != nil { // If container doesn't exists in hcs, do not throw error for hot add/remove if err != hcsshim.ErrComputeSystemDoesNotExist { diff --git a/libnetwork/sandbox.go b/libnetwork/sandbox.go index db0ffb0d1d..315195ebb8 100644 --- a/libnetwork/sandbox.go +++ b/libnetwork/sandbox.go @@ -144,6 +144,13 @@ func (sb *sandbox) ContainerID() string { return sb.containerID } +func (sb *sandbox) Key() string { + if sb.config.useDefaultSandBox { + return osl.GenerateKey("default") + } + return osl.GenerateKey(sb.id) +} + func (sb *sandbox) Labels() map[string]interface{} { sb.Lock() defer sb.Unlock() diff --git a/libnetwork/sandbox_others.go b/libnetwork/sandbox_others.go deleted file mode 100644 index 89232415de..0000000000 --- a/libnetwork/sandbox_others.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build !windows - -package libnetwork - -import "github.com/docker/libnetwork/osl" - -func (sb *sandbox) Key() string { - if sb.config.useDefaultSandBox { - return osl.GenerateKey("default") - } - return osl.GenerateKey(sb.id) -} diff --git a/libnetwork/sandbox_windows.go b/libnetwork/sandbox_windows.go deleted file mode 100644 index e2ce30e675..0000000000 --- a/libnetwork/sandbox_windows.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build windows - -package libnetwork - -import "github.com/docker/libnetwork/osl" - -func (sb *sandbox) Key() string { - if sb.config.useDefaultSandBox { - return osl.GenerateKey("default") - } - return osl.GenerateKey(sb.containerID) -}