Using strict: false in plugin condition has no effect

Bug #1587773 reported by Michal Skalski
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
High
Ihor Kalnytskyi
Mitaka
Fix Released
High
Ihor Kalnytskyi
Newton
Fix Committed
High
Ihor Kalnytskyi

Bug Description

Detailed bug description:

I use strict: false according to plugin documentation: https://wiki.openstack.org/wiki/Fuel/Plugins#How_to_display_plugin_restrictions_to_users

This code:
https://github.com/openstack/fuel-plugin-opendaylight/blob/master/environment_config.yaml#L42-L45

was valid in fuel 8.0 and some previous ISOs of 9.0. When I try activate plugin on fuel installed from recent 9.0 ISO I get error:

OpenStack Settings Configuration Error
A server error has occurred. Please contact your system administrator.

In firebug console there is an error msg:
TypeError: Value of settings:bgpvpn is undefined. Set options.strict to false to allow undefined values.

Here is a fuel snapshot: https://drive.google.com/file/d/0ByJ7mKmkSupcQVg0R0VRMTVoeDg/view?usp=sharing

Steps to reproduce:

Install plugin with condition which check non-existed variable and have strict: false set up

Expected results:

Plugin should be activated.

Actual result:

UI return error of configuration, strict: false is not respected.

Tags: area-python
Changed in fuel:
assignee: nobody → Fuel Sustaining (fuel-sustaining-team)
Ilya Kutukov (ikutukov)
Changed in fuel:
status: New → Confirmed
Dmitry Pyzhov (dpyzhov)
Changed in fuel:
importance: Critical → High
assignee: Fuel Sustaining (fuel-sustaining-team) → Fuel Toolbox (fuel-toolbox)
Revision history for this message
Ihor Kalnytskyi (ikalnytskyi) wrote :

Hm.. I checked and figured out that backend responds without any errors. It seems it's a problem of frontend code. Besides, there're errors in browsers console:

parseError — bundle.js:60:20911Error: Parse error on line 1:
settings:settings:bgpvpn == null or s
-----------------^
Expecting 'EOF', 'EQUALS', 'NOT_EQUALS', 'RPAREN', 'AND', 'OR', 'IN', got 'MODELPATH'

Revision history for this message
Ihor Kalnytskyi (ikalnytskyi) wrote :

Moving to Fuel UI then.

Revision history for this message
Vitaly Kramskikh (vkramskikh) wrote :

The error is not about absent key, but about improper condition format. Construction "settings:settings:bgpvpn" is invalid, but in the plugin there is no such string. Does this string come from the backend? Is live env available?

Revision history for this message
Vitaly Kramskikh (vkramskikh) wrote :

Was able to reproduce on fake env with correct condition

tags: added: area-ui
removed: area-python
Revision history for this message
Michal Skalski (mskalski) wrote :

In firebug I see this message:

"Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/nailgun/api/v1/handlers/base.py", line 170, in checked_data
    valid_data = method(data, **kwargs)
  File "/usr/lib/python2.7/site-packages/nailgun/api/v1/validators/cluster.py", line 250, in validate
    cls.validate_attributes(attrs.get('editable', {}), models, force=force)
  File "/usr/lib/python2.7/site-packages/nailgun/api/v1/validators/base.py", line 164, in validate_attributes
    models, data)
  File "/usr/lib/python2.7/site-packages/nailgun/utils/restrictions.py", line 344, in check_data
    return list(find_errors())
  File "/usr/lib/python2.7/site-packages/nailgun/utils/restrictions.py", line 341, in find_errors
    for err in find_errors(value):
  File "/usr/lib/python2.7/site-packages/nailgun/utils/restrictions.py", line 341, in find_errors
    for err in find_errors(value):
  File "/usr/lib/python2.7/site-packages/nailgun/utils/restrictions.py", line 326, in find_errors
    models, restrictions, action='disable')['result']:
  File "/usr/lib/python2.7/site-packages/nailgun/utils/restrictions.py", line 198, in check_restrictions
    filterd_by_action_restrictions)
  File "/usr/lib/python2.7/site-packages/nailgun/utils/restrictions.py", line 197, in <lambda>
    item.get('condition'), models, strict=strict).evaluate(),
  File "/usr/lib/python2.7/site-packages/nailgun/expression/__init__.py", line 27, in evaluate
    return self.compiled_expression()
  File "/usr/lib/python2.7/site-packages/nailgun/expression/objects.py", line 36, in __call__
    self.evaluate()
  File "/usr/lib/python2.7/site-packages/nailgun/expression/objects.py", line 32, in evaluate
    self.value = self.subexpression()
  File "/usr/lib/python2.7/site-packages/nailgun/expression/expression_parser.py", line 103, in <lambda>
    result = lambda: arg1() or arg2()
  File "/usr/lib/python2.7/site-packages/nailgun/expression/objects.py", line 36, in __call__
    self.evaluate()
  File "/usr/lib/python2.7/site-packages/nailgun/expression/objects.py", line 32, in evaluate
    self.value = self.subexpression()
  File "/usr/lib/python2.7/site-packages/nailgun/expression/expression_parser.py", line 99, in <lambda>
    result = lambda: arg1() == arg2()
  File "/usr/lib/python2.7/site-packages/nailgun/expression/objects.py", line 83, in __call__
    self.evaluate()
  File "/usr/lib/python2.7/site-packages/nailgun/expression/objects.py", line 78, in evaluate
    ' to false to allow undefined values.'.format(self.path))
