Skip to content

Commit

Permalink
fix bug that can't show remote container
Browse files Browse the repository at this point in the history
Fixes #506

docker service ls can't show container connected remotely, change docker
UI to show "remote" under container ID column for remote container

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
  • Loading branch information
WeiZhang555 committed Sep 10, 2015
1 parent 3e31cea commit 914ca1a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,16 @@ func (ep *endpoint) getSandbox() (*sandbox, bool) {
ps, ok := c.sandboxes[sid]
c.Unlock()

// if sid isn't empty but ps is nil, that means
// sandbox is connected remotely
if sid != "" && ps == nil {
ps = &sandbox{
id: sid,
containerID: remoteCID,
}
ok = true
}

return ps, ok
}

Expand Down
2 changes: 1 addition & 1 deletion network.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func (n *network) updateSvcRecord(ep *endpoint, isAdd bool) {

var sbList []*sandbox
n.WalkEndpoints(func(e Endpoint) bool {
if sb, hasSandbox := e.(*endpoint).getSandbox(); hasSandbox {
if sb, hasSandbox := e.(*endpoint).getSandbox(); hasSandbox && !sb.isRemote() {
sbList = append(sbList, sb)
}
return false
Expand Down
8 changes: 8 additions & 0 deletions sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (
"github.com/docker/libnetwork/types"
)

const (
remoteCID = "remote"
)

// Sandbox provides the control over the network container entity. It is a one to one mapping with the container.
type Sandbox interface {
// ID returns the ID of the sandbox
Expand Down Expand Up @@ -124,6 +128,10 @@ func (sb *sandbox) Labels() map[string]interface{} {
return sb.config.generic
}

func (sb *sandbox) isRemote() bool {
return sb.containerID == remoteCID
}

func (sb *sandbox) Statistics() (map[string]*osl.InterfaceStatistics, error) {
m := make(map[string]*osl.InterfaceStatistics)

Expand Down

0 comments on commit 914ca1a

Please sign in to comment.