创建/获取loadbalaner失败,确认为skyline请求的后端url错误

Bug #2047624 reported by Alex Mercer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
skyline console
Fix Committed
Undecided
Unassigned

Bug Description

OpenStack版本为Victoria,skyline为最新master版本,创建或获取loadbalaner失败,报错为404,请求的目标url有问题,浏览器报错截图详见loadbalaner-error.png

{
  "message": {
    "code": 404,
    "title": "Not Found",
    "description": ""
  },
  "status": 404
}

我使用curl可以获取api版本信息
root@node-1:/opt/kolla-etc# curl http://192.168.27.253:9876
{"versions": [{"id": "v2.0", "status": "SUPPORTED", "updated": "2016-12-11T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.1", "status": "SUPPORTED", "updated": "2018-04-20T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.2", "status": "SUPPORTED", "updated": "2018-07-31T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.3", "status": "SUPPORTED", "updated": "2018-12-18T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.4", "status": "SUPPORTED", "updated": "2018-12-19T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.5", "status": "SUPPORTED", "updated": "2019-01-21T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.6", "status": "SUPPORTED", "updated": "2019-01-25T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.7", "status": "SUPPORTED", "updated": "2018-01-25T12:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.8", "status": "SUPPORTED", "updated": "2019-02-12T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.9", "status": "SUPPORTED", "updated": "2019-03-04T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.10", "status": "SUPPORTED", "updated": "2019-03-05T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.11", "status": "SUPPORTED", "updated": "2019-06-24T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.12", "status": "SUPPORTED", "updated": "2019-09-11T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.13", "status": "SUPPORTED", "updated": "2019-09-13T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.14", "status": "SUPPORTED", "updated": "2019-11-10T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.15", "status": "SUPPORTED", "updated": "2020-03-10T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.16", "status": "SUPPORTED", "updated": "2020-03-15T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.17", "status": "SUPPORTED", "updated": "2020-04-29T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.18", "status": "SUPPORTED", "updated": "2020-04-29T01:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.19", "status": "SUPPORTED", "updated": "2020-05-12T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.20", "status": "SUPPORTED", "updated": "2020-08-02T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.21", "status": "SUPPORTED", "updated": "2020-09-03T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.22", "status": "SUPPORTED", "updated": "2020-09-04T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}, {"id": "v2.23", "status": "CURRENT", "updated": "2020-09-07T00:00:00Z", "links": [{"href": "http://192.168.27.253:9876/v2", "rel": "self"}]}]}

通过检查octavia日志和skyline日志发现skyline请求的目标url不对,而正确的后端url应该是http://192.168.27.253:9876/v2/lbaas/loadbalancers

192.168.27.3 - - [27/Dec/2023:09:22:15 +0800] "0.051" "0.052" "POST /api/openstack/regionone/octavia/v2/lbaas/loadbalancers HTTP/1.1" 404 91 "http://192.168.27.253:9999/network/load-balancers/create" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0" "8.8.8.8, 192.168.11.82"
192.168.27.3 - - [27/Dec/2023:09:23:43 +0800] "0.006" "0.004" "POST /api/openstack/regionone/octavia/v2/lbaas/loadbalancers HTTP/1.1" 404 101 "http://192.168.27.253:9999/network/load-balancers/create" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0" "8.8.8.8, 192.168.11.82"
192.168.27.3 - - [27/Dec/2023:11:22:44 +0800] "0.007" "0.004" "GET /api/openstack/regionone/octavia/v2/lbaas/loadbalancers?limit=10&project_id=9d65fb5fbf2942ce82aa91f872dd8059 HTTP/1.1" 404 101 "http://192.168.27.253:9999/network/load-balancers" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0" "8.8.8.8, 192.168.11.82"
192.168.27.3 - - [27/Dec/2023:11:24:17 +0800] "0.005" "0.004" "GET /api/openstack/regionone/octavia/v2/lbaas/loadbalancers?limit=10&project_id=9d65fb5fbf2942ce82aa91f872dd8059 HTTP/1.1" 404 91 "http://192.168.27.253:9999/network/load-balancers" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0" "8.8.8.8, 192.168.11.82"
192.168.27.3 - - [27/Dec/2023:11:25:50 +0800] "0.005" "0.004" "GET /api/openstack/regionone/octavia/v2/lbaas/loadbalancers?limit=10&project_id=9d65fb5fbf2942ce82aa91f872dd8059 HTTP/1.1" 404 91 "http://192.168.27.253:9999/network/load-balancers" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl

测试正确的url:
curl -X GET -H "X-Auth-Token: $Token" -H "Content-Type: application/json" http://192.168.27.253:9876/v2/lbaas/loadbalancers?project_id=9d65fb5fbf2942ce82aa91f872dd8059
{"loadbalancers": [{"id": "0e411692-640e-4a9d-88fc-55fe5fa687db", "name": "test", "description": "", "provisioning_status": "ACTIVE", "operating_status": "OFFLINE", "admin_state_up": true, "project_id": "9d65fb5fbf2942ce82aa91f872dd8059", "created_at": "2023-12-28T07:37:12", "updated_at": "2023-12-28T07:38:11", "vip_address": "192.168.25.59", "vip_port_id": "7fc920a6-b1e7-43ed-96be-29f3535c30e7", "vip_subnet_id": "f4baaa15-8f51-4313-9f41-3ecc896cf083", "vip_network_id": "92870d00-02e1-43e8-9b61-cb47a267ae18", "listeners": [{"id": "355ee073-8f6f-4614-aaad-1e068435c392"}], "pools": [{"id": "daaf04dc-9032-4670-8d10-9692fcefa33d"}], "provider": "amphora", "flavor_id": null, "vip_qos_policy_id": null, "tags": [], "availability_zone": null, "tenant_id": "9d65fb5fbf2942ce82aa91f872dd8059"}], "loadbalancers_links": []}

Revision history for this message
Alex Mercer (flashadow) wrote :
description: updated
description: updated
Alex Mercer (flashadow)
description: updated
description: updated
Alex Mercer (flashadow)
summary: - 创建/获取loadbalaner失败
+ 创建/获取loadbalaner失败,确认为skyline请求的后端url错误
Alex Mercer (flashadow)
description: updated
Alex Mercer (flashadow)
description: updated
Revision history for this message
xusongfu (xusongfu) wrote :

Hello,

看起来像是 nginx 转发不对,你可能没写配置

Revision history for this message
Alex Mercer (flashadow) wrote (last edit ):
Download full text (4.6 KiB)

nginx是有写配置的,我用kolla-ansible部署的, 直接curl skyline console的octavia api根路径是可以路由的,但后面跟上具体api就路由不过去了

root@node-2:/etc/kolla/skyline-console# curl -X GET -H "X-Auth-Token: $Token" -H "Cookie: $Cookie" -H "Content-Type: application/json" http://192.168.27.253:9999/api/openstack/regionone/octavia

{"versions": [{"id": "v2.0", "status": "SUPPORTED", "updated": "2016-12-11T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.1", "status": "SUPPORTED", "updated": "2018-04-20T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.2", "status": "SUPPORTED", "updated": "2018-07-31T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.3", "status": "SUPPORTED", "updated": "2018-12-18T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.4", "status": "SUPPORTED", "updated": "2018-12-19T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.5", "status": "SUPPORTED", "updated": "2019-01-21T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.6", "status": "SUPPORTED", "updated": "2019-01-25T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.7", "status": "SUPPORTED", "updated": "2018-01-25T12:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.8", "status": "SUPPORTED", "updated": "2019-02-12T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.9", "status": "SUPPORTED", "updated": "2019-03-04T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.10", "status": "SUPPORTED", "updated": "2019-03-05T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.11", "status": "SUPPORTED", "updated": "2019-06-24T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.12", "status": "SUPPORTED", "updated": "2019-09-11T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.13", "status": "SUPPORTED", "updated": "2019-09-13T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.14", "status": "SUPPORTED", "updated": "2019-11-10T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.15", "status": "SUPPORTED", "updated": "2020-03-10T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.16", "status": "SUPPORTED", "updated": "2020-03-15T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.17", "status": "SUPPORTED", "updated": "2020-04-29T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.18", "status": "SUPPORTED", "updated": "2020-04-29T01:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.19", "status": "SUPPORTED", "updated": "2020-05-12T00:00:00Z", "links": [{"href": "http://192.168.27.253:9999/v2", "rel": "self"}]}, {"id": "v2.20", "status": ...

Read more...

Revision history for this message
Alex Mercer (flashadow) wrote :

nginx关于octavia部分的配置(skyline-console和skyline-api都是一样的)

        # Region: RegionOne, Service: octavia
        location /api/openstack/regionone/octavia {
            proxy_pass http://192.168.27.253:9876/;
            proxy_redirect http://192.168.27.253:9876/ /api/openstack/regionone/octavia/;
            proxy_buffering off;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header Host $http_host;
        }

Revision history for this message
Alex Mercer (flashadow) wrote :

或者你们研发测试环境的nginx是怎么配置的,可以提供一个样例么?
我想测试一下,谢谢

Revision history for this message
Alex Mercer (flashadow) wrote :

解决了,确实是nginx配置问题,kolla-ansible的模板有问题,将kolla-ansible中skyline的模板关于octavia的配置改为如下就可以解决:
        {% if enable_octavia | bool %}# Region: {{ openstack_region_name }}, Service: octavia
        location {{ skyline_nginx_prefix }}/{{ openstack_region_name | lower }}/octavia/ {
            proxy_pass {{ internal_protocol }}://{{ octavia_internal_fqdn | put_address_in_context('url') }}:{{ octavia_api_port }}/;
            proxy_redirect {{ internal_protocol }}://{{ octavia_internal_fqdn | put_address_in_context('url') }}:{{ octavia_api_port }}/ {{ skyline_nginx_prefix }}/{{ openstack_region_name | lower }}/octavia/;
            proxy_buffering off;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header Host $http_host;
        }
        {% endif %}

Changed in skyline-console:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.