summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavi Arnaut <davi@verdesmares.com>2022-12-13 12:21:02 -0800
committerNeha Pansare <neha.pansare@progress.com>2023-02-01 17:56:59 +0530
commit59690e215924b9dd5eacc471eb46bb202f734ab3 (patch)
tree16ccd45f0007d948cfbb062dfef0f340a6441b89
parent30599c7b2449dee43d8e9938c5bb3bd89c9dda26 (diff)
downloadchef-59690e215924b9dd5eacc471eb46bb202f734ab3.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> * Update yum_package functional spec syntax per chef16 * Fix typo * Shorten yumprepo-data spec asset filenames to fixe windows plan throwing 'file not found' errors when installing built chef gem Signed-off-by: Neha Pansare <neha.pansare@progress.com> Update habitat plan to remove 5 attempts when installing gems, which just increases build time and prevents from seeing error sooner. If it didnot get installed after 2 attempts, no need to try 5 times Signed-off-by: Neha Pansare <neha.pansare@progress.com>
-rw-r--r--habitat/plan.ps112
-rw-r--r--lib/chef/provider/package/yum/yum_helper.py10
-rw-r--r--spec/functional/assets/yumrepo-empty/repodata/01a3b-filelists.sqlite.bz2bin0 -> 586 bytes
-rw-r--r--spec/functional/assets/yumrepo-empty/repodata/401dc-filelists.xml.gzbin0 -> 123 bytes
-rw-r--r--spec/functional/assets/yumrepo-empty/repodata/5dc1e-primary.sqlite.bz2bin0 -> 1131 bytes
-rw-r--r--spec/functional/assets/yumrepo-empty/repodata/6bf96-other.xml.gzbin0 -> 123 bytes
-rw-r--r--spec/functional/assets/yumrepo-empty/repodata/7c365-other.sqlite.bz2bin0 -> 575 bytes
-rw-r--r--spec/functional/assets/yumrepo-empty/repodata/dabe2-primary.xml.gzbin0 -> 134 bytes
-rw-r--r--spec/functional/assets/yumrepo-empty/repodata/repomd.xml55
-rw-r--r--spec/functional/resource/yum_package_spec.rb12
10 files changed, 73 insertions, 16 deletions
diff --git a/habitat/plan.ps1 b/habitat/plan.ps1
index 262c0613da..e7f62facc1 100644
--- a/habitat/plan.ps1
+++ b/habitat/plan.ps1
@@ -104,12 +104,12 @@ function Invoke-Build {
}
Write-BuildLine " ** Running the chef project's 'rake install' to install the path-based gems so they look like any other installed gem."
$install_attempt = 0
- do {
- Start-Sleep -Seconds 5
- $install_attempt++
- Write-BuildLine "Install attempt $install_attempt"
- bundle exec rake install:local --trace=stdout
- } while ((-not $?) -and ($install_attempt -lt 5))
+ bundle exec rake install --trace=stdout # this needs to be 'bundle exec'd because a Rakefile makes reference to Bundler
+ if (-not $?) {
+ Write-Warning " -- That didn't work. Let's try again."
+ bundle exec rake install --trace=stdout # this needs to be 'bundle exec'd because a Rakefile makes reference to Bundler
+ if (-not $?) { throw "unable to install the gems that live in directories within this repo" }
+ }
} finally {
Pop-Location
diff --git a/lib/chef/provider/package/yum/yum_helper.py b/lib/chef/provider/package/yum/yum_helper.py
index 465dceab18..76b169716e 100644
--- a/lib/chef/provider/package/yum/yum_helper.py
+++ b/lib/chef/provider/package/yum/yum_helper.py
@@ -155,16 +155,6 @@ def query(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.
diff --git a/spec/functional/assets/yumrepo-empty/repodata/01a3b-filelists.sqlite.bz2 b/spec/functional/assets/yumrepo-empty/repodata/01a3b-filelists.sqlite.bz2
new file mode 100644
index 0000000000..edcae3c3f9
--- /dev/null
+++ b/spec/functional/assets/yumrepo-empty/repodata/01a3b-filelists.sqlite.bz2
Binary files differ
diff --git a/spec/functional/assets/yumrepo-empty/repodata/401dc-filelists.xml.gz b/spec/functional/assets/yumrepo-empty/repodata/401dc-filelists.xml.gz
new file mode 100644
index 0000000000..995719dbc2
--- /dev/null
+++ b/spec/functional/assets/yumrepo-empty/repodata/401dc-filelists.xml.gz
Binary files differ
diff --git a/spec/functional/assets/yumrepo-empty/repodata/5dc1e-primary.sqlite.bz2 b/spec/functional/assets/yumrepo-empty/repodata/5dc1e-primary.sqlite.bz2
new file mode 100644
index 0000000000..251c6599ee
--- /dev/null
+++ b/spec/functional/assets/yumrepo-empty/repodata/5dc1e-primary.sqlite.bz2
Binary files differ
diff --git a/spec/functional/assets/yumrepo-empty/repodata/6bf96-other.xml.gz b/spec/functional/assets/yumrepo-empty/repodata/6bf96-other.xml.gz
new file mode 100644
index 0000000000..d44692a8d7
--- /dev/null
+++ b/spec/functional/assets/yumrepo-empty/repodata/6bf96-other.xml.gz
Binary files differ
diff --git a/spec/functional/assets/yumrepo-empty/repodata/7c365-other.sqlite.bz2 b/spec/functional/assets/yumrepo-empty/repodata/7c365-other.sqlite.bz2
new file mode 100644
index 0000000000..7af62d2fbc
--- /dev/null
+++ b/spec/functional/assets/yumrepo-empty/repodata/7c365-other.sqlite.bz2
Binary files differ
diff --git a/spec/functional/assets/yumrepo-empty/repodata/dabe2-primary.xml.gz b/spec/functional/assets/yumrepo-empty/repodata/dabe2-primary.xml.gz
new file mode 100644
index 0000000000..2e5f2cf57e
--- /dev/null
+++ b/spec/functional/assets/yumrepo-empty/repodata/dabe2-primary.xml.gz
Binary files differ
diff --git a/spec/functional/assets/yumrepo-empty/repodata/repomd.xml b/spec/functional/assets/yumrepo-empty/repodata/repomd.xml
new file mode 100644
index 0000000000..fdb2b3ed41
--- /dev/null
+++ b/spec/functional/assets/yumrepo-empty/repodata/repomd.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
+ <revision>1667508211</revision>
+<data type="filelists">
+ <checksum type="sha256">401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93</checksum>
+ <open-checksum type="sha256">bf9808b81cb2dbc54b4b8e35adc584ddcaa73bd81f7088d73bf7dbbada961310</open-checksum>
+ <location href="repodata/401dc-filelists.xml.gz"/>
+ <timestamp>1667508211</timestamp>
+ <size>123</size>
+ <open-size>125</open-size>
+</data>
+<data type="primary">
+ <checksum type="sha256">dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9</checksum>
+ <open-checksum type="sha256">e1e2ffd2fb1ee76f87b70750d00ca5677a252b397ab6c2389137a0c33e7b359f</open-checksum>
+ <location href="repodata/dabe2-primary.xml.gz"/>
+ <timestamp>1667508211</timestamp>
+ <size>134</size>
+ <open-size>167</open-size>
+</data>
+<data type="primary_db">
+ <checksum type="sha256">5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945</checksum>
+ <open-checksum type="sha256">f0d550414e8f2e960e82e704549364299ca9e3e8664ad4faffd208262c3b6d12</open-checksum>
+ <location href="repodata/5dc1e-primary.sqlite.bz2"/>
+ <timestamp>1667508211</timestamp>
+ <database_version>10</database_version>
+ <size>1131</size>
+ <open-size>21504</open-size>
+</data>
+<data type="other_db">
+ <checksum type="sha256">7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4</checksum>
+ <open-checksum type="sha256">4de0fe7c5dd2674849a7c63c326e42f33af0a0f46219bc6dd59f51dfa2ac8c68</open-checksum>
+ <location href="repodata/7c365-other.sqlite.bz2"/>
+ <timestamp>1667508211</timestamp>
+ <database_version>10</database_version>
+ <size>575</size>
+ <open-size>6144</open-size>
+</data>
+<data type="other">
+ <checksum type="sha256">6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670</checksum>
+ <open-checksum type="sha256">e0ed5e0054194df036cf09c1a911e15bf2a4e7f26f2a788b6f47d53e80717ccc</open-checksum>
+ <location href="repodata/6bf96-other.xml.gz"/>
+ <timestamp>1667508211</timestamp>
+ <size>123</size>
+ <open-size>121</open-size>
+</data>
+<data type="filelists_db">
+ <checksum type="sha256">01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523</checksum>
+ <open-checksum type="sha256">c4211f57bdcbb142c9f93a6d32401539f775eb6a670ab7a423e13f435ce94689</open-checksum>
+ <location href="repodata/01a3b-filelists.sqlite.bz2"/>
+ <timestamp>1667508211</timestamp>
+ <database_version>10</database_version>
+ <size>586</size>
+ <open-size>7168</open-size>
+</data>
+</repomd>
diff --git a/spec/functional/resource/yum_package_spec.rb b/spec/functional/resource/yum_package_spec.rb
index 5f902cff17..02608e9e00 100644
--- a/spec/functional/resource/yum_package_spec.rb
+++ b/spec/functional/resource/yum_package_spec.rb
@@ -50,6 +50,12 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo
enable=1
gpgcheck=0
+ [chef-yum-empty]
+ name=Chef DNF spec empty repo
+ baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo-empty
+ enable=1
+ gpgcheck=0
+
EOF
end
shell_out!("rpm -qa --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' | grep chef_rpm | xargs -r rpm -e")
@@ -633,6 +639,12 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
end
+ it "should work to disable a repo" do
+ flush_cache
+ yum_package.options("--disablerepo=chef-yum-localtesting --enablerepo=chef-yum-empty")
+ expect { yum_package.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
+ end
+
it "when an idempotent install action is run, does not leave repos disabled" do
flush_cache
# this is a bit tricky -- we need this action to be idempotent, so that it doesn't recycle any