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

Does not handle http 302 response in get_api_version_list #393

Open
THUzxj opened this issue Nov 12, 2022 · 2 comments · May be fixed by #395
Open

Does not handle http 302 response in get_api_version_list #393

THUzxj opened this issue Nov 12, 2022 · 2 comments · May be fixed by #395

Comments

@THUzxj
Copy link

THUzxj commented Nov 12, 2022

Hi, thanks for your great work.

My Neutron responses a 302 code when called /networking, but function get_api_version_list only handles code 200 and 300 and throws an error when getting this. I can offer to fix it.

One temporary solution is to set the endpoint in Vagrantfile like os.openstack_network_url = "http://neutron/networking/v2.0".

2022-11-12 16:31 |  INFO | Looking for available endpoints...
2022-11-12 16:31 | DEBUG | request  => method  : GET
2022-11-12 16:31 | DEBUG | request  => url     : http://neutron/networking
2022-11-12 16:31 | DEBUG | request  => headers : {"X-Auth-Token"=>"xxxxx", :accept=>:json}
2022-11-12 16:31 | DEBUG | response => code    : 302
2022-11-12 16:31 | DEBUG | response => headers : {:content_length=>"52", :content_type=>"application/json", :location=>"http://neutron/networking/", :date=>"Sat, 12 Nov 2022 16:31:18 GMT"}
2022-11-12 16:31 | DEBUG | response => body    : {"code": 302, "title": "Found", "description": null}
{"code": 302, "title": "Found", "description": null}
@THUzxj
Copy link
Author

THUzxj commented Nov 13, 2022

This issue is same as #171

ggiamarchi added a commit that referenced this issue Nov 23, 2022
@ggiamarchi ggiamarchi linked a pull request Nov 23, 2022 that will close this issue
@ggiamarchi
Copy link
Owner

Hi @THUzxj

I have been able to easily reproduce your issue on Devstack where the Neutron endpoint URL from the catalog redirects to a different URL with a 302 code.

In this plugin implementation, we use REST Client to perform HTTP calls. According to the documentation, REST Client is supposed to follow redirections as a default behavior.

It took me a couple of hours to understand why it is not the case here. I finally figured out that when we give a &block parameter when calling RestClient::Request.execute(), redirection is not followed.

I don't know if there is a good reason for that or if this is a bug in REST Client, I didn't deep dive into the code.

I refactored our code to not use Ruby blocks, it does the trick.

Feel free to test and review the PR #395

ggiamarchi added a commit that referenced this issue Nov 24, 2022
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

Successfully merging a pull request may close this issue.

2 participants