Skip to content

mine.update doesn't update the salt mine when called with module.run #47675

Closed

Description

Description of Issue

The salt mine is not updated when mine.update is called with module.run. Calling mine.update directly with salt-call updates the data in the salt mine, though.

Setup

  1. Configure the minion you're testing with to use a newer version of module.run by putting the following lines into the minion configuration file (usually /etc/salt/minion):
use_superseded:
  - module.run
  1. Add to the pillar data for the minion you're testing this with:
mine_functions:
  uptime:
    mine_function: status.uptime
  1. Run salt-call saltutil.refresh_pillar on the minion you're testing this with.
  2. Ensure there aren't any leftovers in the salt mine by running salt-call mine.flush on the minion you're testing this with.
  3. Put the following into a state file, e.g. test/m.sls:
mine.update:
  module.run
  1. Apply the state salt-call state.apply test.m in the minion you're testing this with.
  2. Check what, if anything, got into the salt mine when the state was applied by running salt-call mine-get.get '<this minion>' uptime. Voilà, if your setup works like mine, you get no data from the salt mine.
  3. To ensure it's not just your salt mine that is broken, run salt-call mine.update && salt-call mine-get '<this-inion>' uptime on the minion you're testing this with.

Running salt-call mine.update && salt-call mine-get '<this-inion>' uptime multiple times should show that the seconds value in the salt mine data for this minion is updated oh every subsequent run of salt-call mine.update. However, when running salt-call state.apply m.test repeatedly the values in the salt mine don't change (if your setup works like mine does).

Steps to Reproduce Issue

Steps to reproduce the issue have been combined with the section "Setup" above.

Versions Report

Salt Master Version Report

Salt Version:
           Salt: 2017.7.5
 
Dependency Versions:
           cffi: 1.5.2
       cherrypy: 3.5.0
       dateutil: 2.4.2
      docker-py: 1.9.0
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: 0.24.0
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.24.0
         Python: 2.7.12 (default, Dec  4 2017, 14:50:18)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: Ubuntu 16.04 xenial
         locale: ISO-8859-1
        machine: x86_64
        release: 4.4.0-122-generic
         system: Linux
        version: Ubuntu 16.04 xenial

Salt Minion Version Report

Salt Version:
           Salt: 2017.7.5
 
Dependency Versions:
           cffi: 1.5.2
       cherrypy: 3.5.0
       dateutil: 2.4.2
      docker-py: 1.9.0
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: 0.24.0
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.24.0
         Python: 2.7.12 (default, Dec  4 2017, 14:50:18)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: Ubuntu 16.04 xenial
         locale: ISO-8859-1
        machine: x86_64
        release: 4.4.0-122-generic
         system: Linux
        version: Ubuntu 16.04 xenial

Additional Information

It appears that calling mine.send with module.run in a state file fails to update the salt mine in a similar fashion. However, to keep the length of this issue report within the limits of "readable", I left the details concerning mine.send out of it as I am fairly certain that fixing one will result in both getting fixed.

