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

Fix split in Deploy/playbook/roles/common_files/swift_config.py #7

Open
ghost opened this issue Jul 12, 2015 · 0 comments
Open

Fix split in Deploy/playbook/roles/common_files/swift_config.py #7

ghost opened this issue Jul 12, 2015 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 12, 2015

  1. You need to be careful with SPLIT and PATH exist in python : - )
    There's the following code in Deploy/playbook/roles/common_files/swift_config.py
    def install(conf):
    object_server_conf_files = conf.get('object-confs', 'object_server_conf_files').split(',')
    for f in object_server_conf_files:
    if os.path.exists(f):
    patch_swift_config_file(conf, f, 'object')

Where the config file on disk, to handle the scenario where there are multiple object conf files, as an example:
object_server_conf_files = /etc/swift/object-server/1.conf, /etc/swift/object-server/2.conf, /etc/swift/object-server/3.conf, /etc/swift/object-server/4.conf

So this all looks harmless enough ... but much later down the line I realised my object files were not all patched, now there were two reasons for this (one I'll cover in another section) but the code bug is as follows.
Calling split in python as done above will return:
"file1"
" file2"
" file2"
...
Notice the whitespace, looks harmless but this causes os.path.exists to fail (ouch), and we skip the files !
The first is to first call:
f = f.strip()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants