Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exceptions in _get_virtual() and in _get_virtual() consumers #35207

Merged

Conversation

eliasp
Copy link
Contributor

@eliasp eliasp commented Aug 4, 2016

What does this PR do?

It makes the execution of _get_virtual() in modules.aptpkg a bit more deterministic by handling SystemError/CommandExecutionError exceptions and thereby shortens this backtrace:

          ID: git-binary-icons
    Function: pkg.installed
        Name: git
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1703, in call                                            
                  **cdata['kwargs'])                                                                                                 
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1649, in wrapper                                        
                  return f(*args, **kwargs)                                                                                          
                File "/usr/lib/python2.7/dist-packages/salt/states/pkg.py", line 1062, in installed                                  
                  **kwargs)                                                                                                          
                File "/usr/lib/python2.7/dist-packages/salt/states/pkg.py", line 300, in _find_install_targets                       
                  cur_pkgs = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs)                                              
                File "/usr/lib/python2.7/dist-packages/salt/modules/aptpkg.py", line 1182, in list_pkgs                              
                  virtpkgs_all = _get_virtual()                                                                                      
                File "/usr/lib/python2.7/dist-packages/salt/modules/aptpkg.py", line 174, in _get_virtual                            
                  apt_cache = apt.cache.Cache()                                                                                      
                File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 113, in __init__                                          
                  self.open(progress)                                                                                                
                File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 164, in open                                              
                  self._cache = apt_pkg.Cache(progress)                                                                              
              SystemError: E:Malformed line 2 in source list /etc/apt/sources.list (type), E:The list of sources could not be read.  
     Started: 19:37:06.154266
    Duration: 24.353 ms
     Changes: 

at least by a few lines to this one:

          ID: git-binary-icons
    Function: pkg.installed
        Name: git
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1703, in call                                            
                  **cdata['kwargs'])                                                                                                 
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1649, in wrapper                                        
                  return f(*args, **kwargs)                                                                                          
                File "/usr/lib/python2.7/dist-packages/salt/states/pkg.py", line 1062, in installed                                  
                  **kwargs)                                                                                                          
                File "/usr/lib/python2.7/dist-packages/salt/states/pkg.py", line 300, in _find_install_targets                       
                  cur_pkgs = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs)                                              
                File "/var/cache/salt/minion/extmods/modules/aptpkg.py", line 1193, in list_pkgs                                     
                  raise CommandExecutionError(cee)                                                                                   
              CommandExecutionError: Failed to get virtual package information (E:Malformed line 2 in source list /etc/apt/sources.list (type), E:The list of sources could not be read.)                                                                                 
     Started: 20:01:10.665930
    Duration: 30.483 ms
     Changes:

What issues does this PR fix or reference?

None

Tests written?

No

@cachedout cachedout merged commit 100645e into saltstack:2016.3 Aug 6, 2016
@cachedout
Copy link
Contributor

Thanks, @eliasp

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