TypeError: Value of settings:bgpvpn is undefined. Set options.strict to false to allow undefined values.
"

Revision history for this message
Vitaly Kramskikh (vkramskikh) wrote :

There is no difference in rendering between 8.0 and master:

http://storage7.static.itmages.com/i/16/0602/h_1464872084_5117815_9c9bdbf06e.png
http://storage1.static.itmages.com/i/16/0602/h_1464872124_4880193_2b54346948.png

The only difference is that backend prohibits saving the data as it performs restriction evaluation. In the trace we see error

> TypeError: Value of settings:bgpvpn is undefined. Set options.strict to false to allow undefined values.

But this restriction has strict: false! So it seems Nailgun validation must be fixed.

tags: added: area-python
removed: area-ui
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to fuel-web (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/324537

Changed in fuel:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-web (master)

Reviewed: https://review.openstack.org/324537
Committed: https://git.openstack.org/cgit/openstack/fuel-web/commit/?id=9abbcd7e7ffe510eb0c6ef570977a8103d919c72
Submitter: Jenkins
Branch: master

commit 9abbcd7e7ffe510eb0c6ef570977a8103d919c72
Author: Igor Kalnitsky <email address hidden>
Date: Thu Jun 2 12:59:05 2016 +0300

    Take into account restriction's `strict` value

    So far Nailgun always assumes that restrictions are strict, and doesn't
    care about explicit (specified in restriction) `strict` value. This
    commit fixes that, and if some restriction has an explicit `strict`
    option it will be taken into account.

    Change-Id: I5ef0e91f42cd708be5df56da461af4d7b568ae42
    Closes-Bug: #1587773

Changed in fuel:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-web (stable/mitaka)

Fix proposed to branch: stable/mitaka
Review: https://review.openstack.org/325787

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-web (stable/mitaka)

Reviewed: https://review.openstack.org/325787
Committed: https://git.openstack.org/cgit/openstack/fuel-web/commit/?id=b349906a75624c005f4676f1af1d8cc8365c746d
Submitter: Jenkins
Branch: stable/mitaka

commit b349906a75624c005f4676f1af1d8cc8365c746d
Author: Igor Kalnitsky <email address hidden>
Date: Thu Jun 2 12:59:05 2016 +0300

    Take into account restriction's `strict` value

    So far Nailgun always assumes that restrictions are strict, and doesn't
    care about explicit (specified in restriction) `strict` value. This
    commit fixes that, and if some restriction has an explicit `strict`
    option it will be taken into account.

    Change-Id: I5ef0e91f42cd708be5df56da461af4d7b568ae42
    Closes-Bug: #1587773

Revision history for this message
Maksym Strukov (unbelll) wrote :

Scenario:
1. Build and install https://github.com/openstack/fuel-plugin-opendaylight
2. Create cluster
3. Enable plugin and save settings

Actual:
No errors in console, plugin enabled.

Verified as fixed in 9.0-mos-485

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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