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

Fix merge order of options in run_wfunc (fix mine.get issues) #41025

Closed
wants to merge 1 commit into from

Conversation

ptitdoc
Copy link

@ptitdoc ptitdoc commented May 3, 2017

What does this PR do?

This fix issues with mine.get when using salt-ssh

What issues does this PR fix or reference?

#36796

Previous Behavior

pillar.Pillar() is called with options where master_opts options are overwritten (because of dict merge/update order).

New Behavior

pillar.Pillar() is called with options where master_opts take precedence. This allow mine.get over salt-ssh to work properly.

Tests written?

No

Please review Salt's Contributing Guide for best practices.

This fix issues with mine.get when using salt-ssh (saltstack#36796)

The dict merge order matters and master_opts needs to take precedence in order to mine.get over salt-ssh to work properly.
@ghost
Copy link

ghost commented May 3, 2017

@ptitdoc, thanks for your PR! By analyzing the history of the files in this pull request, we identified @thatch45, @basepi and @ajithhub to be potential reviewers.

@cachedout cachedout requested a review from thatch45 May 3, 2017 17:26
@thatch45
Copy link
Contributor

thatch45 commented May 3, 2017

This is a very sensitive issue, because if we change this it will break other areas in state generation. We may need to build in a way to specify the opts merge order based on specific wfunc routines like mine.get because mine.get is a master centric operation and state.highstate is a minion centric operation.

So this PR needs to be able to detect what function is being requested and make the determination. I would suggest to allow the wfunc to define the centricity of the operation and then decide on the merge order

@cachedout
Copy link
Contributor

@ptitdoc Since I didn't see a response from you on the above comment, I am going to close this PR for now. When you are ready to come back to it, please leave a comment and we'll open it back up. Thanks.

@cachedout cachedout closed this May 12, 2017
@ptitdoc
Copy link
Author

ptitdoc commented Apr 25, 2018

Hello. I'm still trying to fix the problem discussed in #36796

The bug I face is related to usage of mine.get inside the pillar itself, not specifically about runner functions.
I'm not sure about @thatch45 comment, but before publishing a new PR, here is my new proposal:

            popts = {}
            # Master centric operations such as mine.get must have master option loaded.
            # The pillar must then be compiled by passing master opts found in opts_pkg['__master_opts__']
            # which causes the pillar renderer to loose track of salt master options
            #
            # Depending on popts merge order, it will overwrite some options found in opts_pkg['__master_opts__']
            master_centric_funcs = [
              "pillar.items",
              "mine.get"
            ]
            popts.update(opts_pkg)
            # Pillar compilation is a master centric operation.
            # Master options take precedence during Pillar compilation
            popts.update(opts_pkg['__master_opts__'])

            pillar = salt.pillar.Pillar(
                    popts,
                    opts_pkg['grains'],
                    opts_pkg['id'],
                    opts_pkg.get('environment', 'base')
                    )
            pillar_dirs = {}
            pillar_data = pillar.compile_pillar(pillar_dirs=pillar_dirs)

            # Once pillar has been compiled, restore priority of minion opts
            if self.fun not in master_centric_funcs:
                log.info(self.fun+" is a minion centric function")
                popts.update(opts_pkg)
            else:
                log.info(self.fun+" is a master centric function")

thatch45 pushed a commit that referenced this pull request Dec 14, 2018
…e.get in salt-ssh pillar)

This commit fixe a long standing issue: #36796

A first attempt to fix it is present in PR #41025
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.

3 participants