Repository navigation
Closed
Description
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: '*'
Metadata
Metadata
Assignees
Labels
P3Priority 3PillarPlatformRelates to OS, containers, platform-based utilities like FS, system based appsbugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Activity
Fix regression in file_tree pillar (Fixes saltstack#31223.)
pprince commentedon Feb 15, 2016
Submitted PR #31225
[-]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'[/+]pprince commentedon 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.txtbut this works:
/srv/salt/file_tree_pillar/hosts/minion1.example.com/some_dir/file.txtjfindlay commentedon Feb 16, 2016
@pprince, thanks for fixing this.
Merge pull request #31225 from pprince/PR/bugfix/file_tree