test-kitchen / kitchen-openstack

OpenStack Compute driver for Test-Kitchen
Other
56 stars 77 forks source link

Add error handling for invalid certificate. #192

Closed alex-w-k closed 5 years ago

alex-w-k commented 6 years ago

Was troubleshooting an issue with test kitchen not connecting to openstack and giving very vague errors when I couldn't connect.

I would recieve:

E, [2018-10-18T08:48:12.520664 #32090] ERROR -- default-CentOS-72: Message: Expected([200, 201]) <=> Actual(404 Not Found)
excon.error.response
  :body          => "{\"error\": {\"message\": \"The resource could not be found.\", \"code\": 404, \"title\": \"Not Found\"}}"
  :cookies       => [
  ]
  :headers       => {
    "Content-Length"         => "93"
    "Content-Type"           => "application/json"
    "Date"                   => "Thu, 18 Oct 2018 14:48:12 GMT"
    "Server"                 => "Apache/2.4.18 (Ubuntu)"
    "Vary"                   => "X-Auth-Token,Accept-Encoding"
    "X-Distribution"         => "Ubuntu"
    "x-openstack-request-id" => "req-8afd1adc-929e-43f6-aa4f-2d01487faa05"
  }
  :host          => "openstack.server.com"
  :local_address => "***.***.***.***"
  :local_port    => 60739
  :path          => "/v3/tokens/v3/auth/tokens"
  :port          => 5000
  :reason_phrase => "Not Found"
  :remote_ip     => "22.254.0.20"
  :status        => 404
  :status_line   => "HTTP/1.1 404 Not Found\r\n"

Which made it basically impossible to troubleshoot until I downloaded the openstack CLI and attempted to connect to the server manually in which I got this error:

Failed to discover available identity versions when contacting https://openstack.server.com:5000/v3. Attempting to parse version from URL.
SSL exception connecting to https://openstack.server.com:5000/v3/auth/tokens: HTTPSConnectionPool(host='openstack.server.com', port=5000): Max retries exceeded with url: /v3/auth/tokens (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))

Not sure if through the APIs you are using it would be possible to add this error handling in, but that would be fantastic.

simplyunix commented 4 years ago

Hello there. Did you find a resolution to this problem?

Sashi

alex-w-k commented 4 years ago

:path => "/v3/tokens/v3/auth/tokens" The /v3/tokens is repeated in the path. I removed that and I got it fixed if I’m remembering it correctly. It was being added in the .kitchen.yml and the gem added it as well.

simplyunix commented 4 years ago

Thanks Alex. I have got this in my kitchen.yml file but I still get a message saying:

ERROR -- Kitchen: Message: Failed to complete #create action: [Missing required arguments: openstack_auth_url].

Any idea's I feel it may be my syntax :-)

driver: openstack_username: <%= ENV['demo'] %> openstack_api_key: <%= ENV['xxxxxxxx'] %> openstack_auth_url: <%= ENV['http://192.168.1.100:5000/v3/auth/tokens'] %> image_ref: <%= ENV['centos8.final'] %> flavor_ref: <%= ENV['m1.medium'] %>

simplyunix commented 4 years ago

Hi there.

The fix is as per below and is working properly now driver: name: openstack openstack_auth_url: 'http://x.x.x.x:5000' openstack_project: demo openstack_project_name: demo openstack_domain_id: default openstack_username: demo openstack_api_key: xxxxx

One needs all the off the above to get to the correct URL

Thanks