Missing calls to parse_constraints in model.py #36

Closed
petevg opened this Issue Dec 14, 2016 · 5 comments

Comments

Projects
None yet
1 participant
Collaborator

petevg commented Dec 14, 2016

Looks like we missed some places where we need to parse constraints that we get back from the planner in in model.py.

To reproduce:

  1. Deploy the landscape bundle
  2. Note the following traceback (actual traceback from matrix, but the problem is in python-libjuju):
matrix:170:execute: Error in Rule(task=Task(command='matrix.tasks.deploy', args={}), conditions=[])'s task Task(command='matrix.tasks.deploy', args={})
Traceback (most recent call last):
  File "/home/petevg/Code/matrix/matrix/model.py", line 164, in execute
    result = await self.execute_plugin(context, cmd, rule)
  File "/home/petevg/Code/matrix/matrix/model.py", line 181, in execute_plugin
    result = await cmd(context, rule, self, event)
  File "/home/petevg/Code/matrix/matrix/tasks/deploy.py", line 5, in deploy
    await context.juju_model.deploy(str(context.config.path))
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/model.py", line 880, in deploy
    await handler.execute_plan()
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/model.py", line 1314, in execute_plan
    result = await method(*step.args)
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/model.py", line 1442, in deploy
    resources=resources,
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/client/_client.py", line 620, in __init__
    self.constraints = Value.from_json(constraints) if constraints else None
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/client/facade.py", line 442, in from_json
    data = json.loads(data)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
matrix:313:run_once: Pending tasks remain, aborting due to failure
matrix:322:run_once: Exception processing test: deployment
Traceback for <Task finished coro=<RuleEngine.rule_runner() done, defined at /home/petevg/Code/matrix/matrix/rules.py:175> exception=JSONDecodeError('Expecting value: line 1 column 1 (char 0)',)> (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 292, in _step
    self = None  # Needed to break cycles when an exception occurs.
  File "/home/petevg/Code/matrix/matrix/rules.py", line 263, in rule_runner
    break
  File "/home/petevg/Code/matrix/matrix/model.py", line 344, in execute
    result = await self.task.execute(context, self)
  File "/home/petevg/Code/matrix/matrix/model.py", line 171, in execute
    raise
  File "/home/petevg/Code/matrix/matrix/model.py", line 181, in execute_plugin
    result = await cmd(context, rule, self, event)
  File "/home/petevg/Code/matrix/matrix/tasks/deploy.py", line 5, in deploy
    await context.juju_model.deploy(str(context.config.path))
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/model.py", line 880, in deploy
    await handler.execute_plan()
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/model.py", line 1314, in execute_plan
    result = await method(*step.args)
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/model.py", line 1442, in deploy
    resources=resources,
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/client/_client.py", line 620, in __init__
    self.constraints = Value.from_json(constraints) if constraints else None
  File "/home/petevg/Code/matrix/.tox/py35/lib/python3.5/site-packages/juju/client/facade.py", line 442, in from_json
    data = json.loads(data)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Collaborator

petevg commented Dec 14, 2016

Fixing this should be as simple as finding instances of the string "constraints" in model.py, and replacing where appropriate with parse_constraints(constraints).

Collaborator

petevg commented Dec 15, 2016

Working on this now. It looks like it's not as simple as naively adding parse_constraints -- I get errors on the core side, and may have to make the logic in parse_constraints more sophisticated. :-/

Collaborator

petevg commented Dec 16, 2016

This bug has unveiled a whole tangle of fun issues:

  1. We needed to parse_constraints in more places -- I've done that locally.
  2. We need to convert CamelCase in the AddMachines params to snake_case -- I've done that locally, though the code needs some neatening up.
  3. If a .yaml specifies an lxd container or a machine, we need to parse that into two Placement objects -- I've done that locally.
  4. If a .yaml specifies lxc containers, it looks like we need to setup lxd containers instead. I'm working on that, though my first pass at a fix isn't working :-/
Collaborator

petevg commented Dec 16, 2016

Update: I've addressed point 4, from the previous comment, in a branch, but I'm now getting a failure getting haproxy up. Either there's a bug in 3 (Placement objects aren't making lxd containers correctly), or we're missing something that haproxy needs (it looks like it's complaining about missing a config value).

Will continue to work on this ...

Collaborator

petevg commented Dec 20, 2016

A lot of this issue was fixed in #37

The remaining issue is open in launchpad here: https://bugs.launchpad.net/juju-core/+bug/1651260

Will open a new issue here if we need to do more work after addressing the launchpad bug.

@petevg petevg closed this Dec 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment