From 1b442b9c2360c73722376780e417fa7e957c5016 Mon Sep 17 00:00:00 2001 From: Long Nguyen Date: Mon, 31 Jan 2022 12:55:00 -0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9E=20Integration=20tests=20pass?= =?UTF-8?q?=20in=20CPI=20version=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The latest commits check to make sure that the `api_version` was passed in to the CPI along with the other arguments (`method`, `arguments`, `context`); however, our integration tests were not updated to pass in the API version, and thus our integration tests failed. Our integration tests now pass in the API version (2, in case you're interested). fixes: ``` expected: nil got: {"type"=>"Bosh::Clouds::CloudError", "message"=>"Invalid api_version ''", "ok_to_retry"=>false} ``` Signed-off-by: Brian Cunnie --- .../spec/integration/azure_cpi_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bosh_azure_cpi/spec/integration/azure_cpi_spec.rb b/src/bosh_azure_cpi/spec/integration/azure_cpi_spec.rb index e7729a84a..37070e8b0 100644 --- a/src/bosh_azure_cpi/spec/integration/azure_cpi_spec.rb +++ b/src/bosh_azure_cpi/spec/integration/azure_cpi_spec.rb @@ -48,7 +48,7 @@ end it 'should call Azure management endpoint with a valid access token' do - result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }) + result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2) expect(result.keys).to eq(%w[result error log]) expect(result['result']).to be_falsey expect(result['error']).to be_nil @@ -92,7 +92,7 @@ end it 'should call Azure management endpoint with a valid access token' do - result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }) + result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2) expect(result.keys).to eq(%w[result error log]) expect(result['result']).to be_falsey expect(result['error']).to be_nil @@ -130,7 +130,7 @@ end it 'will not evaluate anything that causes an exception and will return the proper message to stdout' do - result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }) + result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2) expect(result.keys).to eq(%w[result error log]) expect(result['result']).to be_nil expect(result['error']['message']).to match(%r{http code: 400. Azure authentication failed: Bad request. Please assure no typo in values of tenant_id, client_id or client_secret\/certificate}) @@ -169,7 +169,7 @@ end it 'will not evaluate anything that causes an exception and will return the proper message to stdout' do - result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }) + result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2) expect(result.keys).to eq(%w[result error log]) expect(result['result']).to be_nil expect(result['error']['message']).to match(%r{http code: 401. Azure authentication failed: Invalid tenant_id, client_id or client_secret\/certificate}) @@ -184,7 +184,7 @@ let(:cloud_properties) { {} } it 'will return an appropriate error message when passed an invalid config file' do - result = run_cpi('method' => 'ping', 'arguments' => [], 'context' => { 'director_uuid' => 'abc123' }) + result = run_cpi('method' => 'ping', 'arguments' => [], 'context' => { 'director_uuid' => 'abc123' }, 'api_version' => 2) expect(result.keys).to eq(%w[result error log]) expect(result['result']).to be_nil expect(result['error']).to eq( @@ -231,7 +231,7 @@ end it 'merges the context into the cloud_properties' do - result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => context) + result = run_cpi('method' => 'has_vm', 'arguments' => [SecureRandom.uuid.to_s], 'context' => context, 'api_version' => 2) expect(result.keys).to eq(%w[result error log]) expect(result['result']).to_not be_nil expect(result['result']).to be_falsey @@ -239,7 +239,7 @@ end it 'returns the api version' do - result = run_cpi('method' => 'info', 'arguments' => [], 'context' => context) + result = run_cpi('method' => 'info', 'arguments' => [], 'context' => context, 'api_version' => 2) expect(result['result']).to_not be_nil expect(result['error']).to be_nil expect(result['result']['api_version']).to eq(2) From f1f495c25dba8376c61a514604bc67c816fb7c8a Mon Sep 17 00:00:00 2001 From: Long Nguyen Date: Tue, 1 Feb 2022 14:45:24 -0500 Subject: [PATCH 2/3] Turns out nil is a valid cpi_api_version, the bosh 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 --- src/bosh_azure_cpi/lib/cloud/azure/cloud.rb | 2 +- src/bosh_azure_cpi/spec/unit/cloud/cloud_spec.rb | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/bosh_azure_cpi/lib/cloud/azure/cloud.rb b/src/bosh_azure_cpi/lib/cloud/azure/cloud.rb index e4484119f..d185638d8 100644 --- a/src/bosh_azure_cpi/lib/cloud/azure/cloud.rb +++ b/src/bosh_azure_cpi/lib/cloud/azure/cloud.rb @@ -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 diff --git a/src/bosh_azure_cpi/spec/unit/cloud/cloud_spec.rb b/src/bosh_azure_cpi/spec/unit/cloud/cloud_spec.rb index b3f289af1..05eaf02e6 100644 --- a/src/bosh_azure_cpi/spec/unit/cloud/cloud_spec.rb +++ b/src/bosh_azure_cpi/spec/unit/cloud/cloud_spec.rb @@ -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 } From 43a35791099b19ee0488efc82c9daddb67965c98 Mon Sep 17 00:00:00 2001 From: CI Date: Wed, 2 Feb 2022 14:17:54 +0000 Subject: [PATCH 3/3] New final release v38.0.0 --- .final_builds/jobs/azure_cpi/index.yml | 4 +++ .../packages/bosh_azure_cpi/index.yml | 4 +++ .../bosh-azure-cpi/bosh-azure-cpi-38.0.0.yml | 28 +++++++++++++++++++ releases/bosh-azure-cpi/index.yml | 2 ++ 4 files changed, 38 insertions(+) create mode 100644 releases/bosh-azure-cpi/bosh-azure-cpi-38.0.0.yml diff --git a/.final_builds/jobs/azure_cpi/index.yml b/.final_builds/jobs/azure_cpi/index.yml index fb176de80..dfb5d3da5 100644 --- a/.final_builds/jobs/azure_cpi/index.yml +++ b/.final_builds/jobs/azure_cpi/index.yml @@ -47,6 +47,10 @@ builds: version: 7505570ee4825fd31871e005157d43a79af7ad4d blobstore_id: b2044ffb-f21a-42b2-60d0-e93bdb125c74 sha1: 8e1afca62e2702ca1a0846769c93c9cad305e252 + 75d16e44e84858f146a52e926190da5187400905ebbc9536f3db90f9f20626af: + version: 75d16e44e84858f146a52e926190da5187400905ebbc9536f3db90f9f20626af + blobstore_id: b5648119-1c9b-4916-6ed5-99cbf219b999 + sha1: sha256:0ad3b4bbf0201346bfddba6b2a2215b0f9c84f6b47408220ad87fdd0ce325d0d 76930bbfe9adc298391cb0f8bc242e16be37d824466916705b06a119de4c1c4a: version: 76930bbfe9adc298391cb0f8bc242e16be37d824466916705b06a119de4c1c4a blobstore_id: 37f20e4b-9e6b-4c2b-5b60-471cb9a70f3e diff --git a/.final_builds/packages/bosh_azure_cpi/index.yml b/.final_builds/packages/bosh_azure_cpi/index.yml index 8d5fb07f3..119d69117 100644 --- a/.final_builds/packages/bosh_azure_cpi/index.yml +++ b/.final_builds/packages/bosh_azure_cpi/index.yml @@ -111,6 +111,10 @@ builds: version: 7f7074c6a2df2f6967ed59cbbbcc9125941afdf3 blobstore_id: 0307c7d1-2048-4ef5-a5f6-53ede1e980d4 sha1: 21b5de8edbfbe44dfdd1757d5dc048f6fd6c73e0 + 9a83ad939adb71925a3d03da535a75ac256b7e2ee86f04a6959dc4235c7d2749: + version: 9a83ad939adb71925a3d03da535a75ac256b7e2ee86f04a6959dc4235c7d2749 + blobstore_id: 405e94f5-1b7f-47b5-56f5-9fb418c240ff + sha1: sha256:c194f3146ee835915c94b0ca3cbb5f28a17d6ef1366a0382a11026c2cd1cb983 9ee80ffac7d5f183ad2d20d074f67d188948d154: version: 9ee80ffac7d5f183ad2d20d074f67d188948d154 blobstore_id: 0dc241d2-5edc-4afa-8269-8bb228bcd698 diff --git a/releases/bosh-azure-cpi/bosh-azure-cpi-38.0.0.yml b/releases/bosh-azure-cpi/bosh-azure-cpi-38.0.0.yml new file mode 100644 index 000000000..69a7e7fc6 --- /dev/null +++ b/releases/bosh-azure-cpi/bosh-azure-cpi-38.0.0.yml @@ -0,0 +1,28 @@ +name: bosh-azure-cpi +version: 38.0.0 +commit_hash: f1f495c +uncommitted_changes: false +jobs: +- name: azure_cpi + version: 75d16e44e84858f146a52e926190da5187400905ebbc9536f3db90f9f20626af + fingerprint: 75d16e44e84858f146a52e926190da5187400905ebbc9536f3db90f9f20626af + sha1: sha256:0ad3b4bbf0201346bfddba6b2a2215b0f9c84f6b47408220ad87fdd0ce325d0d + packages: + - ruby-2.7.3-r0.43.0 + - bosh_azure_cpi +packages: +- name: bosh_azure_cpi + version: 9a83ad939adb71925a3d03da535a75ac256b7e2ee86f04a6959dc4235c7d2749 + fingerprint: 9a83ad939adb71925a3d03da535a75ac256b7e2ee86f04a6959dc4235c7d2749 + sha1: sha256:c194f3146ee835915c94b0ca3cbb5f28a17d6ef1366a0382a11026c2cd1cb983 + dependencies: + - ruby-2.7.3-r0.43.0 +- name: ruby-2.7.3-r0.43.0 + version: 99c4d7fe18ef5287f062b73101b2b697fca340e7eac03b3ee87284b71e1c18d8 + fingerprint: 99c4d7fe18ef5287f062b73101b2b697fca340e7eac03b3ee87284b71e1c18d8 + sha1: sha256:2507840353929a72a2378481168e6d4ae1f2faa47939dfabb358a4724c1b634e + dependencies: [] +license: + version: 6b556bc2340dd2ef930d9fffb160c925cb6edf0f217c620f695c10e127a53d9a + fingerprint: 6b556bc2340dd2ef930d9fffb160c925cb6edf0f217c620f695c10e127a53d9a + sha1: sha256:1e0838be726423eb3d67c119075a1d0ea35d82d8bd66327a139abaa7d6a28a3c diff --git a/releases/bosh-azure-cpi/index.yml b/releases/bosh-azure-cpi/index.yml index db8f6c23d..4431b183f 100644 --- a/releases/bosh-azure-cpi/index.yml +++ b/releases/bosh-azure-cpi/index.yml @@ -51,6 +51,8 @@ builds: version: "8" 701c31e9-33e9-46f9-4347-4dbfd6b9f390: version: "34" + 7e847c23-242a-42d3-60ea-c5aa29d8a5d3: + version: 38.0.0 7fb7b095-78f6-42b6-ad4a-cddaa52e4ac0: version: "6" 80ee34a2-c451-46d8-8b02-7ea46045b50c: