Skip to content

FreeBSD pkgng provider raising error for minion #28262

Closed

Description

@palica

When I change the provider for pkg to pkng the minion fails to start.
This is FreeBSD 10.2 and salt 2015.8.0_1

[WARNING ] ** Restarting minion **
[INFO    ] Sleeping random_reauth_delay of 8 seconds
[DEBUG   ] Reading configuration from /usr/local/etc/salt/minion
[DEBUG   ] Including configuration from '/usr/local/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /usr/local/etc/salt/minion.d/_schedule.conf
[DEBUG   ] Including configuration from '/usr/local/etc/salt/minion.d/grains.conf'
[DEBUG   ] Reading configuration from /usr/local/etc/salt/minion.d/grains.conf
[DEBUG   ] Configuration file path: /usr/local/etc/salt/minion
[INFO    ] Setting up the Salt Minion "kostej"
[DEBUG   ] Created pidfile: /var/run/salt-minion.pid
[DEBUG   ] Reading configuration from /usr/local/etc/salt/minion
[DEBUG   ] Including configuration from '/usr/local/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /usr/local/etc/salt/minion.d/_schedule.conf
[DEBUG   ] Including configuration from '/usr/local/etc/salt/minion.d/grains.conf'
[DEBUG   ] Reading configuration from /usr/local/etc/salt/minion.d/grains.conf
[DEBUG   ] Please install 'virt-what' to improve results of the 'virtual' grain.
[INFO    ] The salt minion is starting up
[INFO    ] Minion is starting as user 'root'
[DEBUG   ] AsyncEventPublisher PUB socket URI: ipc:///var/run/salt/minion/minion_event_e3d2b40525_pub.ipc
[DEBUG   ] AsyncEventPublisher PULL socket URI: ipc:///var/run/salt/minion/minion_event_e3d2b40525_pull.ipc
[INFO    ] Starting pub socket on ipc:///var/run/salt/minion/minion_event_e3d2b40525_pub.ipc
[INFO    ] Starting pull socket on ipc:///var/run/salt/minion/minion_event_e3d2b40525_pull.ipc
[DEBUG   ] Minion 'kostej' trying to tune in
[DEBUG   ] sync_connect_master
[DEBUG   ] Initializing new SAuth for ('/usr/local/etc/salt/pki/minion', 'kostej', 'tcp://37.59.112.xx:4506')
[DEBUG   ] Generated random reconnect delay between '1000ms' and '11000ms' (10576)
[DEBUG   ] Setting zmq_reconnect_ivl to '10576ms'
[DEBUG   ] Setting zmq_reconnect_ivl_max to '11000ms'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/usr/local/etc/salt/pki/minion', 'kostej', 'tcp://37.59.112.xx:4506', 'clear')
[DEBUG   ] Decrypting the current master AES key
[DEBUG   ] Loaded minion key: /usr/local/etc/salt/pki/minion/minion.pem
[DEBUG   ] Loaded minion key: /usr/local/etc/salt/pki/minion/minion.pem
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/usr/local/etc/salt/pki/minion', 'kostej', 'tcp://37.59.112.xx:4506', 'aes')
[DEBUG   ] Re-using SAuth for ('/usr/local/etc/salt/pki/minion', 'kostej', 'tcp://37.59.112.xx:4506')
[DEBUG   ] Loaded minion key: /usr/local/etc/salt/pki/minion/minion.pem
[DEBUG   ] Reading configuration from /usr/local/etc/salt/minion
[DEBUG   ] Including configuration from '/usr/local/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /usr/local/etc/salt/minion.d/_schedule.conf
[DEBUG   ] Including configuration from '/usr/local/etc/salt/minion.d/grains.conf'
[DEBUG   ] Reading configuration from /usr/local/etc/salt/minion.d/grains.conf
[DEBUG   ] Please install 'virt-what' to improve results of the 'virtual' grain.
[ERROR   ] Exception raised when processing __virtual__ function for ifttt. Module will not be loaded global name '__salt__' is not defined
[WARNING ] salt.loaded.int.module.ifttt.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If
 you're the developer of the module 'ifttt', please fix this.
