Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/instance/hyperkit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ func main() {
hyperkitCmd := cmd.Flags().String("hyperkit-cmd", "hyperkit", "Path to HyperKit executable")
vpnkitSock := cmd.Flags().String("vpnkit-sock", "auto", "Path to VPNKit UNIX domain socket")
listen := cmd.Flags().String("listen", "localhost:24865", "Listens on port")
advertise := cmd.Flags().StringP("advertise", "a", "192.168.65.1:24865",
"Hostname for discovery (e.g. to containers). Use 192.168.65.1:24865 if running infrakit in containers on D4M")

cmd.RunE = func(c *cobra.Command, args []string) error {

os.MkdirAll(*vmDir, os.ModePerm)

cli.SetLogLevel(*logLevel)
cli.RunListener(*listen, *name,
cli.RunListener([]string{*listen, *advertise}, *name,
instance_plugin.PluginServer(hyperkit.NewPlugin(*vmDir, *hyperkitCmd, *vpnkitSock)),
metadata_plugin.PluginServer(metadata.NewPluginFromData(
map[string]interface{}{
Expand Down
7 changes: 4 additions & 3 deletions dockerfiles/Dockerfile.installer
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM golang:1.8-alpine

RUN apk add --update git make gcc musl-dev wget ca-certificates openssl libvirt-dev git
RUN apk add --update git make gcc musl-dev wget ca-certificates openssl libvirt-dev git openssh

ENV GOPATH /go
ENV PATH /go/bin:$PATH

RUN go get github.com/docker/infrakit/cmd/infrakit

COPY dockerfiles/build-infrakit /usr/local/bin/
COPY dockerfiles/build-hyperkit /usr/local/bin/

# Add source code
Add . /go/src/github.com/docker/infrakit/
2 changes: 1 addition & 1 deletion dockerfiles/build-hyperkit
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DOCKER_CLIENT_VERSION=1.24
BINARY=infrakit-instance-hyperkit
PACKAGE=github.com/docker/infrakit/cmd/instance/hyperkit

go build -o /build/${BINARY} -buildmode pie \
go build -o /build/${BINARY} \
-ldflags "-s -w -X github.com/docker/infrakit/pkg/cli.Version=${VERSION} -X github.com/docker/infrakit/pkg/cli.Revision=${REVISION} -X github.com/docker/infrakit/pkg/util/docker.ClientVersion=${DOCKER_CLIENT_VERSION} -extldflags \"-static\"" \
${PACKAGE}

Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/serverutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ func RunPlugin(name string, plugin server.VersionedInterface, more ...server.Ver

socketPath := path.Join(dir, name)
pidPath := path.Join(dir, name+".pid")
run("", socketPath, pidPath, plugin, more...)
run(nil, socketPath, pidPath, plugin, more...)
}

// RunListener runs a plugin server, listening at listen address, and
// advertising with the provided name for discovery.
// The plugin should conform to the rpc call convention as implemented in the rpc package.
func RunListener(listen, name string, plugin server.VersionedInterface, more ...server.VersionedInterface) {
func RunListener(listen []string, name string, plugin server.VersionedInterface, more ...server.VersionedInterface) {
dir := local.Dir()
EnsureDirExists(dir)

Expand All @@ -39,12 +39,12 @@ func RunListener(listen, name string, plugin server.VersionedInterface, more ...
run(listen, discoverPath, pidPath, plugin, more...)
}

func run(listen, discoverPath, pidPath string,
func run(listen []string, discoverPath, pidPath string,
plugin server.VersionedInterface, more ...server.VersionedInterface) {

var stoppable server.Stoppable

if listen != "" {
if len(listen) > 0 {
s, err := server.StartListenerAtPath(listen, discoverPath, plugin, more...)
if err != nil {
logrus.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/discovery/local/dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestDirDiscovery(t *testing.T) {
T(100).Infoln("Starting server2")
name2 := "server2"
path2 := filepath.Join(dir, name2+".listen")
server2, err := server.StartListenerAtPath("localhost:7777", path2, rpc.PluginServer(nil))
server2, err := server.StartListenerAtPath([]string{"localhost:7777"}, path2, rpc.PluginServer(nil))
require.NoError(t, err)
require.NotNil(t, server2)

Expand Down
20 changes: 12 additions & 8 deletions pkg/rpc/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ type VersionedInterface interface {

// StartListenerAtPath starts an HTTP server listening on tcp port with discovery entry at specified path.
// Returns a Stoppable that can be used to stop or block on the server.
func StartListenerAtPath(listen, discoverPath string,
func StartListenerAtPath(listen []string, discoverPath string,
receiver VersionedInterface, more ...VersionedInterface) (Stoppable, error) {
return startAtPath(listen, discoverPath, receiver, more...)
}

// StartPluginAtPath starts an HTTP server listening on a unix socket at the specified path.
// Returns a Stoppable that can be used to stop or block on the server.
func StartPluginAtPath(socketPath string, receiver VersionedInterface, more ...VersionedInterface) (Stoppable, error) {
return startAtPath("", socketPath, receiver, more...)
return startAtPath(nil, socketPath, receiver, more...)
}

func startAtPath(listen, discoverPath string,
func startAtPath(listen []string, discoverPath string,
receiver VersionedInterface, more ...VersionedInterface) (Stoppable, error) {

server := rpc.NewServer()
Expand Down Expand Up @@ -179,18 +179,22 @@ func startAtPath(listen, discoverPath string,

var listener net.Listener

if listen != "" {
if len(listen) > 0 {
gracefulServer.Server = &http.Server{
Addr: listen,
Addr: listen[0],
Handler: router,
}
l, err := net.Listen("tcp", listen)
l, err := net.Listen("tcp", listen[0])
if err != nil {
return nil, err
}
listener = l

if err := ioutil.WriteFile(discoverPath, []byte(fmt.Sprintf("tcp://%s", listen)), 0644); err != nil {
advertise := listen[0]
if len(listen) > 1 {
advertise = listen[1]
}
if err := ioutil.WriteFile(discoverPath, []byte(fmt.Sprintf("tcp://%s", advertise)), 0644); err != nil {
return nil, err
}

Expand All @@ -216,7 +220,7 @@ func startAtPath(listen, discoverPath string,
log.Warn(err)
}
events.Stop()
if listen != "" {
if len(listen) > 0 {
os.Remove(discoverPath)
}
}()
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestTCPServer(t *testing.T) {

discover := filepath.Join(os.TempDir(), fmt.Sprintf("%d.listen", time.Now().Unix()))
name := plugin.Name(filepath.Base(discover))
server, err := StartListenerAtPath("localhost:7777", discover, service)
server, err := StartListenerAtPath([]string{"localhost:7777"}, discover, service)
require.NoError(t, err)

c, err := plugin_rpc.NewClient(name, discover)
Expand Down
8 changes: 7 additions & 1 deletion vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
# package
github.com/docker/infrakit

github.com/Masterminds/sprig 2.10.0
github.com/Masterminds/semver v1.3.0
github.com/Masterminds/sprig 2.10.0
github.com/Microsoft/go-winio 0.3.6
github.com/Sirupsen/logrus v0.11.0-5-gabc6f20
github.com/aokoli/goutils 1.0.0
github.com/armon/go-radix 4239b77
github.com/aws/aws-sdk-go/aws v1.8.20
github.com/aws/aws-sdk-go/aws/credentials v1.8.20
github.com/aws/aws-sdk-go/aws/session v1.8.20
github.com/aws/aws-sdk-go/service/s3 v1.8.20
github.com/beorn7/perks 4c0e845
github.com/beorn7/perks/quantile 4c0e845
github.com/coreos/etcd/auth/authpb v3.1.3
Expand Down Expand Up @@ -77,8 +81,10 @@ github.com/vaughan0/go-ini a98ad7e
golang.org/x/crypto/pbkdf2 b07d8c9
golang.org/x/crypto/scrypt aa2481c
golang.org/x/net 0dd7c8d
golang.org/x/oauth2/google a6bd8ce
golang.org/x/sys b699b70
golang.org/x/text a263ba8
google.golang.org/api/storage/v1 16ab375
google.golang.org/grpc v1.0.4
google.golang.org/grpc/codes v1.0.4
google.golang.org/grpc/credentials v1.0.4
Expand Down
145 changes: 145 additions & 0 deletions vendor/github.com/aws/aws-sdk-go/aws/awserr/error.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading