saltstack / saltstack/salt

[BUG] Git files disappear when saltenv mapping is changed, new saltenv mapping not recognized.

Open
#60,686 0 comments 0 reactions 1 assignee View on GitHub

@dwoz is already working on this.

Since Aug 6, 2021.

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

Description

Description

  1. Per remote saltenv mapping doesn't work when changed from initial setting.
  2. After the change, the files disappear from old as well as the new saltenv.

Versions Report

[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-master -V
Salt Version:
          Salt: 3003.1
 
Dependency Versions:
          cffi: 1.14.6
      cherrypy: Not Installed
      dateutil: 2.6.1
     docker-py: Not Installed
         gitdb: 4.0.7
     gitpython: 3.1.20
        Jinja2: 2.10.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: Not Installed
        Python: 3.6.8 (default, Aug 24 2020, 17:57:11)
  python-gnupg: Not Installed
        PyYAML: 3.12
         PyZMQ: 19.0.0
         smmap: 4.0.0
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
Salt Extensions:
        sseape: 0+unknown
 
System Versions:
          dist: centos 8 
        locale: UTF-8
       machine: x86_64
       release: 5.10.25-linuxkit
        system: Linux
       version: CentOS Linux 8 
 
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# 

Step to reproduce

Initial configuration:

  1. My repo is public with one file test.sls, with one branch main, one commit, one tag v1.
  2. Map branch main to saltenv foo.
fileserver_backend:
  - gitfs
  - sseapi
  - roots

gitfs_ref_types:
  - branch

gitfs_remotes:
  - https://github.com/cheburakshu/state.git:
    - saltenv:
      - foo:
        - ref: main

Clean start:

  1. Remove any old file_lists and gifts
  2. Restart salt-master
  3. Update fileserver.
  4. Verify saltenv foo shows up - ✅
  5. Verify file test.sls is listed under saltenv foo - ✅
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# rm -Rf /var/cache/salt/master/[file_lists,gitfs]
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# systemctl restart salt-master
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.update
True
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.envs
- base
- foo
- sse
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.file_list saltenv=foo
- test.sls
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# 

Now change the mapping:

  1. Change ref type to tag.
  2. Change the mapping to point tag v1 to saltenv bar.
fileserver_backend:
  - gitfs
  - sseapi
  - roots

gitfs_ref_types:
  - tag

gitfs_remotes:
  - https://github.com/cheburakshu/state.git:
    - saltenv:
      - bar:
        - ref: v1
  • Restart salt-master to reflect new config
  • Update fileserver
  • Verify saltenv bar shows up - ❌
  • Verify saltenv foo is absent - ❌
  • Verify file test.sls is listed under saltenv bar - ❌
  • Verify file test.sls is absent under saltenv foo - ✅
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# systemctl restart salt-master
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.update
True
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.envs
- base
- foo
- sse
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# 
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.file_list saltenv=bar
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.file_list saltenv=foo
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# 

WORKAROUND
This should ideally happen automatically upon config change. There are stale env files present in other directories that need cleanup even with this workaround.

  • Delete envs.p under gitfs
  • Restart salt-master (optional)
  • Verify saltenv bar shows up - ✅
  • Verify saltenv foo is absent - ✅
  • Verify file test.sls is listed under saltenv bar - ✅
  • Verify file test.sls is absent under saltenv foo - ✅
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# rm -f /var/cache/salt/master/gitfs/envs.p 
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# systemctl restart salt-master
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.update
True
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.envs
- bar
- base
- sse
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# salt-run fileserver.file_list saltenv=bar
- test.sls
[root@salt-master-58cbd5c9cd-jf8c6 master.d]# 

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.