saltstack / saltstack/salt

Merging pillars when one is empty gives empty result

Open
#33,437 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Confirmed Core help-wanted pending-community-assignment Pillar severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue/Question

I'm trying to merge pillar data, as suggested in https://github.com/saltstack/salt/issues/28394#issuecomment-158659657 . However, if the data I try to merge in happens to be empty (as a result of template rendering), the end result is completely empty, ignoring any previous data.

Setup

pillar/top.sls:

base:
  '*':
    - common
    - modules

pillar/common.sls:

program:
  modules:
    00-definitions.conf: ~
    01-cleanup.conf: ~

pillar/modules.sls:

program:
  modules:
    {% if 'test' in grains['roles'] %}
    10-dostuff.conf: ~
    {% endif %}

From this, I expect a minion with the grain roles: [test] to get the pillar {'00-definitions.conf': None, '01-cleanup.conf': None, '10-dostuff.conf': None}, while other minions should get {'00-definitions.conf': None, '01-cleanup.conf': None}.

However, what actually happens is that minions without the role test get nothing at all:

# salt --no-colour 'salt*' grains.get roles   
saltminion:
    - test
saltmaster:
    - saltmaster
# salt --no-colour 'salt*' pillar.get program
saltminion:
    ----------
    modules:
        ----------
        00-definitions.conf:
            None
        01-cleanup.conf:
            None
        10-dostuff.conf:
            None
saltmaster:
    ----------
    modules:
        None

Changing pillar_source_merging_strategy from smart to recurse gives the same result.

Versions Report
Salt Version:
           Salt: 2015.8.8

Dependency Versions:
         Jinja2: 2.8
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.2.0
         Python: 2.7.11 (default, May  7 2016, 22:38:59)
           RAET: Not Installed
        Tornado: 4.3
            ZMQ: 4.1.4
           cffi: 1.6.0
       cherrypy: Not Installed
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: gentoo 2.2 
        machine: x86_64
        release: 4.5.5-hardened-r1
         system: Gentoo Base System 2.2 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the three pillar files and the two grain configurations shown in the report, then trace the pillar source-merging path for an empty rendered mapping. Done means the common pillar data remains present when the conditional pillar renders empty, for both the smart and recurse strategies.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.