From 5d164b04c298cdc522005e862f5adad28ebfca9a Mon Sep 17 00:00:00 2001 From: David Chung Date: Tue, 16 May 2017 15:19:16 -0700 Subject: [PATCH 1/2] Playbook fix; change warnings to debug statements for CLI Signed-off-by: David Chung --- docs/playbooks/linuxkit/start-infrakit.sh | 4 ++-- pkg/cli/registry.go | 6 +++--- pkg/cli/remote/remote.go | 6 +++--- pkg/template/fetch.go | 4 ++++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/playbooks/linuxkit/start-infrakit.sh b/docs/playbooks/linuxkit/start-infrakit.sh index c54037bb9..9bcb69959 100644 --- a/docs/playbooks/linuxkit/start-infrakit.sh +++ b/docs/playbooks/linuxkit/start-infrakit.sh @@ -49,9 +49,9 @@ docker run -d --volumes-from infrakit --name manager \ echo "Updating hosts file" {{ $hostsFile := list (env `INFRAKIT_HOME`) `/hosts` | join `` }} {{ $hosts := include (list `file://` $hostsFile | join ``) | yamlDecode }} -{{ $_ := set $hosts `localhost` (list `localhost` $port | join `:`) }} +{{ $_ := set $hosts `docker4mac` (list `localhost` $port | join `:`) }} echo "{{ $hosts | yamlEncode }}" > {{ $hostsFile }} -echo "Updated hosts file. You are using the host `localhost` as defined in your hosts file in INFRAKIT_HOME/hosts" +echo "Updated hosts file. You are using the remote `docker4mac` as defined in your hosts file in INFRAKIT_HOME/hosts" echo "Started hyperkit: {{ var `started-hyperkit` }}" echo "Started gcp: {{ var `started-gcp` }}" diff --git a/pkg/cli/registry.go b/pkg/cli/registry.go index fdc1bdabb..b16e9be6c 100644 --- a/pkg/cli/registry.go +++ b/pkg/cli/registry.go @@ -50,14 +50,14 @@ func getPluginObjects(hs rpc.Handshaker, major string) map[string][]spi.Interfac // The spi this object implements (e.g. Instance/0.5.0) spis, err := hs.Implements() if err != nil { - log.Warn("error getting interface", "name", major, "err", err) + log.Debug("error getting interface", "name", major, "err", err) return objects } // For each spi, eg. Instance/0.5.0 a list of object names typesBySpi, err := hs.Types() if err != nil { - log.Warn("error getting typed objects in this plugin", "name", major, "err", err) + log.Debug("error getting typed objects in this plugin", "name", major, "err", err) // Here we assume there are no lower level objects objects[major] = spis @@ -108,7 +108,7 @@ func LoadAll(services *Services) ([]*cobra.Command, error) { for major, entry := range running { hs, err := client.NewHandshaker(entry.Address) if err != nil { - log.Warn("handshaker error", "err", err, "addr", entry.Address) + log.Debug("handshaker error", "err", err, "addr", entry.Address) continue } diff --git a/pkg/cli/remote/remote.go b/pkg/cli/remote/remote.go index 37e0ba263..6e6bc6a6b 100644 --- a/pkg/cli/remote/remote.go +++ b/pkg/cli/remote/remote.go @@ -115,7 +115,7 @@ loop: moduleURL = SourceURL(u.String()) } else { - log.Warn("cannot resolve", "op", op, "url", moduleURL, "parent", parentURL) + log.Debug("cannot resolve", "op", op, "url", moduleURL, "parent", parentURL) continue loop } } @@ -142,7 +142,7 @@ loop: copy := moduleURL subs, err := list(plugins, mods, input, cmd, ©) if err != nil { - log.Warn("cannot list", "op", op, "url", moduleURL, "err", err) + log.Debug("cannot list", "op", op, "url", moduleURL, "err", err) continue loop } for _, sub := range subs { @@ -158,7 +158,7 @@ loop: } err := ctx.BuildFlags() if err != nil { - log.Warn("cannot build flags", "op", op, "url", moduleURL, "err", err) + log.Debug("cannot build flags", "op", op, "url", moduleURL, "err", err) continue loop } diff --git a/pkg/template/fetch.go b/pkg/template/fetch.go index 30a1296b0..ae4a51db8 100644 --- a/pkg/template/fetch.go +++ b/pkg/template/fetch.go @@ -50,6 +50,10 @@ func doHTTPGet(u *url.URL, customize func(*http.Request), client *http.Client) ( if err != nil { return nil, err } + + if resp.StatusCode != http.StatusOK { + return []byte{}, fmt.Errorf("error %s", resp.Status) + } defer resp.Body.Close() return ioutil.ReadAll(resp.Body) } From 4473bf33a7f36526a1fd06b141d0dd616d5e2822 Mon Sep 17 00:00:00 2001 From: David Chung Date: Tue, 16 May 2017 16:14:52 -0700 Subject: [PATCH 2/2] fix bad playbook command line usage Signed-off-by: David Chung --- .../linuxkit/examples/sshd/hyperkit/destroy-instances.sh | 2 +- .../linuxkit/examples/sshd/hyperkit/list-instances.sh | 2 +- .../linuxkit/examples/sshd/packet/destroy-instances.sh | 2 +- .../playbooks/linuxkit/examples/sshd/packet/list-instances.sh | 2 +- docs/playbooks/linuxkit/examples/sshd/packet/scale-group.ikt | 4 ++-- pkg/plugin/instance/packet/plugin.go | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/playbooks/linuxkit/examples/sshd/hyperkit/destroy-instances.sh b/docs/playbooks/linuxkit/examples/sshd/hyperkit/destroy-instances.sh index ab3625529..28ab010d7 100644 --- a/docs/playbooks/linuxkit/examples/sshd/hyperkit/destroy-instances.sh +++ b/docs/playbooks/linuxkit/examples/sshd/hyperkit/destroy-instances.sh @@ -2,4 +2,4 @@ {{ $plugin := flag "instance-plugin" "string" "Name of plugin" | prompt "What instance plugin to target?" "string" "instance-hyperkit" }} -infrakit instance --name {{ $plugin }} describe -q | awk '{print $1}' | xargs infrakit instance --name {{ $plugin }} destroy +infrakit {{ $plugin }} describe -q | awk '{print $1}' | xargs infrakit instance --name {{ $plugin }} destroy diff --git a/docs/playbooks/linuxkit/examples/sshd/hyperkit/list-instances.sh b/docs/playbooks/linuxkit/examples/sshd/hyperkit/list-instances.sh index c0b5fb173..5de0ab647 100644 --- a/docs/playbooks/linuxkit/examples/sshd/hyperkit/list-instances.sh +++ b/docs/playbooks/linuxkit/examples/sshd/hyperkit/list-instances.sh @@ -1,3 +1,3 @@ {{/* =% sh %= */}} -infrakit instance --name instance-hyperkit describe +infrakit instance-hyperkit describe diff --git a/docs/playbooks/linuxkit/examples/sshd/packet/destroy-instances.sh b/docs/playbooks/linuxkit/examples/sshd/packet/destroy-instances.sh index b85cfa3f9..53317b2c9 100644 --- a/docs/playbooks/linuxkit/examples/sshd/packet/destroy-instances.sh +++ b/docs/playbooks/linuxkit/examples/sshd/packet/destroy-instances.sh @@ -2,4 +2,4 @@ {{ $plugin := flag "instance-plugin" "string" "Name of plugin" | prompt "What instance plugin to target?" "string" "instance-packet" }} -infrakit instance --name {{ $plugin }} describe -q | awk '{print $1}' | xargs infrakit instance --name {{ $plugin }} destroy +infrakit {{ $plugin }} describe -q | awk '{print $1}' | xargs infrakit instance --name {{ $plugin }} destroy diff --git a/docs/playbooks/linuxkit/examples/sshd/packet/list-instances.sh b/docs/playbooks/linuxkit/examples/sshd/packet/list-instances.sh index a8b1b53fe..cfb1b3d7d 100644 --- a/docs/playbooks/linuxkit/examples/sshd/packet/list-instances.sh +++ b/docs/playbooks/linuxkit/examples/sshd/packet/list-instances.sh @@ -1,3 +1,3 @@ {{/* =% sh %= */}} -infrakit instance --name instance-packet describe +infrakit instance-packet describe diff --git a/docs/playbooks/linuxkit/examples/sshd/packet/scale-group.ikt b/docs/playbooks/linuxkit/examples/sshd/packet/scale-group.ikt index 400f33b8b..ba7394b35 100644 --- a/docs/playbooks/linuxkit/examples/sshd/packet/scale-group.ikt +++ b/docs/playbooks/linuxkit/examples/sshd/packet/scale-group.ikt @@ -33,6 +33,8 @@ facility: {{ $facility }} operating_system: custom_ipxe billing_cycle: hourly + hostname_prefix: infrakit-{{ $groupName }} + checksum: {{ $checksum }} userdata: | #!ipxe @@ -42,5 +44,3 @@ kernel ${base-url}/{{$bundle}}-kernel ${kernel-params} initrd ${base-url}/{{$bundle}}-initrd.img boot - hostname_prefix: infrakit-demo - checksum: {{ $checksum }} diff --git a/pkg/plugin/instance/packet/plugin.go b/pkg/plugin/instance/packet/plugin.go index 3bc3aea84..61315633c 100644 --- a/pkg/plugin/instance/packet/plugin.go +++ b/pkg/plugin/instance/packet/plugin.go @@ -14,7 +14,7 @@ import ( "github.com/packethost/packngo" ) -var log = logutil.New("module", "plugin/instance/packetnet") +var log = logutil.New("module", "plugin/instance/packet") func init() { rand.Seed(time.Now().UTC().UnixNano())