Skip to content

strange behaviour with zfs.filesystem_present and pkg state in combination #51042

Closed

Description

@L4rS6

Description of Issue/Question

If minimum two pkg states (e.g. purged, or installed) are executed before the zfs.filesystem_present state, then an exception will be thrown.

Setup

init.sls file

pkgs_deinstalled:
  pkg.purged:
      - name: nonexistend

pkgs_deinstalled2:
  pkg.installed:
      - name: nonexistend

user_home_test:
  zfs.filesystem_present:
    - name: zroot/home/test

Steps to Reproduce Issue

Run the init.sls file above and you'll get an exception like this:

----------
          ID: user_home_test
    Function: zfs.filesystem_present
        Name: zroot/home/test
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/local/lib/python2.7/site-packages/salt/state.py", line 1913, in call
                  **cdata['kwargs'])
                File "/usr/local/lib/python2.7/site-packages/salt/loader.py", line 1898, in wrapper
                  return f(*args, **kwargs)
                File "/usr/local/lib/python2.7/site-packages/salt/states/zfs.py", line 582, in filesystem_present
                  cloned_from=cloned_from,
                File "/usr/local/lib/python2.7/site-packages/salt/states/zfs.py", line 453, in _dataset_present
                  if __salt__['zfs.exists'](name, **{'type': dataset_type}):
                File "/usr/local/lib/python2.7/site-packages/salt/modules/zfs.py", line 78, in exists
                  __utils__['zfs.zfs_command'](
                File "/usr/local/lib/python2.7/site-packages/salt/utils/context.py", line 228, in __getitem__
                  return self._dict()[key]
              KeyError: u'zfs.zfs_command'
     Started: 15:01:50.148276
    Duration: 2.946 ms
     Changes:

The weird thing is that this exception is only thrown if the order is like above (1st pkg state, 2nd pkg state and 3rd zfs.filesystem_present) and it doesn't matter if it's a pkg.purged or pkg.installed state. If I change the order like 1st pkg.purged, 2nd zfs.filesystem_present and 3rd pkg.installed, then it works.

I was not able to figure out where this dict (self._dict() in context.py class) gets overwritten and why it only gets overwritten if there are two pkg states first.

The same state works on FreeBSD 10 with salt-minion 2017.7.3

Versions Report

salt-minion 2018.3.3 (Oxygen) and FreeBSD 11

Activity

  1. dwoz commented on Jan 4, 2019

    @dwoz
    Contributor

    @L4rS6 Thanks for reporting the issue.

    @nmadhok Can you look into this one please?

  2. added
    bug
    severity-low
    P4
    on Jan 4, 2019
  3. added this to the Approved milestone on Jan 4, 2019
  4. L4rS6 commented on Feb 7, 2019

    @L4rS6
    ContributorAuthor

    Any news when this will be fixed?

  5. stale commented on Jan 9, 2020

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

    If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

  6. L4rS6 commented on Jan 9, 2020

    @L4rS6
    ContributorAuthor

    Problem still exists.

  7. stale commented on Jan 9, 2020

    @stale

    Thank you for updating this issue. It is no longer marked as stale.

  8. krionbsd commented on Mar 13, 2020

    @krionbsd
    Contributor

    I can't reproduce it with:

    Salt Version:                                                                                                                           
               Salt: 2019.2.3                                                                                                               
                                                                                                                                            
    Dependency Versions:                                                                                                                    
               cffi: 1.14.0                                                                                                                 
           cherrypy: Not Installed                                                                                                          
           dateutil: Not Installed                                                                                                          
          docker-py: Not Installed                                                                                                          
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
             Jinja2: 2.10.1
            libgit2: Not Installed
            libnacl: Not Installed
           M2Crypto: Not Installed
               Mako: Not Installed
       msgpack-pure: Not Installed
     msgpack-python: 0.6.2
       mysql-python: Not Installed
          pycparser: 2.19
           pycrypto: 2.6.1
       pycryptodome: Not Installed
             pygit2: Not Installed
             Python: 3.7.6 (default, Dec 23 2019, 22:01:37)
       python-gnupg: Not Installed
             PyYAML: 5.2
              PyZMQ: 18.1.1
               RAET: Not Installed
              smmap: Not Installed
            timelib: Not Installed
            Tornado: 4.5.3
                ZMQ: 4.3.1
     
    System Versions:
               dist:   
             locale: UTF-8
            machine: amd64
            release: 13.0-CURRENT
             system: FreeBSD
            version: Not Installed
    
    mothership# cat test.sls 
    pkgs_deinstalled:
      pkg.purged:
          - name: nonexistend
    
    pkgs_deinstalled2:
      pkg.installed:
          - name: nonexistend
    
    user_home_test:
      zfs.filesystem_present:
        - name: zroot/home
    
    mothership# salt mother\* state.apply test test=True --state-verbose=False
    mothership:
    ----------
              ID: pkgs_deinstalled2
        Function: pkg.installed
            Name: nonexistend
          Result: None
         Comment: The following packages would be installed/updated: nonexistend
         Started: 00:05:19.823497
        Duration: 63.48 ms
         Changes:   
    
    Summary for mothership
    ------------
    Succeeded: 3 (unchanged=1)
    Failed:    0
    ------------
    Total states run:     3
    Total run time: 201.320 ms
    
  9. L4rS6 commented on Mar 16, 2020

    @L4rS6
    ContributorAuthor

    You're right, the problem doesn't exist any longer (SaltStack Version 3000).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4bugseverity-low

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions