cloudfoundry/bosh — pull request #710 by allomov (2014-12-05 16:42:24+00:00)
Title: [bosh releases] Fix issue with having empty `release_versions` array in release parameters

Hey, all.

## Description

Sometimes data about releases is not stored and returned properly. I faced problem when `release_versions` is returned as an empty array. This PR helps BOSH not to fail in this case.

## Motivation

Not long ago I had an issue when blobstore client was not able to connect to blobstore. This caused failing `bosh upload release` command with following error:
```
Started creating new packages > admin_ui/d8d5adcd22b78b9ec17637414e48b372a910420a.
Failed: Failed to create object, underlying error:
#
/var/vcap/packages/director/gem_home/ruby/2.1.0/gems/httpclient-2.4.0/lib/httpclient/session.rb:805:in `initialize'
```
(details are in this [gist](https://gist.github.com/allomov/d7822d6f86ae35fdefce))

After that I couldn't get list of releases with `bosh releases` command having following problem:
```
ubuntu@cf-deployer:~$ bosh releases
/home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bosh_cli-1.2719.0/lib/cli/commands/release/list_releases.rb:59:in `block (2 levels) in build_releases_table': undefined method `join' for nil:NilClass (NoMethodError)
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bosh_cli-1.2719.0/lib/cli/commands/release/list_releases.rb:57:in `each'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bosh_cli-1.2719.0/lib/cli/commands/release/list_releases.rb:57:in `block in build_releases_table'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/terminal-table-1.4.5/lib/terminal-table/table.rb:210:in `yield_or_eval'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/terminal-table-1.4.5/lib/terminal-table/table.rb:17:in `initialize'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/terminal-table-1.4.5/lib/terminal-table/table_helper.rb:5:in `new'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/terminal-table-1.4.5/lib/terminal-table/table_helper.rb:5:in `table'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bosh_cli-1.2719.0/lib/cli/commands/release/list_releases.rb:54:in `build_releases_table'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bosh_cli-1.2719.0/lib/cli/commands/release/list_releases.rb:19:in `list'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bosh_cli-1.2719.0/lib/cli/command_handler.rb:57:in `run'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bosh_cli-1.2719.0/lib/cli/runner.rb:56:in `run'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bosh_cli-1.2719.0/lib/cli/runner.rb:16:in `run'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/gems/bosh_cli-1.2719.0/bin/bosh:7:in `'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/bin/bosh:23:in `load'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/bin/bosh:23:in `

'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/bin/ruby_executable_hooks:15:in `eval'
from /home/ubuntu/.rvm/gems/ruby-1.9.3-p547@global/bin/ruby_executable_hooks:15:in `

'
```

The problem was that `release['release_versions']` array was empty. This PR fixes it.

In some time issue with storing releases could be fixed, but I think that there are cases `release_versions` will also be empty.