Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Error: Property 'Box' must be set #857

Open
havok4u opened this issue Feb 8, 2018 · 0 comments
Open

Error: Property 'Box' must be set #857

havok4u opened this issue Feb 8, 2018 · 0 comments

Comments

@havok4u
Copy link

havok4u commented Feb 8, 2018

Pulled down code yesterday and was trying to get infrakit to launch with the vagrant plugin. Launched the plugin and the did a `infrakit local vagrant provision vagrant-centos7-vm.json. I then get the error:
CRIT[02-08|08:08:43] error executing module=main cmd=infrakit err="Property 'Box' must be set" fn=main.main
Property 'Box' must be set

After some investigation I see that something in
github.com/docker/infrakit/pkg/provider/vagrant/plugin/instance/instance.go
must have changed in the method Provision. Your expecting properties["Box"] to be a string, but actually it is a series of map[string]interface{}'s I put some debug code in to see what was going on, the first set shows that spec.Properties is actually the following json:

Debug: spec.Properties -> {"Instance":{"Plugin":"instance-vagrant","Properties":{"CPUs":1,"Memory":1024,"Box":"centos7"}},"Flavor":{"Plugin":"flavor-vanilla","Properties":{"Size":3,"UserData":["curl https://experimental.docker.com |sudo bash","sudo service docker start"],"Labels":{"tier":"docker-engines","project":"infrakit"}}}}

Debug: spec.Properties type -> *types.Any

I then print properties out and its type:
Debug: properties -> map[Flavor:map[Plugin:flavor-vanilla Properties:map[Size:3 UserData:[curl https://experimental.docker.com |sudo bash sudo service docker start] Labels:map[tier:docker-engines project:infrakit]]] Instance:map[Plugin:instance-vagrant Properties:map[CPUs:1 Memory:1024 Box:centos7]]]

Debug: properties type -> map[string]interface {}

I modified the code in the instance file to what I believe your expecting by putting the following in:

--- a/pkg/provider/vagrant/plugin/instance/instance.go
+++ b/pkg/provider/vagrant/plugin/instance/instance.go
@@ -111,7 +111,7 @@ func (v vagrantPlugin) Provision(spec instance.Spec) (*instance.ID, error) {
return nil, fmt.Errorf("Invalid instance properties: %s", err)
}
}

  •     **properties = properties["Instance"].(map[string]interface{})["Properties"].(map[string]interface{})**
      if properties["Box"] == nil {
              return nil, errors.New("Property 'Box' must be set")
      }
    

This temporarily fixes the issue and everything works. I suspect the spec.Properties.Decode is to pass in only the properties part which is "Properties":{"CPUs":1,"Memory":1024,"Box":"centos7"}, but instead it decodes and returns all of it burying properties 2 deep into a map[string]interface{}

I am not sure where the proper place to fix this is though as the decode method is pretty straight forward and handles any input.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant