Skip to content

[BUG] Inline Pillars are still getting cached in a particular scenario when pillar_cache is set to True #67904

Open
@sanket925

Description

@sanket925

Description
We have found that despite #66292 is fixed , inline pillars are still getting cached in a particular scenario.

Setup
pillar cache is enabled

#/etc/salt/master.d/master.conf

user: root
pillar_cache: True

orchestration file test_pillar_cache_orch.sls:

{%- set event_data = salt.pillar.get('event_data') %}
{# this is the master minion #}
{%- set master_minion = salt.pillar.get('master_minion') %}

{%- do salt.cmd.run('salt ' ~ master_minion ~ ' saltutil.refresh_pillar') %}
{%- do salt.cmd.run('sleep 60') %}  # Time to reflect pillar data change after pillar refresh is done.

{%- do salt.state.apply(mods='test_pillar_cache_state',
                       concurrent=True,
                       failhard=True) %}

State file test_pillar_cache_state:

{% set event_data = salt.pillar.get('event_data', None) %}

debug_msg:
  cmd.run:
    - name: "echo {{event_data}}"

Driver code driver_code.sh

rm -rf nohup.out
nohup salt-run state.orch test_pillar_cache_orch pillar="{'event_data': {'pillar1': 'value1'}, 'master_minion':'<master_minion_name>'}" &

nohup salt-run state.orch test_pillar_cache_orch pillar="{'event_data': {'pillar1': 'value2', 'pillar2': 'value2'}, 'master_minion':'<master_minion_name>'}" &

test script to print the pillar after the problem is reproduced test.sls

{% set event_data = salt.pillar.get('event_data', None) %}

debug_msg:
  cmd.run:
    - name: "echo {{event_data}}"

Please be as specific as possible and give set-up details.

My setup is on a docker container running with redhat 9 as base image.

Steps to Reproduce the behavior
1 replace the master minion name in driver_code.sh
2 run driver_code.sh
3 salt-run state.orch test

If the problem is reproduced , the pillars passed to the orchs in driver code are printed in test.sls execution.

Additionally what we found is when the problem gets reproduced , pillarenv is None which should be base as default. We have also made an attempt to fix the issue which resolves the problem .
here is the PR : #67899
Though the root cause could be different , but adding a null check similar to saltenv in the above code actually solves the problem . Until root cause is found , will this be a safe fix ?

We also attempted to throw an exception when pillarenv is none and this is what it prints

NoneType: None
2025-03-20 18:19:13,148 [salt.master      :1935][ERROR   ][6892] Error in function _pillar:
Traceback (most recent call last):
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/master.py", line 1929, in run_func
    ret = getattr(self, func)(load)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/master.py", line 1608, in _pillar
    pillar = salt.pillar.get_pillar(
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/__init__.py", line 75, in get_pillar
    return PillarCache(
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/__init__.py", line 454, in __init__

Expected behavior
Inline pillars passed to an orchestration should not be cached.

Screenshots
Image

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3006.8

Python Version:
        Python: 3.10.14 (main, Apr  3 2024, 21:30:09) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: 4.0.12
     gitpython: 3.1.44
        Jinja2: 3.1.3
       libgit2: Not Installed
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.16.0
         smmap: 5.0.2
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: rhel 9.5 Plow
        locale: utf-8
       machine: x86_64
       release: 3.10.0-1160.59.1.el7.x86_64
        system: Linux
       version: Red Hat Enterprise Linux 9.5 Plow

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugbroken, incorrect, or confusing behaviorneeds-triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions