saltstack / saltstack/salt

[BUG] State files using `svn.export` fails when running under `state.test`

Open
#65,487 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
Executing a highstate using the test=True parameter or using state.test will fail with an exception when the svn.export module is used.
When run as a regular highstate without the test=True parameter, the state executes without errors.

Error

----------
          ID: script_export
    Function: svn.export
        Name: https://svn.example.com/repo/path/trunk/test.txt
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python3.6/site-packages/salt/state.py", line 2277, in call
                  *cdata["args"], **cdata["kwargs"]
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1228, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
                  return callable(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1243, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1276, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/states/svn.py", line 271, in export
                  out = __salt__[svn_cmd](cwd, target, user, username, password, *opts)
                File "/usr/lib/python3.6/site-packages/salt/loader/context.py", line 78, in __getitem__
                  return self.value()[item]
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 336, in __getitem__
                  super().__getitem__(item)  # try to get the item from the dictionary
                File "/usr/lib/python3.6/site-packages/salt/utils/lazy.py", line 105, in __getitem__
                  raise KeyError(key)
              KeyError: 'svn.list'
     Started: 10:59:12.776222
    Duration: 46.759 ms
     Changes:

The underlying state file:

dns_script_dns-gen:
  svn.export:
    - name: "https://svn.example.com/repo/path/trunk/test.txt"
    - target: /tmp
    - force: true
    - trust: true
    - externals: false
    - username: {{ salt['pillar.get']("svn_credentials:username", None) }}
    - password: {{ salt['pillar.get']("svn_credentials:password", None) }}

Versions Report
Observed starting with 3005.

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

Start in salt/states/svn.py around the export function at line 271 and reproduce the provided state with state.test or test=True. Trace the svn.list lookup shown in the exception and verify that svn.export completes without an exception in test mode while preserving normal highstate behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.