Activity

  1. Ch3LL commented on May 16, 2018

    @Ch3LL
    Contributor

    i'm not able to replicate this. it is working fine for me. Here is my use case. please correct me if you see something different you are doing in your scenario:

    [root@f687ffdb4945 /]# salt-call mine.flush
    local:
        True
    [root@f687ffdb4945 /]# salt-call mine.get 'f687ffdb4945' uptime
    local:
        ----------
    [root@f687ffdb4945 /]# salt-call state.apply test
    [WARNING ] The function "module.run" is using its deprecated version and will expire in version "Sodium".
    local:
    ----------
              ID: mine.update
        Function: module.run
          Result: True
         Comment: Module function mine.update executed
         Started: 13:06:10.938289
        Duration: 637.472 ms
         Changes:   
                  ----------
                  ret:
                      True
    
    Summary for local
    ------------
    Succeeded: 1 (changed=1)
    Failed:    0
    ------------
    Total states run:     1
    Total run time: 637.472 ms
    [root@f687ffdb4945 /]# salt-call mine.get 'f687ffdb4945' uptime
    local:
        ----------
        f687ffdb4945:
            ----------
            days:
                0
            seconds:
                71182
            since_iso:
                2018-05-15T17:19:48.940149
            since_t:
                1526404788
            time:
                19:46
            users:
                1
    [root@f687ffdb4945 /]# salt --version
    salt 2017.7.5 (Nitrogen)
    

    Did you just see this after an upgrade? I wonder if your cache has been corrupt by chance? maybe wipe out the cache?

  2. added
    cannot-reproduce
    needs-more-info
    on May 16, 2018
  3. added this to the Blocked milestone on May 16, 2018
  4. Ch3LL commented on May 17, 2018

    @Ch3LL
    Contributor

    ahh thanks for updating.

    So it seems with the new syntax of module.run you cannot simply run:

    mine.update:
      module.run
    

    with the function as the state id:

    Here is a workaround in the meantime:

    updat_mine:
      module.run:
        - mine.update:
    

    ping @isbm is this on purpose? this seems to break expected functionality to be able to set the id as the function name as well.

  5. added
    pending-discussion
    and removed
    cannot-reproduce
    needs-more-info
    on May 17, 2018
  6. Reiner030 commented on Jan 15, 2019

    @Reiner030

    In many issues it's interesting to monitor what on "your" side get's a "Cannot Reproduce" ...

    To be prepared for Sodium I changed my states to actual "module.run" version.
    For all other calls it works fine so I found this bug only now because on one developer VM it was called and this state is required in other states (and normally called as module.wait).

    Tested first with (not updated Dev VM saltstack version):

    root@vagrant-dev-7355:~# salt-call --version
    salt-call 2017.7.2 (Nitrogen)
    

    and then with my actual saltstack version for all instances:

    root@vagrant-dev-7355:~# salt-call --version
    salt-call 2017.7.8 (Nitrogen)
    

    Simplified state file system/minion.sls:

    salt-mine-update:
      module.run:
        - mine.update:
    

    ... and the result is "CAN Reproduce":

    root@vagrant-dev-7355:~# salt-call state.apply system.minion
    [WARNING ] The function "module.run" is using its deprecated version and will expire in version "Sodium".
    [ERROR   ] Module function salt-mine-update is not available
    local:
    ----------
              ID: salt-mine-update
        Function: module.run
          Result: False
         Comment: Module function salt-mine-update is not available
         Started: 15:40:14.777892
        Duration: 0.799 ms
         Changes:
    
    Summary for local
    ------------
    Succeeded: 0
    Failed:    1
    ------------
    Total states run:     1
    Total run time:   0.799 ms
    

    The interesting part here is that I migrated to "new version" but still get complains about using "deprecated version"... so my setup which is equal to your posted workaround isn't working ?!?!?

    Btw. mine.update is working fine for both versions:

    root@vagrant-dev-7355:~# salt-call  mine.update
    local:
        True
    
  7. Ch3LL commented on Jan 17, 2019

    @Ch3LL
    Contributor

    I was able to replicate the issue after the initial reporter verified he was using the new version of module.run. To verify do you have this set in your minion config?

    use_superseded:
      - module.run
    

    the error you are seeing means its trying to load the state_id as a function which is the old usage of module.run.

    also bump @isbm for my initial question in my comment above.

  8. Reiner030 commented on Jan 25, 2019

    @Reiner030

    yes with this modification this state is also working correctly. thx.

    But there are still several (documentation) bugs because:

    • Improvement: Saltstack is complaining about using old functionality:
    [WARNING ] The function "module.run" is using its deprecated version and will expire in version "Sodium".
    

    without telling the user that he needs modification to activate the new version

    • Bug: Saltstack is running fine without this modification for states in new version "with parameters" like:
    postfix-main-smtp_generic_maps:
      module.run:
        - postfix.set_main:
          - key: "smtp_generic_maps"
          - value: "hash:/etc/postfix/generic"
        - unless: grep "^smtp_generic_maps = hash:/etc/postfix/generic" /etc/postfix/main.cf
        - require:
          - pkg: postfix
        - watch_in:
          - service: postfix
    

    but fails in new variant "without parameters" like above:

    salt-mine-update:
      module.run:
        - mine.update:
    

    which is a very weird behavior... Else it works for none or for both setups ?!?
    This was the main problem because only one state out of 27 was failing in my case so I reported it in this issue as still open bug.

    Bests ;)

  9. Ch3LL commented on Feb 12, 2019

    @Ch3LL
    Contributor

    thanks i'll label this a documentation bug so we can get this cleaned up.

  10. added
    documentation
    bug
    and removed
    pending-discussion
    on Feb 12, 2019
  11. modified the milestones: Blocked, Approved on Feb 12, 2019
  12. self-assigned this
    on Feb 12, 2019
  13. added
    severity-medium
    docstring-update
    on Jun 6, 2022
  14. added
    help-wanted
    pending-community-assignment
    on Sep 6, 2023
  15. dwoz commented on Jul 2, 2026

    @dwoz
    Contributor

    Fix merged and shipped in a supported release. Closing per bulk triage. Reopen if this reproduces on a currently supported release (3006.x, 3007.x, 3008.x, master).

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

    bugdocstring-updatedocumentationhelp-wantedmodule doc standardspending-community-assignmentseverity-mediumtime-estimate-sprint

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions