-
Notifications
You must be signed in to change notification settings - Fork 283
W/A hardcoding of debian alternatives priority #177
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
W/A hardcoding of debian alternatives priority #177
Conversation
Would anyone be able to review? |
I don't think debian alternatives makes sense on os_family other than Debian so I'm not sure the conditional is right. |
I think
|
BTW, this PR does not add alternatives feature, just removes a hardcoding of 30 priority. There is a pre-existing check for os_family which do not support 'debian alternatives'.
|
Gentoo has eselect which is somewhat similar but has its own module https://docs.saltstack.com/en/latest/ref/states/all/salt.states.eselect.html. Not sure alternatives would work there. |
Good point @EvaSDK Could you raise issue? BTW, such problems exist as legacy technical debt. |
Hey @EvaSDK I updated commit for your comments. Was thinking this PR assists future eselect support because pillar is reusable for that feature. Probaby eselect has priorities too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of this PR. Having configurable priority for alternatives is a neat feature.
Let's make an implementation more robust. I have few concerns, let's address them one by one as usual.
postgres/client.sls
Outdated
{%- if 'bin_dir' in postgres %} | ||
{% if postgres.linux.altpriority|int > 0 %} | ||
{% if grains.os_family not in ('Arch', 'Gentoo', 'MacOS', 'Windows',) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to hard-code the list of distros in the state.
The top-level if
statement checks if bin_dir
parameter has been defined. And it is explicitly defined only for RedHat in osmap.yaml
for now. It does not exist for any other system.
Same applies to the server
state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats correct. The Jinja is unnecessary here. done.
postgres/client.sls
Outdated
{%- if 'bin_dir' in postgres %} | ||
{% if postgres.linux.altpriority|int > 0 %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first, you don't need to introduce lower level if
statement, it's better to collapse two statements into one simply using and
operator. It reduces amount of changes, unnecessary indentations and makes it more readable overall.
At second, no need to use int
filter here. You could just test with implicit Boolean comparison:
{%- if 'bin_dir' in postgres and
postgres.linux.altpriority %}
This would negate the check if postgres.linux.altpriority
would be 0
, ''
,false
or none
. And that looks better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice suggestion. This is all done.
postgres/client.sls
Outdated
|
||
{{ bin }}: | ||
alternatives.install: | ||
- link: {{ salt['file.join']('/usr/bin', bin) }} | ||
- path: {{ path }} | ||
- priority: 30 | ||
- priority: {{ postgres.linux.altpriority|int }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As well, the int
filter is unnecessary. YAML renderer does not care about Jinja internal data type.
postgres/defaults.yaml
Outdated
|
||
linux: | ||
#Alternatives system are disabled by a 'altpriority=0' pillar. | ||
altpriority: 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since for now the formula is able to provision the alternatives only for RedHat systems when PG comes from upstream repo, I think the default value across all supported distros must be empty:
linux:
# Alternatives are applicable only for some OS
altpriority:
Please set actual value in osmap.yaml
file near bin_dir
and *_bins
parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. I tested this on CentOS and Ubuntu and it works like a charm.
Thanks for you contribution @noelmcloughlin
The current hardcoding of '
postgres.alternatives.install.priority=30
', breaks formula reruns.- - priority: 30
This PR is a workaround solution, by exposing the value as a configurable pillar.
+ - priority: {{ postgres.linux.altpriority|int }}
Implementation decisions