Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Handle role with empty metadata file (fix AttributeError) #882

Merged
merged 1 commit into from
Mar 6, 2018
Merged

Handle role with empty metadata file (fix AttributeError) #882

merged 1 commit into from
Mar 6, 2018

Conversation

pilou-
Copy link
Contributor

@pilou- pilou- commented Feb 7, 2018

ISSUE TYPE
  • Bugfix Pull Request
SUMMARY

The following exception occurs when a role with an empty metadata file is used.

Traceback (most recent call last):
  File "/usr/local/bin/conductor", line 11, in <module>
    load_entry_point('ansible-container', 'console_scripts', 'conductor')()
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/cli.py", line 423, in conductor_commandline
    **params)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/core.py", line 809, in conductorcmd_build
    role_fingerprint = get_role_fingerprint(role, service_name, config_vars)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/utils/__init__.py", line 326, in get_role_fingerprint
    hash_role(hash_obj, resolve_role_to_path(role))
  File "/_ansible/container/utils/__init__.py", line 286, in hash_role
    hash_role(hash_obj, dependency_path)
  File "/_ansible/container/utils/__init__.py", line 286, in hash_role
    hash_role(hash_obj, dependency_path)
  File "/_ansible/container/utils/__init__.py", line 283, in hash_role
    for dependency in get_dependencies_for_role(role_path):
  File "/_ansible/container/utils/__init__.py", line 317, in get_dependencies_for_role
    for dependency in meta_main.get('dependencies', []):
AttributeError: 'NoneType' object has no attribute 'get'

exception was:
Traceback (most recent call last):
  File "/usr/local/bin/conductor", line 11, in <module>
    load_entry_point('ansible-container', 'console_scripts', 'conductor')()
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/cli.py", line 423, in conductor_commandline
    **params)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/core.py", line 809, in conductorcmd_build
    role_fingerprint = get_role_fingerprint(role, service_name, config_vars)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/utils/__init__.py", line 326, in get_role_fingerprint
    hash_role(hash_obj, resolve_role_to_path(role))
  File "/_ansible/container/utils/__init__.py", line 286, in hash_role
    hash_role(hash_obj, dependency_path)
  File "/_ansible/container/utils/__init__.py", line 286, in hash_role
    hash_role(hash_obj, dependency_path)
  File "/_ansible/container/utils/__init__.py", line 283, in hash_role
    for dependency in get_dependencies_for_role(role_path):
  File "/_ansible/container/utils/__init__.py", line 317, in get_dependencies_for_role
    for dependency in meta_main.get('dependencies', []):
AttributeError: 'NoneType' object has no attribute 'get'
yield None
for dependency in meta_main.get('dependencies', []):
yield dependency.get('role', None)
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this else statement is still needed to account for no meta_main_path?

Copy link
Contributor Author

@pilou- pilou- Feb 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so: the caller ignores None value (and None was yielded when os.path.exists(meta_main_path) was False).

@ehelms ehelms merged commit 9b05a94 into ansible:develop Mar 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants