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

file_tree pillar: fails when data files at root end in '\n' #31223

Closed
pprince opened this issue Feb 15, 2016 · 3 comments
Closed

file_tree pillar: fails when data files at root end in '\n' #31223

pprince opened this issue Feb 15, 2016 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior P3 Priority 3 Pillar Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@pprince
Copy link
Contributor

pprince commented Feb 15, 2016

Since 1ba448b (in v2015.8.4)

Using file_tree pillar, if any of the files end with '\n', this exception is thrown:

It looks to me like a bug in the code, and I am submitting a PR momentarily.

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/pillar/__init__.py", line 637, in ext_pillar
    key)
  File "/usr/lib/python2.7/dist-packages/salt/pillar/__init__.py", line 589, in _external_pillar_data
    ext = self.ext_pillars[key](self.opts['id'], pillar, **val)
  File "/usr/lib/python2.7/dist-packages/salt/pillar/file_tree.py", line 307, in ext_pillar
    keep_newline)
  File "/usr/lib/python2.7/dist-packages/salt/pillar/file_tree.py", line 234, in _construct_pillar
    and _check_newline(prefix,
UnboundLocalError: local variable 'prefix' referenced before assignment

For reference, I have the files laid out like this:

/srv/salt
├── file_tree
│   ├── hosts
│   │   ├── m1.nacl.example.com
│   │   │   ├── file.txt
│   │   │   └── m1.nacl.example.com.txt
│   │   ├── m2.nacl.example.com
│   │   │   ├── file.txt
│   │   │   └── m2.nacl.example.com.txt
│   │   └── master.nacl.example.com
│   │       ├── file.txt
│   │       └── master.nacl.example.com.txt
│   └── nodegroups
│       └── all
│           ├── file.txt
│           └── nodegroups_all.txt
├── modules
└── pillar
    ├── default.sls
    └── top.sls

and my /etc/salt/master contains this:

interface: '::'
ipv6: True
extension_modules: /srv/salt/modules
pillar_roots:
    base:
        - /srv/salt/pillar
ext_pillar:
    - file_tree:
        root_dir: /srv/salt/file_tree
        keep_newline: True
nodegroups:
    all: '*'
pprince added a commit to pprince/salt that referenced this issue Feb 15, 2016
@pprince
Copy link
Contributor Author

pprince commented Feb 15, 2016

Submitted PR #31225

@pprince pprince changed the title file_tree pillar regression: UnboundLocalError exception when any of the files end in '\n' file_tree pillar: fails when data files at root end in '\n' Feb 16, 2016
@pprince
Copy link
Contributor Author

pprince commented Feb 16, 2016

I figured out why I was having this issue, but no one else had yet.

It only occurs when the data files are at the top level of the tree, so this breaks:

/srv/salt/file_tree_pillar/hosts/minion1.example.com/file.txt

but this works:

/srv/salt/file_tree_pillar/hosts/minion1.example.com/some_dir/file.txt

@jfindlay jfindlay added Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P3 Priority 3 Platform Relates to OS, containers, platform-based utilities like FS, system based apps Pillar labels Feb 16, 2016
@jfindlay jfindlay added this to the Approved milestone Feb 16, 2016
@jfindlay
Copy link
Contributor

@pprince, thanks for fixing this.

terminalmage pushed a commit that referenced this issue Feb 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior P3 Priority 3 Pillar Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

No branches or pull requests

2 participants