Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise an exception for unknown CSPs #1207

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion engines/scc_proxy/lib/scc_proxy/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ def get_instance_id(params)
nil,
params['instance_data']
)
instance_id_key = INSTANCE_ID_KEYS[params['hwinfo']['cloud_provider'].downcase.to_sym]
id_key = params['hwinfo']['cloud_provider'].downcase.to_sym
unless INSTANCE_ID_KEYS.key?(id_key)
error_message = 'Unknown cloud provider'
Rails.logger.error error_message
raise ActionController::TranslatedError.new(error_message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? I am unaware of any conversation at the business level where a decision was made that 3rd party CSPs that run their own update infrastructure are not allowed to offer BYOS pass through.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the CSP is unknown we would not have a valid value for system_token

do we not care about that ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand what the system_token has to do with this change. Nor what system_token has to do with now breaking functionality for 3rd party CSPs that previously probably worked when disable_system_tokens: true is set in the rmt.conf file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are setting the system_token for BYOS systems and we use system_token to get the system

The method get_instance_id is the method that sets that value

end
instance_id_key = INSTANCE_ID_KEYS[id_key]
iid = verification_provider.parse_instance_data
iid[instance_id_key]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
hypervisor: 'Xen',
arch: 'x86_64',
uuid: 'ec235f7d-b435-e27d-86c6-c8fef3180a01',
cloud_provider: 'super_cloud'
cloud_provider: 'amazon'
}
}
end
Expand Down Expand Up @@ -110,7 +110,7 @@
hypervisor: 'Xen',
arch: 'x86_64',
uuid: 'ec235f7d-b435-e27d-86c6-c8fef3180a01',
cloud_provider: 'super_cloud'
cloud_provider: 'amazon'
}
}
end
Expand Down Expand Up @@ -151,6 +151,34 @@
end
end

context 'unknown cloud provider' do
let(:params) do
{
hostname: 'test',
proxy_byos_mode: :payg,
instance_data: instance_data,
hwinfo:
{
hostname: 'test',
cpus: '1',
sockets: '1',
hypervisor: 'Xen',
arch: 'x86_64',
uuid: 'ec235f7d-b435-e27d-86c6-c8fef3180a01',
cloud_provider: 'super_cloud'
}
}
end

it 'returns error' do
post '/connect/subscriptions/systems', params: params, headers: { HTTP_AUTHORIZATION: 'Token token=bar' }
data = JSON.parse(response.body)
expect(response.code).to eq('422')
expect(data['type']).to eq('error')
expect(data['error']).to include('Unknown cloud provider')
end
end

context 'unreachable server' do
before do
stub_request(:post, scc_register_system_url)
Expand Down