typesafehub / conductr-cli

CLI for Lightbend ConductR
Other
16 stars 21 forks source link

conduct load/deploy now reads the first bundle.conf file listed in the archive central directory #499

Closed longshorej closed 7 years ago

longshorej commented 7 years ago

Adjust conduct load and conduct deploy to read the first bundle.conf. Previously, this errored out if a bundle had multiple bundle.conf files. By reading the first one listed, we're also consistent with the logic in ConductR core.

Fixes https://github.com/typesafehub/conductr/issues/1811

longshorej commented 7 years ago

Thanks @fsat - I fixed the unit test to covert this scenario and verified that it fails without this PR, but with this PR now passes. Manual tests below:

Manual Tests

This test takes visualizer and unzips it. An empty bundle.conf is created in a subdirectory, and it is recreated with bndl.

We verify this fails to load on master, then load it on this PR and verify it succeeds, and finally confirm that the regular visualizer continues to work as well.

Setup

$ unzip /home/longshorej/.conductr/cache/bundle/visualizer-2.1.0-31fe9536b5f3252cc7b432ab06bd9ba31b7258d920f7147020392a7058074606.zipArchive:  /home/longshorej/.conductr/cache/bundle/visualizer-2.1.0-31fe9536b5f3252cc7b432ab06bd9ba31b7258d920f7147020392a7058074606.zip
  inflating: [snipped]
-> 0

$ mkdir visualizer-2.1.0/fake-conf
-> 0

$ touch visualizer-2.1.0/fake-conf/bundle.conf
-> 0

$ bndl visualizer-2.1.0 -o visualizer-double-confs.zip
-> 0

Multiple bundle.conf fails on master

$ (cd ~/work/lightbend/conductr-cli && git checkout master)

$ conduct load visualizer-double-confs.zip 
Retrieving bundle..
Loading bundle to ConductR..
Error: Unable to contact ConductR.                 ]   0%
Error: Reason: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
Error: Start the ConductR sandbox with: sandbox run IMAGE_VERSION
-> 1

Multiple bundle.conf succeeds with this PR

$ (cd ~/work/lightbend/conductr-cli && git checkout multiple-bundle-conf)

$ conduct load visualizer-double-confs.zip
Retrieving bundle..
Loading bundle to ConductR..
[##################################################] 100%
Bundle bd1f275d840c5f55894742826c1fa321 is installed
Bundle loaded.
Start bundle with:        conduct run bd1f275
Unload bundle with:       conduct unload bd1f275
Print ConductR info with: conduct info
Print bundle info with:   conduct info bd1f275
-> 0

$ conduct run bd1f275
Bundle run request sent.
Bundle bd1f275d840c5f55894742826c1fa321 waiting to reach expected scale 1
Bundle bd1f275d840c5f55894742826c1fa321 has scale 0, expected 1.
Bundle bd1f275d840c5f55894742826c1fa321 expected scale 1 is met
Stop bundle with:         conduct stop bd1f275
Print ConductR info with: conduct info
Print bundle info with:   conduct info bd1f275
-> 0

$ conduct stop bd1f275
Bundle stop request sent.
Bundle bd1f275d840c5f55894742826c1fa321 waiting to reach expected scale 0
Bundle bd1f275d840c5f55894742826c1fa321 has scale 1, expected 0
Bundle bd1f275d840c5f55894742826c1fa321 expected scale 0 is met
Unload bundle with:       conduct unload bd1f275
Print ConductR info with: conduct info
Print bundle info with:   conduct info bd1f275
-> 0

"happy path" still works

$ conduct load visualizer
Retrieving bundle..
Loading bundle from cache typesafe/bundle/visualizer
Bintray credentials loaded from /home/longshorej/.lightbend/commercial.credentials
Retrieving from cache /home/longshorej/.conductr/cache/bundle/visualizer-2.1.0-31fe9536b5f3252cc7b432ab06bd9ba31b7258d920f7147020392a7058074606.zip
Loading bundle to ConductR..
[##################################################] 100%
Bundle 31fe9536b5f3252cc7b432ab06bd9ba3 is installed
Bundle loaded.
Start bundle with:        conduct run 31fe953
Unload bundle with:       conduct unload 31fe953
Print ConductR info with: conduct info
Print bundle info with:   conduct info 31fe953
-> 0

$ conduct run 31fe953
Bundle run request sent.
Bundle 31fe9536b5f3252cc7b432ab06bd9ba3 waiting to reach expected scale 1
Bundle 31fe9536b5f3252cc7b432ab06bd9ba3 has scale 0, expected 1.
Bundle 31fe9536b5f3252cc7b432ab06bd9ba3 expected scale 1 is met
Stop bundle with:         conduct stop 31fe953
Print ConductR info with: conduct info
Print bundle info with:   conduct info 31fe953
-> 0