Skip to content

Commit

Permalink
Turns out nil is a valid cpi_api_version, the bosh
Browse files Browse the repository at this point in the history
looks for info command to determine cpi_api_version,
so on first call it is nil, this will cause error on
info rpc call that then causes BOSH to uses cpi_api_version = 1
which tne causes cascading effect as info rpc is called at
beginning of all cpi commands. Nil is considered a value
in ruby so we don't get default of 1, then we raise error on info call
  • Loading branch information
lnguyen committed Feb 1, 2022
1 parent 1b442b9 commit f1f495c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion src/bosh_azure_cpi/lib/cloud/azure/cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Cloud < Bosh::Cloud
#
# @param [Hash] options cloud options
def initialize(options, api_version = 1)
cloud_error("Invalid api_version '#{api_version}'") unless [1, 2].include?(api_version)
cloud_error("Invalid api_version '#{api_version}'") unless [1, 2, nil].include?(api_version)

options_dup = options.dup.freeze

Expand Down
10 changes: 0 additions & 10 deletions src/bosh_azure_cpi/spec/unit/cloud/cloud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@
end
end

context 'to api version nil' do
let(:api_version) { nil }

it 'raises an exception' do
expect do
mock_cloud(nil, api_version)
end.to raise_error(Bosh::Clouds::CloudError, "Invalid api_version '#{api_version}'")
end
end

context 'to api version 3' do
let(:api_version) { 3 }

Expand Down

0 comments on commit f1f495c

Please sign in to comment.