OpenStack senlin cannot create a loadbalance listener by openstack sdk

Bug #1708780 reported by TingtingYu
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack SDK
Fix Released
Undecided
Unassigned

Bug Description

cannot create a listener by openstack sdk when I attach lbaas policy to a cluster in senlin.
The openstacksdk version is 0.9.17
Example one:
lb_policy.yaml:
type: senlin.policy.loadbalance
version: 1.1
properties:
  pool:
    protocol: HTTP
    protocol_port: 80
    subnet: public-subnet
    lb_method: ROUND_ROBIN
    admin_state_up: true
    session_persistence:
      type: HTTP_COOKIE
      cookie_name: my_cookie
  vip:
    subnet: public-subnet
    address: 192.168.6.110
    connection_limit: 5000
    protocol: HTTP
    protocol_port: 80
    admin_state_up: true
  health_monitor:
    type: HTTP
    delay: 20
    timeout: 5
    max_retries: 3
    admin_state_up: true
    http_method: GET
    url_path: /health
    expected_codes: 200
  lb_status_timeout: 300

[stack@yutingting v2]$ openstack cluster policy create --spec-file lb_policy.yaml lb01
[stack@yutingting v2]$ openstack cluster policy attach --enabled True --policy lb01 mycluster

2017-08-04 16:22:19.758 ERROR senlin.drivers.openstack.sdk [req-e1de5559-063c-48ba-8ad6-10a91a253ad8 None None] HttpException: Bad Request (HTTP 400) (Request-ID: req-24905409-f305-4bce-a880-41d29e385903), Listener must be created with a loadbalancer or pool.: HttpException: HttpException: Bad Request (HTTP 400) (Request-ID: req-24905409-f305-4bce-a880-41d29e385903), Listener must be created with a loadbalancer or pool.
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk Traceback (most recent call last):
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk File "/opt/stack/venv/senlin/senlin/drivers/openstack/sdk.py", line 96, in invoke_with_catch
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk return func(driver, *args, **kwargs)
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk File "/opt/stack/venv/senlin/senlin/drivers/openstack/neutron_v2.py", line 93, in listener_create
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk res = self.conn.network.create_listener(**kwargs)
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk File "/opt/stack/venv/lib/python2.7/site-packages/openstack/network/v2/_proxy.py", line 694, in create_listener
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk return self._create(_listener.Listener, **attrs)
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk File "/opt/stack/venv/lib/python2.7/site-packages/openstack/proxy2.py", line 195, in _create
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk return res.create(self._session)
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk File "/opt/stack/venv/lib/python2.7/site-packages/openstack/resource2.py", line 591, in create
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk json=request.body, headers=request.headers)
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk File "/opt/stack/venv/lib/python2.7/site-packages/keystoneauth1/session.py", line 853, in post
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk return self.request(url, 'POST', **kwargs)
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk File "/opt/stack/venv/lib/python2.7/site-packages/openstack/session.py", line 66, in map_exceptions_wrapper
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk raise exceptions.from_exception(e)
2017-08-04 16:22:19.758 TRACE senlin.drivers.openstack.sdk HttpException: HttpException: Bad Request (HTTP 400) (Request-ID: req-24905409-f305-4bce-a880-41d29e385903), Listener must be created with a loadbalancer or pool.

But the loadbalancer is created,I can see the loadbalancer in neutron
[stack@yutingting senlin]$ neutron lbaas-loadbalancer-list
+--------------------------------------+---------+---------------+---------------------+----------+
| id | name | vip_address | provisioning_status | provider |
+--------------------------------------+---------+---------------+---------------------+----------+
| 668339db-b506-4aa1-ba08-2d4ae84339c9 | pub-lb | 192.168.6.107 | ACTIVE | haproxy |
| 8487f860-9f43-444c-a9dd-d9425cd24099 | test-lb | 10.0.0.3 | ACTIVE | haproxy |
| f1d35284-30ca-456c-af48-a31cf1b60cb7 | | 192.168.6.110 | ACTIVE | haproxy |
+--------------------------------------+---------+---------------+---------------------+----------+

Example two:
Then I write a test case by openstacksdk documention to test the sdk.,It's also has this problem.
test_sdk.py
from openstack import connection
from openstack import profile

def create_connection(auth_url, region, project_name, username, password):
    prof = profile.Profile()
    prof.set_region(profile.Profile.ALL, region)

    return connection.Connection(
        profile=prof,
        user_agent='senlin',
        auth_url=auth_url,
        project_name=project_name,
        username=username,
        password=password
    )

def create_listener():
    conn = create_connection('http://192.168.6.71:5000/v2.0','','admin','admin','pass')

    kwargs = {
            'loadbalancer_id': 'f1d35284-30ca-456c-af48-a31cf1b60cb7',
            'protocol': 'HTTP',
            'protocol_port': '80',
            'admin_state_up': True,
            }
    try:
        res = conn.network.create_listener(**kwargs)
        print 'yes'
    except Exception as e:
        print e

create_listener()

[root@yutingting mypro]# python test_sdk.py
HttpException: Bad Request (HTTP 400) (Request-ID: req-bc082b09-9ac6-4c20-92ef-f3aff65b8cb8), Listener must be created with a loadbalancer or pool.

Then I modify the 'loadbalancer_id' to 'loadbalancers',there is another error:
[root@yutingting mypro]# python test_sdk.py
HttpException: Bad Request (HTTP 400) (Request-ID: req-77b3472e-9a12-41c2-be84-f5a3136b60b7), Attribute 'loadbalancers' not allowed in POST

Wangpan (aspirer)
summary: - cannot create a listener by openstack sdk
+ cannot create a loadbalance listener by openstack sdk
summary: - cannot create a loadbalance listener by openstack sdk
+ OpenStack senlin cannot create a loadbalance listener by openstack sdk
TingtingYu (qearl)
description: updated
Revision history for this message
Wangpan (aspirer) wrote :

there is a patch that try to fix the issue: https://review.openstack.org/#/c/493449/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstacksdk (master)

Reviewed: https://review.openstack.org/493449
Committed: https://git.openstack.org/cgit/openstack/python-openstacksdk/commit/?id=73924e988fd2c05ce8b74e5f526c71becc43e250
Submitter: Jenkins
Branch: master

commit 73924e988fd2c05ce8b74e5f526c71becc43e250
Author: TingtingYu <yu_qearl@163.com>
Date: Mon Aug 14 14:08:20 2017 +0800

    fix the bug that cannot create a listener by openstacksdk

    When creating a listener with a loadbalance id by openstacksdk,there
    have an error with the message "Listener must be created with a
    loadbalancer or pool." I guess the reason is that I give the parameter
    "loadbalancer_id" but it be ignored in the code.

    I modify the listener class, I add a new line load_balancer_id =
    resource.Body('loadbalancer_id'), then successfully create a listener.

    Change-Id: Id05fcdc0be8f50304a974c01d1aada4eaa4053cd
    Closes-Bug: 1708780

Changed in python-openstacksdk:
status: New → Fix Released
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.