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

Image Service doesn't validate supported versions anymore #438

Closed
beyhan opened this issue Sep 24, 2018 · 6 comments
Closed

Image Service doesn't validate supported versions anymore #438

beyhan opened this issue Sep 24, 2018 · 6 comments

Comments

@beyhan
Copy link
Contributor

beyhan commented Sep 24, 2018

Description:
The fog openstack image service does not check for supported versions anymore. Previously, a Fog::OpenStack::Errors::ServiceUnavailable was raised.

How to reproduce:
Run the following script with fog-openstack version 0.1.19 against an Openstack wich does not support image version 1:

require 'fog/openstack'

image = Fog::Image::OpenStack::V1.new({
  :openstack_api_key => “…”,
  :openstack_username => “…”,
  :openstack_auth_url => ‘…’,
  :openstack_project_name => “…”,
  :openstack_project_id => “…”,
  :openstack_user_domain => “…”,
  :openstack_endpoint_type => ‘…’,
})

puts image.images.all

The output is

/Users/cpi/.rvm/gems/ruby-2.4.4/gems/fog-openstack-0.1.19/lib/fog/openstack.rb:592:in `get_supported_version_path': OpenStack service only supports API versions /v1(\.(0|1))*/ (Fog::OpenStack::Errors::ServiceUnavailable)
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/fog-openstack-0.1.19/lib/fog/image/openstack/v1.rb:123:in `set_api_path'
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/fog-openstack-0.1.19/lib/fog/image/openstack/v1.rb:115:in `initialize'
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/fog-core-1.43.0/lib/fog/core/service.rb:115:in `new'
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/fog-core-1.43.0/lib/fog/core/service.rb:115:in `new'
	from /Users/cpi/workspace/fog-examples/lib/image-test.rb:3:in `<main>'

Process finished with exit code 1

Then, run the same script with fog-openstack version 1.0.0.
The output is

/Users/cpi/.rvm/gems/ruby-2.4.4/gems/excon-0.62.0/lib/excon/middlewares/expects.rb:7:in `response_call': Expected([200, 204]) <=> Actual(300 Multiple Choices) (Excon::Error::MultipleChoices)
excon.error.response
  :body          => "{\"versions\": [{\"status\": \"CURRENT\", \"id\": \"v2.4\", \"links\": [{\"href\": \"<openstack-url>/v2/\", \"rel\": \"self\"}]}, {\"status\": \"SUPPORTED\", \"id\": \"v2.3\", \"links\": [{\"href\": \"<openstack-url>/v2/\", \"rel\": \"self\"}]}, {\"status\": \"SUPPORTED\", \"id\": \"v2.2\", \"links\": [{\"href\": \"<openstack-url>/v2/\", \"rel\": \"self\"}]}, {\"status\": \"SUPPORTED\", \"id\": \"v2.1\", \"links\": [{\"href\": \"<openstack-url>/v2/\", \"rel\": \"self\"}]}, {\"status\": \"SUPPORTED\", \"id\": \"v2.0\", \"links\": [{\"href\": \"<openstack-url>/v2/\", \"rel\": \"self\"}]}]}"
  :cookies       => [
  ]
  :headers       => {
    "Connection"     => "close"
    "Content-Length" => "627"
    "Content-Type"   => "application/json"
    "Date"           => "Mon, 24 Sep 2018 13:49:41 GMT"
  }
  :host          => "<openstack-host>"
  :local_address => "<local_address>"
  :local_port    => 63663
  :path          => "/v1/images/detail"
  :port          => 9292
  :reason_phrase => "Multiple Choices"
  :remote_ip     => "<remote_ip>"
  :status        => 300
  :status_line   => "HTTP/1.1 300 Multiple Choices\r\n"
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/excon-0.62.0/lib/excon/middlewares/response_parser.rb:9:in `response_call'
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/excon-0.62.0/lib/excon/connection.rb:414:in `response'
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/excon-0.62.0/lib/excon/connection.rb:263:in `request'
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/fog-core-2.1.2/lib/fog/core/connection.rb:79:in `request'
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/fog-openstack-1.0.0/lib/fog/openstack/core.rb:53:in `request'
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/fog-openstack-1.0.0/lib/fog/openstack/image/v1/requests/list_public_images_detailed.rb:17:in `list_public_images_detailed'
	from /Users/cpi/.rvm/gems/ruby-2.4.4/gems/fog-openstack-1.0.0/lib/fog/openstack/image/v1/models/images.rb:12:in `all'
	from /Users/cpi/workspace/fog-examples/lib/image-test-new-version.rb:19:in `<main>'

Process finished with exit code 1

Desired behavior:
Fog openstack raises an exception if a version is not supported.
For example, in the current version 1.0.0 of fog openstack, the volume (cinder) service raises a Fog::OpenStack::Auth::Catalog::ServiceTypeError error.

Debugging:
We assume that the following commit didn't only refactor, but also changed functionality in the sense that no validation is happening anymore.

The exception doesn't get raised since in Glance, the service type is the same for v1 and v2.
However, raising the exception works for Cinder because the service type is different for v1 and v2.

@gildub
Copy link
Collaborator

gildub commented Sep 25, 2018

@beyhan, thank you for reporting this issue. I'll look into it ASAP.

@gildub
Copy link
Collaborator

gildub commented Sep 26, 2018

@beyhan, you're right the service type "image" is conflicting between V1 and V2. V1 is deprecated as V2 is the default and unfortunately OpenStack Image service didn't publish the V2 service as "imagev2".
Therefore renaming the service type "imagev1" seems to be the best option for us.

@beyhan
Copy link
Contributor Author

beyhan commented Sep 26, 2018

@gildub Thanks for the prompt response! Are there plans for a new release with the fix?

@gildub
Copy link
Collaborator

gildub commented Sep 26, 2018

@beyan, absolutely, later today (my time down under).

@gildub
Copy link
Collaborator

gildub commented Sep 27, 2018

@beyhan, v1.0.1 and v0.3.4 have been released.

@gildub gildub closed this as completed Sep 27, 2018
@beyhan
Copy link
Contributor Author

beyhan commented Sep 28, 2018

@gildub Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants