Skip to content

salt-ssh: Fix race condition when caching files to build the thin tarball - #31521

Merged
cachedout merged 5 commits into
saltstack:2015.5from
terminalmage:issue24753
Feb 29, 2016
Merged

cachedout merged 5 commits into
saltstack:2015.5from
terminalmage:issue24753

Conversation

@terminalmage

Copy link
Copy Markdown
Contributor

This pull request extends the fileclient such that it is possible to override
the base directory for file caching. The new "cachedir" param can be either a
relative path or an absolute path. If it is relative, the path will be appended
to __opts__['cachedir'], and if it is absolute then it will take the place of
__opts__['cachedir'].

Note that this functionality is only used by salt-ssh. The cp execution module
has not been updated to use it, because there doesn't appear to be a use case
for it.

Fixes #24753

@terminalmage

Copy link
Copy Markdown
Contributor Author

To test this PR

  1. Create a file in the root of your salt fileserver:

    $ echo "{{ grains['os'] }}" >/srv/salt/foo.txt
  2. Use salt-ssh to deploy it:

    $ salt-ssh minion_id state.single file.managed /tmp/foo.txt source=salt://foo.txt template=jinja
    minion_id:
    ----------
              ID: /tmp/foo.txt
        Function: file.managed
          Result: True
         Comment: File /tmp/foo.txt updated
         Started: 15:48:57.936234
        Duration: 90.915 ms
         Changes:
                  ----------
                  diff:
                      New file
                  mode:
                      0644
    
    Summary
    ------------
    Succeeded: 1 (changed=1)
    Failed:    0
    ------------
    Total states run:     1
  3. Use salt-ssh to make sure the file was deployed:

    $ salt-ssh minion_id cmd.run 'cat /tmp/foo.txt'
    minion_id:
        Arch
  4. Confirm that the file was cached to the master under /var/cache/salt/master/salt-ssh:

    $ find /var/cache/salt/master/salt-ssh
    /var/cache/salt/master/salt-ssh/minion_id/files
    /var/cache/salt/master/salt-ssh/minion_id/files/base
    /var/cache/salt/master/salt-ssh/minion_id/files/base/foo.txt
  5. Test cp.get_file, cp.get_dir, and cp.get_url using salt-ssh, and confirm as in step 4 above that the files were cached underneath /var/cache/salt/master/salt-ssh. Clean out the salt-ssh file cache using rm -rf /var/cache/salt/master/salt-ssh before testing each of these to be sure that the files are actually being cached.

This commit extends the fileclient such that it is possible to override
the base directory for file caching. The new "cachedir" param can be
either a relative path or an absolute path. If it is relative, the path
will be appended to __opts__['cachedir'], and if it is absolute then it
will take the place of __opts__['cachedir'].
@terminalmage

Copy link
Copy Markdown
Contributor Author

I've updated the previous comment with testing instructions, please refer to it instead of the email to get info on how to test.

@terminalmage

Copy link
Copy Markdown
Contributor Author

I'm planning on adding some fileclient integration tests today, so hold off on merging.

@terminalmage

Copy link
Copy Markdown
Contributor Author

Tests were added last night and are passing.

cachedout pushed a commit that referenced this pull request Feb 29, 2016
salt-ssh: Fix race condition when caching files to build the thin tarball
@cachedout
cachedout merged commit 060a60f into saltstack:2015.5 Feb 29, 2016
@terminalmage
terminalmage deleted the issue24753 branch April 6, 2016 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants