-
Notifications
You must be signed in to change notification settings - Fork 419
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
feat(package): reorg version-locking salt packages #525
Conversation
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.
Looks good as far as I can tell, this is based on my experience with rhel like systems.
@@ -24,6 +29,9 @@ salt-cloud: | |||
{%- if salt_settings.version is defined %} | |||
- version: {{ salt_settings.version }} | |||
{%- endif %} | |||
{%- if salt_settings.pin_version %} | |||
- hold: True | |||
{%- endif %} |
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.
Don't you think you need to also add update_holds: True
here and in other similar places to allow upgrade or downgrade?
update_holds (bool) --
If True, and this function would update the package version, any packages which are being held will be temporarily unheld so that they can be updated. Otherwise, if this function attempts to update a held package, the held package(s) will be skipped and the state will fail. By default, this parameter is set to False.
Supported on YUM/DNF & APT based systems.
Currently you don't provide any way to unhold packages via formula.
Version hold is looks very similar with version pinning but it is not exactly the same thing. If I'm not mistaken
I'm almost certain that is not possible by simple |
@hatifnatt maybe you could explain the difference between "pinning" and "hold"? On the surface, they sound like the same thing... I'm having a hard time finding anything in the official Salt module index specifically about "pinning." |
Regarding
|
#525 (comment)
But can you hold package prior installation? Does hold help you with downgrade? Main reason why I'm using pinning - it helps with downgrade. Also in the formula you only set hold for, let's call it "main" packages i.e. |
@myii can you please help with failing test? I don't think it's related with PR itself but I'm not familiar with all kitchen stuff. |
@hatifnatt I think my question is more along the lines of...should I make this PR a breaking change and replace all the Btw, your point about update_holds was totally spot-on. Thanks for that. |
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.
Addition of hold.sls
is definitely an improvement, otherwise formula can fail on systems where versionlock
plugin is not installed, but in the rest previous version was better and cleaner.
# Pin version provided under 'version' key by using apt-pinning | ||
# available only on Debian family OS-es | ||
pin_version: false |
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 don't see any reason why you need to delete pinning in favor to hold. Both options can coexist without any trouble.
{%- if salt_settings.hold_version is defined %} | ||
- hold: {{ salt_settings.hold_version }} | ||
{%- endif %} | ||
{%- if salt_settings.update_holds is defined %} | ||
- update_holds: {{ salt_settings.update_holds }} | ||
{%- endif %} |
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.
{%- if salt_settings.hold_version is defined %} | |
- hold: {{ salt_settings.hold_version }} | |
{%- endif %} | |
{%- if salt_settings.update_holds is defined %} | |
- update_holds: {{ salt_settings.update_holds }} | |
{%- endif %} | |
- hold: {{ salt_settings.get('hold_version', False) }} | |
- update_holds: {{ salt_settings.get('update_holds', False ) }} |
I would suggest something like this - less Jinja - better readability.
But even better is to preserve defaults in defaults.yaml
and wait for comment about failing pipelines from @myii
@@ -2,7 +2,7 @@ | |||
{%- from tplroot ~ "/map.jinja" import salt_settings with context %} | |||
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} | |||
|
|||
{% if salt_settings.pin_version and salt_settings.version and grains.os_family|lower == 'debian' %} | |||
{% if salt_settings.hold_version is defined and salt_settings.install_packages %} |
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.
And again don't replace pin with hold, just add hold.
{% if salt_settings.hold_version is defined and salt_settings.install_packages %} | ||
include: | ||
- .pin | ||
- .hold | ||
{% endif %} |
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.
And there you are replacing .pin
with .hold
salt-install-hold-plugin: | ||
pkg.installed: | ||
{% if grains.osmajorrelease > 7 %} | ||
- name: python3-dnf-plugin-versionlock | ||
{% else %} | ||
- name: yum-plugin-versionlock | ||
{% endif %} |
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 would suggest to put package name into variable and read it from osfingermap file. osmajorrelease
based condition is only applicable for RedHat derivatives I suppose it will fail for SUSE.
Excellent feedback. Give me a little bit to try to clean this up. |
I think you're right about the legibility and "less Jinja" suggestion when you say I should do this: - hold: {{ salt_settings.get('hold_version', False) }}
- update_holds: {{ salt_settings.get('update_holds', False ) }} But unfortunately, if the necessary yum plugin is not installed, having If you see another cleaner way to do it, I'm all ears. Should we just install the respective versionlock package regardless of any pillar settings in this formula? That seems a little heavy-handed.. |
You can have less Jinja something like this: {% if salt_settings.install_packages and (salt_settings.hold_version or salt_settings.update_holds) %}
include:
- {{ tplroot }}.hold
{% endif %}
...
salt-master:
{% if salt_settings.install_packages %}
pkg.installed:
...
{%- if salt_settings.hold_version or salt_settings.update_holds %}
- hold: {{ salt_settings.get('hold_version', False) }}
- update_holds: {{ salt_settings.get('update_holds', False ) }}
{%- endif %}
- require:
{%- if salt_settings.hold_version or salt_settings.update_holds %}
- sls: {{ tplroot }}.hold
{%- endif %} This way |
Nevermind. This is more trouble than it's worth. |
PR progress checklist (to be filled in by reviewers)
What type of PR is this?
Primary type
[build]
Changes related to the build system[chore]
Changes to the build process or auxiliary tools and libraries such as documentation generation[ci]
Changes to the continuous integration configuration[feat]
A new feature[fix]
A bug fix[perf]
A code change that improves performance[refactor]
A code change that neither fixes a bug nor adds a feature[revert]
A change used to revert a previous commit[style]
Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)Secondary type
[docs]
Documentation changes[test]
Adding missing or correcting existing testsDoes this PR introduce a
BREAKING CHANGE
?Possibly. I'm not 100% sure how pkg.installed's "hold" parameter functions cross-platform. My testing was on an AmazonLinux 2 box, and I don't see anything specific in the integration tests for this particular item..
Related issues and/or pull requests
Describe the changes you're proposing
Add the ability to version-lock the yum packages for Salt, if desired.
Pillar / config required to test the proposed changes
On a RHEL-based system:
Debug log showing how the proposed changes work
Documentation checklist
README
(e.g.Available states
).pillar.example
.Testing checklist
state_top
).Additional context