Closed dwgebler closed 10 years ago
Yep, that works. With a slight modification to the GearEnvironment class (below)
The tests and docstrings will probably need updating too.
diff --git a/flocker/node/_config.py b/flocker/node/_config.py
index cab15d7..e8de7d5 100644
--- a/flocker/node/_config.py
+++ b/flocker/node/_config.py
@@ -212,7 +212,7 @@ class Configuration(object):
image=image,
volume=volume,
ports=frozenset(ports),
- environment=environment)
+ environment=frozenset(environment.items()))
if config:
raise ConfigurationError(
diff --git a/flocker/node/gear.py b/flocker/node/gear.py
index 4a68f86..82da392 100644
--- a/flocker/node/gear.py
+++ b/flocker/node/gear.py
@@ -38,7 +38,7 @@ class GearEnvironment(object):
the Gear REST API.
"""
variables = []
- for k, v in self.variables.items():
+ for k, v in self.variables:
variables.append(dict(name=k, value=v))
return dict(id=self.id, variables=variables)
I think the problem actually occurs when we create a frozenset of the Applications. Which attempts to hash each Application and triggers the hash
and the attrs_to_tuple
function in characteristic
Perhaps we could suggest an improvement to Characteristic for better handling of dicts and other unhashable attributes. Maybe automatically call dict.items for DictType?
I don't think that's a good idea lacking ability to make stuff read-only. There's a reason dictionaries aren't hashable; if you mutate it and it's a key in a dictionary unexpected things would happen.
Due to a bug in the implementation of
environment
YAML config,flocker-deploy
can end up returning an "Error: Wrong number of arguments" message (as a result oftwisted.python.usage
raising aTypeError
with that message), when in fact the correct number of command-line arguments are given.The real underlying problem is that
flocker.node._config
assigns theenvironment
attribute of theCharacteristic
Application
model as adict
, whichCharacteristic
then complains is not hashable:In this code,
environment
is eitherdict
orNone
, so we need to do something like ensuringenvironment
is always adict
(even if empty) and then doing:This
frozenset
can later be converted back to adict
and processed as normal.