Got fatal exception with policy ID not exist
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
congress |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
I am able to create a rule against policy ironic:
zhenzan@
+------
| id | name | owner_id | kind | description |
+------
| 15abd376-
| 4921bc6b-
| None | neutronv2 | system | nonrecursive | Datasource store |
| None | nova | system | nonrecursive | Datasource store |
| None | ironic | system | nonrecursive | Datasource store |
| None | keystone | system | nonrecursive | Datasource store |
| None | cinder | system | nonrecursive | Datasource store |
| None | glancev2 | system | nonrecursive | Datasource store |
+------
zhenzan@
+------
| Field | Value |
+------
| comment | None |
| id | 639b0da6-
| name | test_ds |
| rule | error(id) :- |
| | ironic:nodes(id, _x_0_1, _x_0_2, _x_0_3, _x_0_4, _x_0_5, _x_0_6, _x_0_7, _x_0_8), |
| | not equal(id, "") |
+------
But congress-server failed to start because it got fatal exception that policy ID ironic does not exist.
> /home/zhenzan/
-> if policy_name not in self.engine.theory:
(Pdb) p policy_name
u'ironic'
(Pdb) p self.engine.theory
{u'action': <congress.
(Pdb) n
> /home/zhenzan/
-> raise KeyError("Policy with ID '%s' does not exist", policy_name)
(Pdb)
KeyError: KeyError.
> /home/zhenzan/
-> raise KeyError("Policy with ID '%s' does not exist", policy_name)
(Pdb) c
2015-03-23 11:23:46.689 ERROR congress.service [-] Fatal Exception:
2015-03-23 11:23:46.689 TRACE congress.service Traceback (most recent call last):
2015-03-23 11:23:46.689 TRACE congress.service File "/home/
2015-03-23 11:23:46.689 TRACE congress.service return f(*args, **kw)
2015-03-23 11:23:46.689 TRACE congress.service File "/home/
2015-03-23 11:23:46.689 TRACE congress.service cage = harness.
2015-03-23 11:23:46.689 TRACE congress.service File "/home/
2015-03-23 11:23:46.689 TRACE congress.service {'policy_id': rule.policy_name})
2015-03-23 11:23:46.689 TRACE congress.service File "/home/
2015-03-23 11:23:46.689 TRACE congress.service raise KeyError("Policy with ID '%s' does not exist", policy_name)
2015-03-23 11:23:46.689 TRACE congress.service KeyError: ("Policy with ID '%s' does not exist", u'ironic')
2015-03-23 11:23:46.689 TRACE congress.service
So the quesiton is if we should block rule creation against system owned policy? Or it is just a bug that system owned policy is not loaded at the time?
Just found that it's more like a bug that system owned policies are not loaded on boot when inserting rules from DB.
Service api-policy is loaded before datasource services. So self.engine.theory doesn't have datasource policies yet.
2015-03-23 14:56:52.752 DEBUG congress. api.application [req-03cac977- 63f1-45fb- 914f-b2136c9351 0a admin 1b0d3b9acf47400 6984364f54a07e7 dd] Handling request 'POST /v1/policies/ ironic/ rules' with CollectionHandl er(/v1/ policies/ (?P<policy_ id>[^/] +)/rules$ ) from (pid=2444) __call__ /home/zhenzan/ workspace/ congress/ congress/ api/application .py:45 workspace/ congress/ congress/ api/rule_ model.py( 176)change_ rule() datalog. nonrecursive. NonrecursiveRul eTheory object at 0x7f75242e6890>, u'classification': <congress. datalog. nonrecursive. NonrecursiveRul eTheory object at 0x7f752365c710>, u'neutronv2': <congress. datalog. nonrecursive. NonrecursiveRul eTheory object at 0x7f7522d96d50>, u'nova': <congress. datalog. nonrecursive. NonrecursiveRul eTheory object at 0x7f7522ecdd10>, u'ironic': <congress. datalog. nonrecursive. NonrecursiveRul eTheory object at 0x7f7522ed6050>, u'keystone': <congress. datalog. nonrecursive. NonrecursiveRul eTheory object at 0x7f7522eb8f50>, u'action': <congress. datalog. nonrecursive. NonrecursiveRul eTheory object at 0x7f75242e67d0>, u'cinder': <congress. datalog. nonrecursive. NonrecursiveRul eTheory object at 0x7f7523639ed0>, u'glancev2': <congress. datalog. nonrecursive. NonrecursiveRul eTheory object at 0x7f7522da1090>} theory. keys()
> /home/zhenzan/
-> if policy_name not in self.engine.theory:
(Pdb) p self.engine.theory
{u'bzhou': <congress.
(Pdb) p self.engine.
[u'bzhou', u'classification', u'neutronv2', u'nova', u'ironic', u'keystone', u'action', u'cinder', u'glancev2']
(Pdb)