saltstack / saltstack/salt

spm DB consistency problem

Open
#57,707 4 comments 0 reactions 1 assignee View on GitHub

@krionbsd is already working on this.

Since Aug 14, 2020.

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

Description

Description
spm python code only adds or removes entries from the packages and files sqlite3 tables. Theres no updates, no constraints in DB to limit the number of packages with the same name.

If one updates a package and installs it with -f option - DB will have additional entry for the same package and this will accumulate over time. Each time new version is installed. Same happens with files table that stores list of the files for each package.

spm info selects package from sqlite3 DB (which can return multiple rows) and picks one with fetchone(). If there are multiple entries - this does not even guarantee that the latest one is displayed.

If a file is removed from spm package and new version is installed, removed file still exists on the filesystem

This is related to https://github.com/saltstack/salt/issues/43239

Setup
Uploaded to https://github.com/hsergei/spm-test

Steps to Reproduce the behavior
https://github.com/hsergei/spm-test

Expected behavior
After version 0.2 installed

  • spm info test should display version 0.2
  • file ver2.sls should be removed
  • packages table should not contain row for version 0.1
  • files table should not contain rows for all version 0.1 files

Versions Report

salt --versions-report
Salt Version:
           Salt: 3000.3

Dependency Versions:
           cffi: Not Installed
       cherrypy: unknown
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.7.6 (default, Feb 26 2020, 20:54:15)
   python-gnupg: Not Installed
         PyYAML: 4.2
          PyZMQ: 17.0.0
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.3

System Versions:
           dist:
         locale: UTF-8
        machine: x86_64
        release: 4.14.177-139.254.amzn2.x86_64
         system: Linux
        version: Not Installed```
</details>


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.