[ERROR   ] Exception raised when processing __virtual__ function for victorops. Module will not be loaded global name '__salt__' is not defi
ned
[WARNING ] salt.loaded.int.module.victorops.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name
. If you're the developer of the module 'victorops', please fix this.
[DEBUG   ] Error loading module.tls: ['PyOpenSSL version 0.10 or later must be installed before this module can be used.']
[DEBUG   ] SMBIOS: neither dmidecode nor smbios found!
[DEBUG   ] Error loading module.nacl: libnacl import error, perhaps missing python libnacl package
[ERROR   ] Exception raised when processing __virtual__ function for zfs. Module will not be loaded global name '__salt__' is not defined
[WARNING ] salt.loaded.int.module.zfs.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If y
ou're the developer of the module 'zfs', please fix this.
[DEBUG   ] Error loading module.ipmi: No module named pyghmi.ipmi
[DEBUG   ] Error loading module.npm: npm execution module could not be loaded because the npm binary could not be located
[INFO    ] The salt minion is shut down
[ERROR   ] Minion failed to start: 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/salt/scripts.py", line 81, in minion_process
    minion.start()
  File "/usr/local/lib/python2.7/site-packages/salt/cli/daemons.py", line 272, in start
    self.minion.tune_in()
  File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 1596, in tune_in
    self.sync_connect_master()
  File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 724, in sync_connect_master
    raise six.reraise(*future_exception)
  File "/usr/local/lib/python2.7/site-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 732, in connect_master
    yield self._post_master_init(master)
  File "/usr/local/lib/python2.7/site-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/local/lib/python2.7/site-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/local/lib/python2.7/site-packages/tornado/gen.py", line 879, in run
    yielded = self.gen.send(value)
  File "/usr/local/lib/python2.7/site-packages/salt/minion.py", line 763, in _post_master_init
    self.returners)
  File "/usr/local/lib/python2.7/site-packages/salt/utils/schedule.py", line 318, in __init__
    self.time_offset = self.functions.get('timezone.get_offset', lambda: '0000')()
  File "/usr/local/lib/python2.7/site-packages/salt/modules/timezone.py", line 94, in get_offset
    out = __salt__['cmd.run'](cmd)
NameError: global name '__salt__' is not defined

