-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Call zypper refresh after adding/modifying a repository #33581
Conversation
Please do not review this yet because I just noticed that I need to add more things. |
Calling `zypper --gpg-auto-import-keys refresh` is required after adding/modifying a repository because `--gpg-auto-import-keys` doesn't do anything when called with `zypper ar` or `zypper mr`. Without calling `zypper --gpg-auto-import-keys refresh` here, calling `zypper ref` after adding/removing would still ask for accepting/rejecting the gpg key.
I think it's ready for review now (if all the tests pass, of course). @isbm maybe you want to take a look as well |
@isbm Please let me know once you've had a chance to look this over and then I'll review it. Thanks. |
|
||
if cmd_opt: | ||
cmd_opt = global_cmd_opt + ['mr'] + cmd_opt + [repo] | ||
__zypper__.refreshable.xml.call(*cmd_opt) | ||
|
||
# If repo nor added neither modified, error should be thrown | ||
if not added and not cmd_opt: | ||
if not added and not cmd_opt and not trigger_refresh: |
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 not forge such deranged shatter with unnecessary trigger_refresh
, but would just:
if kwargs.get('gpgautoimport'):
if added:
refresh_opts = global_cmd_opt ...
else:
if not added:
raise CommandExecutionError( ....
That would look simple and clear.
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 kwargs.get('gpgautoimport'):
is wrong because we don't want this:
repo_with_gpg:
pkgrepo.managed:
- url: http://some.url/path
- gpgautoimport: any-string-here
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.
@isbm
I do not like the idea of dropping the specialized variable because I want to have a single source of truth.
So I want to check only once this (I don't want to repeat this check again):
if kwargs.get('gpgautoimport') is True:
So I'm relying on that single line for both adding --gpg-auto-import-keys
option to global_cmd_opt
and for calling the refresh and not on two separate conditions.
If we later want to modify the condition, we change it in one single place.
Tested the patch and it worked with - gpgautoimport: True, but did not work with - gpgautoimport: 1. |
@kbaikov I'm not aware of this, so if anyone know anything please speak up. |
@kbaikov It won't work with "1/0", because the code is waiting only for True/False values. |
@isbm we know that. the question is if 1 should work as True |
I was under the impression that all states that accept True will work with 1 also. At least in some other states. |
@kbaikov This is valid to Zypper configs. But this is not a Zypper config. |
@dincamihai Where do you see "1/0" as "True/False" in the link I've sent? Maybe I am missing something. |
@isbm the only thing that prevents |
@dincamihai No, we don't. Let's make it simple, |
@isbm I agree |
@cachedout 👍 😉 |
It seems the computer shutdown while jenkins was running: 12:30:57 Broadcast message from root@ubuntu
12:30:57 (unknown) at 12:30 ...
12:30:57
12:30:57
The system is going down for power off NOW!
12:30:57 [CPU:33.3%|MEM:14.7%|Z:0] ... OK (1.059s)
12:30:57 test_disable_job (unit.utils.schedule_test.ScheduleTestCase)
12:30:58 Connection to 45.33.53.215 closed by remote host.
12:30:58 Connection to 45.33.53.215 closed. Is there a way to trigger a new build? |
Go Go Jenkins! |
What does this PR do?
completes this previous PR #33432
and it attempts to fix this issue #27155
What issues does this PR fix or reference?
In my previous attempt to fix this I was tricked by zypper's caching mechanism which saves the gpg key once accepted and it made me believe that just fixing the
--gpg-auto-import-keys
position fixes the issue.I talked today with the maintainer of 'zypper' and it seems that an additional call like this
is necessary after adding the repository.
At the moment, this is the only way to prevent subsequent
zypper refresh
from asking for confirmation of the gpg key.I didn't revert the previous commit introduced with #33432 because it still fixes the related issue with using
--gpg-auto-import-keys
in the wrong position when calling zypper.Tests written?
Yes.
Meanwhile I learned more about zypper and modules/zypper.py::mod_repo so I added more tests to capture the behavior of mod_repo when passing different parameters to it and to make sure the repository is refreshed only when specifically requested in the sls file with gpgautoimport: True
Possible scenarios:
url only
url and refresh
zypper refresh
zypper refresh
url and gpgautoimport
zypper --gpg-auto-import-keys refresh <repo-name>
but does not call modifyzypper --gpg-auto-import-keys refresh <repo-name>
on the existing repositoryurl, refresh and gpgautoimport
zypper --gpg-auto-import-keys refresh <repo-name>