diff options
author | Davi Arnaut <davi@verdesmares.com> | 2022-12-13 12:21:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-13 15:21:02 -0500 |
commit | 9b1ef8c55c33e4200523b53d997b989dbfdef2aa (patch) | |
tree | 394d53a6424d47cd42a5648a7ebd86c288be75f6 /lib | |
parent | 62a9952f14b049b6af15efcb0789eeb15bb6455c (diff) | |
download | chef-9b1ef8c55c33e4200523b53d997b989dbfdef2aa.tar.gz |
Fix indentation of condition for disabling repos (#13327)
* Fix indentation of condition for disabling repos
The helper was only disabling repos if the disable action appeared
last in the repos array. This was also hiding a problem where the
helper failed to re-enable repos when all repos are disabled using
a wildcard (e.g. "*").
Signed-off-by: Davi Arnaut <davi@verdesmares.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/package/yum/yum_helper.py | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/lib/chef/provider/package/yum/yum_helper.py b/lib/chef/provider/package/yum/yum_helper.py index 4dfe0cb24b..e3718f994d 100644 --- a/lib/chef/provider/package/yum/yum_helper.py +++ b/lib/chef/provider/package/yum/yum_helper.py @@ -53,16 +53,14 @@ def install_only_packages(base, name): outpipe.flush() def query(base, command): - enabled_repos = base.repos.listEnabled() - # Handle any repocontrols passed in with our options if 'repos' in command: for repo in command['repos']: if 'enable' in repo: base.repos.enableRepo(repo['enable']) - if 'disable' in repo: - base.repos.disableRepo(repo['disable']) + if 'disable' in repo: + base.repos.disableRepo(repo['disable']) args = { 'name': command['provides'] } do_nevra = False @@ -123,16 +121,6 @@ def query(base, command): outpipe.write("%(n)s %(e)s:%(v)s-%(r)s %(a)s\n" % { 'n': pkg.name, 'e': pkg.epoch, 'v': pkg.version, 'r': pkg.release, 'a': pkg.arch }) outpipe.flush() - # Reset any repos we were passed in enablerepo/disablerepo to the original state in enabled_repos - if 'repos' in command: - for repo in command['repos']: - if 'enable' in repo: - if base.repos.getRepo(repo['enable']) not in enabled_repos: - base.repos.disableRepo(repo['enable']) - if 'disable' in repo: - if base.repos.getRepo(repo['disable']) in enabled_repos: - base.repos.enableRepo(repo['disable']) - # the design of this helper is that it should try to be 'brittle' and fail hard and exit in order # to keep process tables clean. additional error handling should probably be added to the retry loop # on the ruby side. |