Activity

  1. palica commented on Oct 23, 2015

    @palica
    Author

    with the default provider values the packages don't get upgraded.

    [INFO    ] Running state [mosh] at time 23:27:07.528386
    [INFO    ] Executing state pkg.latest for mosh
    [INFO    ] Executing command 'pkg search mosh' in directory '/root'
    [DEBUG   ] Could not LazyLoad pkg.version_cmp
    [DEBUG   ] Could not LazyLoad pkg.normalize_name
    [INFO    ] Executing command 'pkg install  -y mosh' in directory '/root'
    [INFO    ] Executing command 'pkg info -ao' in directory '/root'
    [ERROR   ] Package mosh failed to update.
    [INFO    ] Completed state [mosh] at time 23:27:09.335900
    
  2. added
    bug
    severity-medium
    Platform
    P3
    on Oct 26, 2015
  3. added this to the Approved milestone on Oct 26, 2015
  4. jfindlay commented on Oct 26, 2015

    @jfindlay
    Contributor

    @palica, thanks for the report. It seems that there are three issues here:

    1. my guess is that there is some sort of code error the loader encounters when the pkg provider is set to pkgng
    2. not setting the pkg provider, causes install candidates to not get installed, and
    3. when the loader encounters the pkgng error, rather than handling it gracefully, it fails to generate __salt__, which crashes the minion.
  5. palica commented on Oct 26, 2015

    @palica
    Author

    Thank you. I couldn't have said it nicer :). If there is something I can do
    to debug it more, let me know.

    On Mon, Oct 26, 2015 at 5:41 PM, Justin Findlay [email protected]
    wrote:

    @palica https://github.com/palica, thanks for the report. It seems that
    there are three issues here: my guess is that there is a syntax error the
    loader encounters when the pkg provider is set to pkgng, not setting the
    pkg provider, causes install candidates to not get installed, and when the
    loader encounters the pkgng error, rather than handling it gracefully, it
    fails to generate salt, which crashes the minion.

    —
    Reply to this email directly or view it on GitHub
    #28262 (comment).

  6. kraileth commented on Oct 27, 2015

    @kraileth

    On friday I ran into the same or a related issue, I think. Perhaps I can supply a bit more of information that may be helpful. My test machine is also FreeBSD 10.2 and I'm also using Salt Stack version 2015.8.0 for evaluation. I begun with a simple masterless setup and specifying programs to install does work. What does not is using "latest" - it will install the package if it is absent but then error out for some reason.

    For example this works as intended:
    sudo:
    pkg.installed

    Whereas this causes the same problem that palica described above:

    sudo:
    pkg.latest

    Using "latest" leads to this output if sudo is not yet present on the system:

    sudo:
      pkg.latest
    
    [DEBUG   ] LazyLoaded config.get
    [DEBUG   ] Results of YAML rendering: 
    OrderedDict([('sudo', 'pkg.latest')])
    [DEBUG   ] LazyLoaded pkg.install
    [DEBUG   ] LazyLoaded pkg.latest
    [DEBUG   ] Error loading module.ifttt: IFTTT Secret Key Unavailable, not loading.
    [DEBUG   ] Error loading module.npm: npm execution module could not be loaded because the npm binary could not be located
    [DEBUG   ] Error loading module.tls: ['PyOpenSSL version 0.10 or later must be installed before this module can be used.']
    [DEBUG   ] Error loading module.victorops: No VictorOps api key found.
    [DEBUG   ] Error loading module.nacl: libnacl import error, perhaps missing python libnacl package
    [DEBUG   ] Error loading module.ipmi: No module named pyghmi.ipmi
    [DEBUG   ] SMBIOS: neither dmidecode nor smbios found!
    [DEBUG   ] Could not LazyLoad pkg.ex_mod_init
    [INFO    ] Running state [sudo] at time 09:53:15.896138
    [INFO    ] Executing state pkg.latest for sudo
    [INFO    ] Executing command 'pkg info -ao' in directory '/root'
    [INFO    ] Executing command 'pkg search sudo' in directory '/root'
    [DEBUG   ] Could not LazyLoad pkg.version_cmp
    [DEBUG   ] Could not LazyLoad pkg.normalize_name
    [INFO    ] Executing command 'pkg install  -y sudo' in directory '/root'
    [INFO    ] Executing command 'pkg info -ao' in directory '/root'
    [ERROR   ] Made the following changes:
    'sudo' changed from 'absent' to '1.8.14p3'
    
    [DEBUG   ] Refreshing modules...
    [INFO    ] Loading fresh modules for state activity
    [DEBUG   ] LazyLoaded jinja.render
    [DEBUG   ] LazyLoaded yaml.render
    [INFO    ] Completed state [sudo] at time 09:53:16.950213
    [DEBUG   ] File /var/cache/salt/minion/accumulator/34563144144 does not exist, no need to cleanup.
    [DEBUG   ] LazyLoaded highstate.output
    [DEBUG   ] LazyLoaded nested.output
    local:
    ----------
              ID: sudo
        Function: pkg.latest
          Result: False
         Comment: The following packages failed to update: sudo
         Started: 09:53:15.896138
        Duration: 1054.075 ms
         Changes:   
                  ----------
                  sudo:
                      ----------
                      new:
                          1.8.14p3
                      old:
    
    Summary for local
    ------------
    Succeeded: 0 (changed=1)
    Failed:    1
    ------------
    Total states run:     1
    Total run time:   1.054 s
    

    I have no idea why Salt Stack thinks that installing failed. The change that it detected is exactly what it was meant to apply. And here's what happens if the current version of sudo is already present:

    sudo:
      pkg.latest
    
    [DEBUG   ] LazyLoaded config.get
    [DEBUG   ] Results of YAML rendering: 
    OrderedDict([('sudo', 'pkg.latest')])
    [DEBUG   ] LazyLoaded pkg.install
    [DEBUG   ] LazyLoaded pkg.latest
    [DEBUG   ] Error loading module.ifttt: IFTTT Secret Key Unavailable, not loading.
    [DEBUG   ] Error loading module.npm: npm execution module could not be loaded because the npm binary could not be located
    [DEBUG   ] Error loading module.tls: ['PyOpenSSL version 0.10 or later must be installed before this module can be used.']
    [DEBUG   ] Error loading module.victorops: No VictorOps api key found.
    [DEBUG   ] Error loading module.nacl: libnacl import error, perhaps missing python libnacl package
    [DEBUG   ] Error loading module.ipmi: No module named pyghmi.ipmi
    [DEBUG   ] SMBIOS: neither dmidecode nor smbios found!
    [DEBUG   ] Could not LazyLoad pkg.ex_mod_init
    [INFO    ] Running state [sudo] at time 09:55:23.267159
    [INFO    ] Executing state pkg.latest for sudo
    [INFO    ] Executing command 'pkg info -ao' in directory '/root'
    [INFO    ] Executing command 'pkg search sudo' in directory '/root'
    [DEBUG   ] Could not LazyLoad pkg.version_cmp
    [DEBUG   ] Could not LazyLoad pkg.normalize_name
    [INFO    ] Executing command 'pkg install  -y sudo' in directory '/root'
    [INFO    ] Executing command 'pkg info -ao' in directory '/root'
    [ERROR   ] Package sudo failed to update.
    [INFO    ] Completed state [sudo] at time 09:55:24.019566
    [DEBUG   ] File /var/cache/salt/minion/accumulator/34563144144 does not exist, no need to cleanup.
    [DEBUG   ] LazyLoaded highstate.output
    local:
    ----------
              ID: sudo
        Function: pkg.latest
          Result: False
         Comment: Package sudo failed to update.
         Started: 09:55:23.267159
        Duration: 752.407 ms
         Changes:   
    
    Summary for local
    ------------
    Succeeded: 0
    Failed:    1
    ------------
    Total states run:     1
    Total run time: 752.407 ms
    

    I've tested the commands from the "[INFO ] Executing command" lines and they all result in a return code of 0 so that should not be a problem.

    If any more information is needed, I'd also gladly provide it.

  7. jfindlay commented on Oct 27, 2015

    @jfindlay
    Contributor
  8. cedwards commented on Oct 27, 2015

    @cedwards
    Contributor

    On FreeBSD 10.x the pkg provider will default to pkgng, so setting the value is not required. It was primarily put in place (and perhaps @terminalmage can comment here) for use during the transitional period between 9.x and 10.x as people on-boarded to pkgng.

    According to the __virtual__ function:

    Load as 'pkg' on FreeBSD 10 and greater.
    Load as 'pkg' on FreeBSD 9 when config option
    ``providers:pkg`` is set to 'pkgng'.
    

    Sounds to me like we need to clarify when/if providers should be set.

  9. cedwards commented on Oct 28, 2015

    @cedwards
    Contributor

    I can confirm that pkg.latest gives false-negative output. It tells me that the latest fails, but it actually looks to be successful. I have not caught this before because I prefer not to use latest to avoid surprise updates.

  10. amontalban commented on Apr 5, 2016

    @amontalban
    Contributor

    +1

  11. amontalban commented on Apr 5, 2016

    @amontalban
    Contributor

    This are my findings so far:

    Salt Versions (I'm using latest version available in FreeBSD packages)

    Salt Version:
               Salt: 2015.8.8
    
    Dependency Versions:
             Jinja2: 2.8
           M2Crypto: Not Installed
               Mako: Not Installed
             PyYAML: 3.11
              PyZMQ: 15.2.0
             Python: 2.7.11 (default, Mar 19 2016, 01:13:51)
               RAET: Not Installed
            Tornado: 4.3
                ZMQ: 4.1.4
               cffi: Not Installed
           cherrypy: Not Installed
           dateutil: 2.5.0
              gitdb: Not Installed
          gitpython: Not Installed
              ioflo: Not Installed
            libgit2: Not Installed
            libnacl: Not Installed
       msgpack-pure: Not Installed
     msgpack-python: 0.4.7
       mysql-python: 1.2.5
          pycparser: Not Installed
           pycrypto: 2.6.1
             pygit2: Not Installed
       python-gnupg: Not Installed
              smmap: Not Installed
            timelib: Not Installed
    
    System Versions:
               dist:   
            machine: amd64
            release: 10.1-RELEASE-p31
    

    My example SLS:

    nginx:
      pkg.latest:
        - name: nginx
        - require:
          - cmd: repository_update
        - fromrepo: REPOSITORY
    
    repository_update:
      cmd.wait:
        - name: pkg update -f

    My scenario:

    • I have a custom packages repository where I have latest version of NGINX of port which is 1.8.1_1,2
    • FreeBSD official packages repository have a NGINX version of 1.8.1,2 (Older than latest port, at least right now).
    • This have not failed for me before (Been using pkg.latest for a while) so I think this can be a corner case.

    The lines that mark the package upgrade as failed are present in salt/states/pkg.py.

    So for the help of any developer this are some useful outputs:

    Command: pkg search -q nginx

    [root@devserver ~]# pkg search -q nginx
    nginx-1.8.1,2
    nginx-devel-1.9.12
    p5-Nginx-ReadBody-0.07_1
    p5-Nginx-Simple-0.07_1
    p5-Test-Nginx-0.25
    nginx-1.8.1_1,2

    Command: pkg info -ao | grep -i nginx

    [root@devserver ~]# pkg info -ao | grep -i nginx
    nginx-1.8.1_1,2                www/nginx

    What I found is that pkg.py targets to version 1.8.1,2 and when it does the following comparision:

                # Find failed and successful updates
                failed = [x for x in targets
                          if not changes.get(x) or changes[x]['new'] != targets[x]]

    changes[x]['new'] will be different than targets[x] because changes[x]['new'] will be 1.8.1_1,2 and targets[x] will be 1.8.1,2.

    So the proper way to fix this will be to parse the output of pkg search -q packagename and select the higher version and assign it to targets so it compares the proper versions.

    Hope this helps someone to get on the right direction, unfortunately I'm lacking of time to take this but if no one takes it maybe I can do it over weekend.

    Thanks!

  12. 4 remaining items

  13. terminalmage commented on Apr 5, 2016

    @terminalmage
    Contributor

    Awesome. I just wanted to make sure that we preserved expected behavior when a package is already up-to-date.

    Can you submit a pull request?

  14. amontalban commented on Apr 5, 2016

    @amontalban
    Contributor

    Sure thing! Should I do it against 2015.8.8 or develop branch?

    Thanks

  15. terminalmage commented on Apr 5, 2016

    @terminalmage
    Contributor

    Open it against the 2015.8 branch, please. Thanks!

  16. amontalban commented on Apr 5, 2016

    @amontalban
    Contributor

    @terminalmage sorry for the noise, but github was acting funny and the commits were not visible. I have created PR #32376.

    Thanks!

  17. added a commit that references this issue on Apr 6, 2016
    802580e
  18. terminalmage commented on Apr 6, 2016

    @terminalmage
    Contributor

    Thanks, I've merged the pull request.

  19. added a commit that references this issue on Apr 6, 2016
    a36866d
  20. added a commit that references this issue on Apr 11, 2016
    216d9fd
  21. added 2 commits that reference this issue on Dec 19, 2023
    7ade93e
    9657435
  22. added a commit that references this issue on Nov 2, 2024
    082b0ed
  23. added a commit that references this issue on Mar 6, 2025
    e46dcb6
  24. added a commit that references this issue on Aug 13, 2026
    cb3ad5f
  25. added a commit that references this issue on Sep 15, 2026
    462a080
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

    LoaderP3Platformbugseverity-medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions