Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dockerng] Disable notset check #31455

Merged
merged 2 commits into from Feb 25, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 11 additions & 39 deletions salt/states/dockerng.py
Expand Up @@ -62,8 +62,6 @@
# Define the module's virtual name
__virtualname__ = 'dockerng'

NOTSET = object()


def __virtual__():
'''
Expand All @@ -89,17 +87,6 @@ def _format_comments(comments):
return ret


def _api_mismatch(param):
'''
Raise an exception if a config value can't be found at the expected
location in a call to dockerng.inspect_container
'''
raise CommandExecutionError(
'Unable to compare configuration for the \'{0}\' parameter. This may '
'be due to a change in the Docker API'.format(param)
)


def _prep_input(kwargs):
'''
Repack (if necessary) data that should be in a dict but is easier to
Expand All @@ -126,13 +113,12 @@ def _compare(actual, create_kwargs, defaults_from_image):
Compare the desired configuration against the actual configuration returned
by dockerng.inspect_container
'''
_get = lambda path: (
salt.utils.traverse_dict(actual, path, NOTSET, delimiter=':')
)
_image_get = lambda path: (
salt.utils.traverse_dict(defaults_from_image, path, NOTSET,
delimiter=':')
)
def _get(path, default=None):
return salt.utils.traverse_dict(actual, path, default, delimiter=':')

def _image_get(path):
return salt.utils.traverse_dict(defaults_from_image, path, None,
delimiter=':')
ret = {}
for item, config in six.iteritems(VALID_CREATE_OPTS):
try:
Expand All @@ -145,31 +131,13 @@ def _compare(actual, create_kwargs, defaults_from_image):
data = _get(config['path'])
else:
data = config.get('default')
else:
if data is NOTSET:
_api_mismatch(item)

log.trace('dockerng.running: comparing ' + item)
conf_path = config['path']
if isinstance(conf_path, tuple):
actual_data = [_get(x) for x in conf_path]
for val in actual_data:
if val is NOTSET:
_api_mismatch(item)
else:
actual_data = _get(conf_path)
if actual_data is NOTSET:
if item in ('network_disabled', # dockerd 1.9.1
'lxc_conf', # dockerd 1.10.2
):
# XXX hack !
# Depending of docker daemon version,
# the inspect command doesn't always
# return all expected values.
# TODO consider removing NOTSET checking.
actual_data = config.get('default')
else:
_api_mismatch(item)
actual_data = _get(conf_path, default=config.get('default'))
log.trace('dockerng.running ({0}): desired value: {1}'
.format(item, data))
log.trace('dockerng.running ({0}): actual value: {1}'
Expand Down Expand Up @@ -220,6 +188,10 @@ def _compare(actual, create_kwargs, defaults_from_image):
# list of ints or tuples, and that won't look as good in the
# nested outputter as a simple comparison of lists of
# port/protocol pairs (as found in the "actual" dict).
if actual_data is None:
actual_data = []
if data is None:
data = []
actual_ports = sorted(actual_data)
desired_ports = []
for port_def in data:
Expand Down