salt
salt copied to clipboard
Package holds with a "+" in the name continually refreshed
Description of Issue/Question
On CentOS7, using Yum, if I try to hold the following packages the state is always re-applied every run:
libstdc++-4.8.5-11.el7.x86_64
libstdc++-devel-4.8.5-11.el7.x86_64
memtest86+-5.01-2.el7.x86_64
Oddly though, this package is held fine:
gcc-c++-4.8.5-11.el7.x86_64
The result of an application of the state is always:
Changes:
----------
libstdc++:
----------
new:
hold
old:
libstdc++-devel:
----------
new:
hold
old:
memtest86+:
----------
new:
hold
old:
Setup
versionlock packages:
pkg.installed:
- hold: true
- update_holds: true
- ignore_epoch: true
- pkgs:
- gcc-c++: 4.8.5-11.el7
- libstdc++: 4.8.5-11.el7
- libstdc++-devel: 4.8.5-11.el7
- memtest86+: 5.01-2.el7
Steps to Reproduce Issue
# salt-call state.apply versionlock test=false
local:
----------
ID: versionlock packages
Function: pkg.installed
Result: True
Comment: All specified packages are already installed and are at the desired version.
Package libstdc++ is now being held..
Package memtest86+ is now being held..
Package libstdc++-devel is now being held..
Package gcc-c++ is already set to be held.
Started: 16:12:07.400054
Duration: 3184.315 ms
Changes:
----------
libstdc++:
----------
new:
hold
old:
libstdc++-devel:
----------
new:
hold
old:
memtest86+:
----------
new:
hold
old:
Summary for local
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 3.184 s
# salt-call state.apply versionlock test=true
local:
----------
ID: versionlock packages
Function: pkg.installed
Result: None
Comment: All specified packages are already installed and are at the desired version.
Package gcc-c++ is already set to be held..
Package libstdc++ is set to be held..
Package memtest86+ is set to be held..
Package libstdc++-devel is set to be held.
Started: 16:11:27.154225
Duration: 1785.079 ms
Changes:
Summary for local
------------
Succeeded: 1 (unchanged=1)
Failed: 0
------------
Total states run: 1
Total run time: 1.785 s
Versions Report
# salt-call --versions-report
Salt Version:
Salt: 2016.11.5
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.6.0
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 1.0.6
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: 3.4.3
pygit2: Not Installed
Python: 2.7.5 (default, Nov 6 2016, 00:28:07)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: centos 7.3.1611 Core
machine: x86_64
release: 3.10.0-514.21.2.el7.x86_64
system: Linux
version: CentOS Linux 7.3.1611 Core
I think I've traced down the issue - the regex used to filter out package names doesn't match on these. This will work around it:
diff --git a/yumpkg.py b/yumpkg.py
index d67bbe0..285fd01 100644
--- a/yumpkg.py
+++ b/yumpkg.py
@@ -51,7 +51,7 @@ from salt.exceptions import (
log = logging.getLogger(__name__)
-__HOLD_PATTERN = r'\w+(?:[.-][^-]+)*'
+__HOLD_PATTERN = r'[\w+]+(?:[.-][^-]+)*'
# Define the module's virtual name
__virtualname__ = 'pkg'
It's the bit where the two regex's are joined together:
lock_re = r'(\d+:{0}-\S+)'.format(pattern)
where pattern is the __HOLD_PATTERN above.
This results in lock_re of:
(\d+:\w+(?:[.-][^-]+)*-\S+)
Which will match:
0:gcc-c++-4.8.5-11.el7.*
but not:
0:libstdc++-devel-4.8.5-11.el7.*
where the "+" symbols are appearing before the "-" symbol.
Closed via #43527