)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":6816,"name":"Jesse Pretorius","email":"jesse@odyssey4.me","username":"jesse-pretorius"},"change_message_id":"5fbd974f9a0d735ceb1fc1cd01bf0d6383204a80","unresolved":false,"context_lines":[{"line_number":12,"context_line":"directory and merges their configurations into the inventory. An"},{"line_number":13,"context_line":"example extra_container configuration file is also provided."},{"line_number":14,"context_line":""},{"line_number":15,"context_line":"Fixed the nit"},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: Ibc83770e69efb67996a012c96766b4a88774986e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":3,"id":"9aa53dc9_afee4589","line":15,"updated":"2015-04-07 08:42:20.000000000","message":"What nit?","commit_id":"e67e4984a273c33a5b8eb67440f85134f668ec44"},{"author":{"_account_id":6816,"name":"Jesse Pretorius","email":"jesse@odyssey4.me","username":"jesse-pretorius"},"change_message_id":"d752330e3b2ab2597c1eaa8d630750a4ff032f8b","unresolved":false,"context_lines":[{"line_number":12,"context_line":"directory and merges their configurations into the inventory. An"},{"line_number":13,"context_line":"example extra_container configuration file is also provided."},{"line_number":14,"context_line":""},{"line_number":15,"context_line":"Fixes bug: 1440117"},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"Change-Id: Ibc83770e69efb67996a012c96766b4a88774986e"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"9aa53dc9_d974a09d","line":15,"updated":"2015-04-07 15:29:22.000000000","message":"\"Closes-Bug: #1440117\" as per https://wiki.openstack.org/wiki/GitCommitMessages#Including_external_references","commit_id":"1b731969f579da9c783a304bd412a427aa9299d2"}],"playbooks/inventory/dynamic_inventory.py":[{"author":{"_account_id":12892,"name":"Nolan Brubaker","email":"nolan.brubaker@rackspace.com","username":"nrb"},"change_message_id":"dd090229e000e0b32903d69e6d4e8616c59f8c8b","unresolved":false,"context_lines":[{"line_number":856,"context_line":"    return base_items"},{"line_number":857,"context_line":""},{"line_number":858,"context_line":""},{"line_number":859,"context_line":"def _extra_config(user_defined_config, base_dir):"},{"line_number":860,"context_line":"    \"\"\"Discover new items in a conf.d directory and add the new values."},{"line_number":861,"context_line":""},{"line_number":862,"context_line":"    :param user_defined_config: ``dict``"}],"source_content_type":"text/x-python","patch_set":2,"id":"baa041b7_a0cbbd52","line":859,"updated":"2015-04-03 16:25:51.000000000","message":"Nitpick: might want to update this comment now that it\u0027s being used with env.d too","commit_id":"59e03c2c1b24b11508f72bb94f630c8f09826446"},{"author":{"_account_id":7353,"name":"Kevin Carter","email":"kevin@cloudnull.com","username":"cloudnull"},"change_message_id":"3d3c03164e9d44c2f43684958d3dae47359e481b","unresolved":false,"context_lines":[{"line_number":857,"context_line":""},{"line_number":858,"context_line":""},{"line_number":859,"context_line":"def _extra_config(user_defined_config, base_dir):"},{"line_number":860,"context_line":"    \"\"\"Discover new items in a conf.d directory and add the new values."},{"line_number":861,"context_line":""},{"line_number":862,"context_line":"    :param user_defined_config: ``dict``"},{"line_number":863,"context_line":"    :param base_dir: ``str``"}],"source_content_type":"text/x-python","patch_set":2,"id":"baa041b7_94835804","line":860,"updated":"2015-04-03 18:07:27.000000000","message":"something like \"Discover new items in an extra directory and add the new values.\"","commit_id":"59e03c2c1b24b11508f72bb94f630c8f09826446"},{"author":{"_account_id":7414,"name":"David Wilde","email":"dwilde@redhat.com","username":"d34dh0r53"},"change_message_id":"124d72b8fb5f3b373d358a9361b1c838993ebc85","unresolved":false,"context_lines":[{"line_number":857,"context_line":""},{"line_number":858,"context_line":""},{"line_number":859,"context_line":"def _extra_config(user_defined_config, base_dir):"},{"line_number":860,"context_line":"    \"\"\"Discover new items in a conf.d directory and add the new values."},{"line_number":861,"context_line":""},{"line_number":862,"context_line":"    :param user_defined_config: ``dict``"},{"line_number":863,"context_line":"    :param base_dir: ``str``"}],"source_content_type":"text/x-python","patch_set":2,"id":"baa041b7_b4089c92","line":860,"in_reply_to":"baa041b7_94835804","updated":"2015-04-03 18:11:37.000000000","message":"Done","commit_id":"59e03c2c1b24b11508f72bb94f630c8f09826446"},{"author":{"_account_id":7219,"name":"git-harry","email":"git-harry@live.co.uk","username":"git-harry"},"change_message_id":"cf47321ae3056b1572052d3fa16afc7c8242c99e","unresolved":false,"context_lines":[{"line_number":922,"context_line":""},{"line_number":923,"context_line":"    # Load anything in an env.d directory if found"},{"line_number":924,"context_line":"    env_plugins \u003d os.path.join(local_path, \u0027env.d\u0027)"},{"line_number":925,"context_line":"    if os.path.isdir(env_plugins):"},{"line_number":926,"context_line":"        _extra_config(user_defined_config\u003denvironment, base_dir\u003denv_plugins)"},{"line_number":927,"context_line":""},{"line_number":928,"context_line":"    # Load existing inventory file if found"}],"source_content_type":"text/x-python","patch_set":7,"id":"9aa53dc9_b93c3c94","line":925,"updated":"2015-04-07 15:36:10.000000000","message":"This line is unnecessary. The for loop in _extra_config won\u0027t do anything if base_dir isn\u0027t a valid directory.","commit_id":"0800bdd3879a834450fdb28104ed65cf3f544d92"},{"author":{"_account_id":7353,"name":"Kevin Carter","email":"kevin@cloudnull.com","username":"cloudnull"},"change_message_id":"57bc8bcaeced59c4aa96684e34ed0c9da1d5947d","unresolved":false,"context_lines":[{"line_number":922,"context_line":""},{"line_number":923,"context_line":"    # Load anything in an env.d directory if found"},{"line_number":924,"context_line":"    env_plugins \u003d os.path.join(local_path, \u0027env.d\u0027)"},{"line_number":925,"context_line":"    if os.path.isdir(env_plugins):"},{"line_number":926,"context_line":"        _extra_config(user_defined_config\u003denvironment, base_dir\u003denv_plugins)"},{"line_number":927,"context_line":""},{"line_number":928,"context_line":"    # Load existing inventory file if found"}],"source_content_type":"text/x-python","patch_set":7,"id":"9aa53dc9_71c0cde0","line":925,"in_reply_to":"9aa53dc9_384febbe","updated":"2015-04-08 20:52:30.000000000","message":"This is an issue with implicit vs explicit as the current implementation sticks with the same design pattern perviously implemented for the other use of the `_extra_config` function; which would require the explicit check before running the method. That said, I do agree that we could, in a subsequent patch, refactor the `_extra_config` use such that the directory check is done within the function. However, I disagree that we should do that within this patch. \n\nI can see where the method has a \"potential\" for a race condition in the case where files in the \"/etc/openstack_deployment/env.d\" were deleted or in the case where the \"/etc/openstack_deployment/env.d\" and or \"/etc/openstack_deployment\" directory has been deleted while ansible was initially executing the dynamic_inventory.py via the ansible-playbook command. If this race occurred two possible things could happen. if a file was deleted from the \"/etc/openstack_deployment/env.d\" directory in execution nothing would happen because the items in env.d modify the in memory version of the environment prior to processing. If the env.d directory was all together removed nothing would still happen because there would be no modifiers to apply and due to how your astute comments on how `os.walk` works. The second race possibility is that \"/etc/openstack_deployment\" is deleted which would result in catastrophic failure. which I would say is really something else that we can\u0027t account for and is the result of a \"bigger problem\".\n\nWhile I know that `os.walk` will return an empty generator when the string provided is not a valid path on the host I don\u0027t think that we should rely on that or call the method into memory when not needed. As for your concerns on whether the `environment` object is a directory you can rest assured because calling `yaml.safe_load` on line 909 will always result in a python dictionary. If the loading of the environment was not possible the environment object would never exist as the script would halt resulting in a stacktrace. Additionally at present the environment yaml file is checked via MD5 sum to ensure its contents which we know will will result in python dictionary object when loaded through the yaml module.\n\nPer comments from @Andymccr I think that we should do a little refactoring within the dynamic inventory script to remove the md5 check and provide a more useful sanity check. In that refactor work we might also want improve some of the functions within this script but I don\u0027t think it should be done here.","commit_id":"0800bdd3879a834450fdb28104ed65cf3f544d92"},{"author":{"_account_id":7219,"name":"git-harry","email":"git-harry@live.co.uk","username":"git-harry"},"change_message_id":"17753e7578a5352734b6355a4311ce2fdc07e76a","unresolved":false,"context_lines":[{"line_number":922,"context_line":""},{"line_number":923,"context_line":"    # Load anything in an env.d directory if found"},{"line_number":924,"context_line":"    env_plugins \u003d os.path.join(local_path, \u0027env.d\u0027)"},{"line_number":925,"context_line":"    if os.path.isdir(env_plugins):"},{"line_number":926,"context_line":"        _extra_config(user_defined_config\u003denvironment, base_dir\u003denv_plugins)"},{"line_number":927,"context_line":""},{"line_number":928,"context_line":"    # Load existing inventory file if found"}],"source_content_type":"text/x-python","patch_set":7,"id":"9aa53dc9_384febbe","line":925,"in_reply_to":"9aa53dc9_549f25b4","updated":"2015-04-08 07:10:39.000000000","message":"It\u0027s does not mean it\u0027s necessary, it would be necessary if _extra_config was broken by the lack of a check.\n\nAlthough I see no reason for the isdir test based on it\u0027s current function, if you consider it vital I think it would make a lot more sense if it lived inside _extra_config. This would make future use of the function less prone to error because someone had forgotten to do the appropriate data validation. The pattern you describe only exists because of this separation.\n\nIn addition this essentially has the potential for a race whereby _extra_config is ultimately the decider. If the directory is deleted after the isdir test and before _extra_config, the isdir test has served no purpose yet nothing breaks and os.walk will act in the same way as if the isdir line of code had never been there.\n\nI also don\u0027t think this is an argument of explicitness versus implicitness, by definition an empty iterable is going to have zero loops of a for-loop. Once os.walk is in the directory the code relies on it to decide if something is a directory or a file and act accordingly, I don\u0027t see why the base directory should be treated any different.\n\nenvironment is never tested to confirm it is a dict.","commit_id":"0800bdd3879a834450fdb28104ed65cf3f544d92"},{"author":{"_account_id":7219,"name":"git-harry","email":"git-harry@live.co.uk","username":"git-harry"},"change_message_id":"e59ac7a9d1701c0d0eaca06c9e4af4429b26e556","unresolved":false,"context_lines":[{"line_number":922,"context_line":""},{"line_number":923,"context_line":"    # Load anything in an env.d directory if found"},{"line_number":924,"context_line":"    env_plugins \u003d os.path.join(local_path, \u0027env.d\u0027)"},{"line_number":925,"context_line":"    if os.path.isdir(env_plugins):"},{"line_number":926,"context_line":"        _extra_config(user_defined_config\u003denvironment, base_dir\u003denv_plugins)"},{"line_number":927,"context_line":""},{"line_number":928,"context_line":"    # Load existing inventory file if found"}],"source_content_type":"text/x-python","patch_set":7,"id":"9aa53dc9_db01e6b0","line":925,"in_reply_to":"9aa53dc9_71c0cde0","updated":"2015-04-09 08:40:21.000000000","message":"I guess we shall have to agree to differ on the worth of this line.\n\nThe point about implicit versus explicit is that it is not absolute and requires a certain amount of judgement. This code makes all sorts of assumptions about the objects that it uses. I highlighted the environment object as an example because it is assumed to be a dictionary. yaml.safe_load does not guarantee that it is a dictionary, it simply restricts the type of objects that can be created. Therefore the environment could quite easily be a list. The md5 check is an implicit guarantee that environment is a dict.\n\nI see hughsaunders has just approved this so it is now moot but let me know if you still don\u0027t understand anything.","commit_id":"0800bdd3879a834450fdb28104ed65cf3f544d92"},{"author":{"_account_id":7414,"name":"David Wilde","email":"dwilde@redhat.com","username":"d34dh0r53"},"change_message_id":"83d1e848f32149bef76823366dd292a3e6b550e0","unresolved":false,"context_lines":[{"line_number":922,"context_line":""},{"line_number":923,"context_line":"    # Load anything in an env.d directory if found"},{"line_number":924,"context_line":"    env_plugins \u003d os.path.join(local_path, \u0027env.d\u0027)"},{"line_number":925,"context_line":"    if os.path.isdir(env_plugins):"},{"line_number":926,"context_line":"        _extra_config(user_defined_config\u003denvironment, base_dir\u003denv_plugins)"},{"line_number":927,"context_line":""},{"line_number":928,"context_line":"    # Load existing inventory file if found"}],"source_content_type":"text/x-python","patch_set":7,"id":"9aa53dc9_8cddb844","line":925,"in_reply_to":"9aa53dc9_b93c3c94","updated":"2015-04-07 15:49:27.000000000","message":"Done","commit_id":"0800bdd3879a834450fdb28104ed65cf3f544d92"},{"author":{"_account_id":7353,"name":"Kevin Carter","email":"kevin@cloudnull.com","username":"cloudnull"},"change_message_id":"44e29b20a685f05c584da9ebab38c9c6d9f45d35","unresolved":false,"context_lines":[{"line_number":922,"context_line":""},{"line_number":923,"context_line":"    # Load anything in an env.d directory if found"},{"line_number":924,"context_line":"    env_plugins \u003d os.path.join(local_path, \u0027env.d\u0027)"},{"line_number":925,"context_line":"    if os.path.isdir(env_plugins):"},{"line_number":926,"context_line":"        _extra_config(user_defined_config\u003denvironment, base_dir\u003denv_plugins)"},{"line_number":927,"context_line":""},{"line_number":928,"context_line":"    # Load existing inventory file if found"}],"source_content_type":"text/x-python","patch_set":7,"id":"9aa53dc9_549f25b4","line":925,"in_reply_to":"9aa53dc9_b93c3c94","updated":"2015-04-07 22:45:34.000000000","message":"This line is necessary because there is no reason to call the `_extra_config` loop if the `base_dir` does not exist. Additionally this follows the same pattern used when `_extra_config` is loaded for use in the \"conf.d\" directory. \n\nIMO with \"user_defined_config\u003denvironment\" being a defined dict calling this method and assuming the merge operation will not inversely effect the environment would be bad in practice as it is always better to be explicit that implicit.","commit_id":"0800bdd3879a834450fdb28104ed65cf3f544d92"}]}
