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

ssh-client: fix merge order of options in run_wfunc (fix usage of mine.get in pillar) #50489

Merged
merged 4 commits into from
Dec 14, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion salt/client/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,22 @@ def run_wfunc(self):
opts_pkg['grains'][grain] = self.target['grains'][grain]

popts = {}
popts.update(opts_pkg['__master_opts__'])
popts.update(opts_pkg)

# 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"
]

# Pillar compilation is a master centric operation.
# Master options take precedence during Pillar compilation
popts.update(opts_pkg['__master_opts__'])
cachedout marked this conversation as resolved.
Show resolved Hide resolved

pillar = salt.pillar.Pillar(
popts,
opts_pkg['grains'],
Expand All @@ -1085,6 +1099,13 @@ def run_wfunc(self):
)
pillar_data = pillar.compile_pillar()

# Once pillar has been compiled, restore priority of minion opts
if self.fun not in master_centric_funcs:
log.debug(self.fun+" is a minion centric function")
cachedout marked this conversation as resolved.
Show resolved Hide resolved
popts.update(opts_pkg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cachedout I am still wondering if we need that popts.update(opts_pkg) first time. This one is a second.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it do any harm though?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine and it makes sense.

else:
log.debug(self.fun+" is a master centric function")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging should be fixed here:

log.debug('%s is a minion function', self.fun)


# TODO: cache minion opts in datap in master.py
data = {'opts': opts_pkg,
'grains': opts_pkg['grains'],
Expand Down