docker-archive / deploykit

A toolkit for creating and managing declarative, self-healing infrastructure.
Apache License 2.0
2.25k stars 262 forks source link

Error: Property 'Box' must be set #857

Open havok4u opened 6 years ago

havok4u commented 6 years ago

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) } }

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.