Skip to content

Commit

Permalink
bugfix: bind an address for stream server
Browse files Browse the repository at this point in the history
Signed-off-by: YaoZengzeng <yaozengzeng@zju.edu.cn>
  • Loading branch information
YaoZengzeng committed Jun 14, 2018
1 parent 578caa9 commit d8ba256
Show file tree
Hide file tree
Showing 5 changed files with 1,108 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cri/v1alpha1/cri_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ import (
apitypes "github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/cri/stream/remotecommand"
"github.com/alibaba/pouch/daemon/mgr"
pouchnet "github.com/alibaba/pouch/pkg/net"

"github.com/sirupsen/logrus"
)

func newStreamServer(ctrMgr mgr.ContainerMgr, address string, port string) (Server, error) {
if address == "" {
a, err := pouchnet.ChooseBindAddress(nil)
if err != nil {
return nil, fmt.Errorf("failed to get stream server address: %v", err)
}
address = a.String()
}
config := DefaultConfig
config.Address = net.JoinHostPort(address, port)
runtime := newStreamRuntime(ctrMgr)
Expand Down
8 changes: 8 additions & 0 deletions cri/v1alpha2/cri_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ import (
apitypes "github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/cri/stream/remotecommand"
"github.com/alibaba/pouch/daemon/mgr"
pouchnet "github.com/alibaba/pouch/pkg/net"

"github.com/sirupsen/logrus"
)

func newStreamServer(ctrMgr mgr.ContainerMgr, address string, port string) (Server, error) {
if address == "" {
a, err := pouchnet.ChooseBindAddress(nil)
if err != nil {
return nil, fmt.Errorf("failed to get stream server address: %v", err)
}
address = a.String()
}
config := DefaultConfig
config.Address = net.JoinHostPort(address, port)
runtime := newStreamRuntime(ctrMgr)
Expand Down
5 changes: 5 additions & 0 deletions pkg/net/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package net

// NOTE: The code in this package is directly copy from package "k8s.io/apimachinery/pkg/util/net".
// We do this because we don't want to vendor too many irrelevant packages and try to make
// the code simple and clean :)
Loading

0 comments on commit d8ba256

Please sign in to comment.