{"action":"created","issue":{"url":"https://api.github.com/repos/chef/chef/issues/7540","repository_url":"https://api.github.com/repos/chef/chef","labels_url":"https://api.github.com/repos/chef/chef/issues/7540/labels{/name}","comments_url":"https://api.github.com/repos/chef/chef/issues/7540/comments","events_url":"https://api.github.com/repos/chef/chef/issues/7540/events","html_url":"https://github.com/chef/chef/issues/7540","id":349968803,"node_id":"MDU6SXNzdWUzNDk5Njg4MDM=","number":7540,"title":"chef-client yum_package install fails with \"No candidate version available for ...\" error","user":{"login":"cosinusoidally","id":905043,"node_id":"MDQ6VXNlcjkwNTA0Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/905043?v=4","gravatar_id":"","url":"https://api.github.com/users/cosinusoidally","html_url":"https://github.com/cosinusoidally","followers_url":"https://api.github.com/users/cosinusoidally/followers","following_url":"https://api.github.com/users/cosinusoidally/following{/other_user}","gists_url":"https://api.github.com/users/cosinusoidally/gists{/gist_id}","starred_url":"https://api.github.com/users/cosinusoidally/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cosinusoidally/subscriptions","organizations_url":"https://api.github.com/users/cosinusoidally/orgs","repos_url":"https://api.github.com/users/cosinusoidally/repos","events_url":"https://api.github.com/users/cosinusoidally/events{/privacy}","received_events_url":"https://api.github.com/users/cosinusoidally/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-13T10:15:50Z","updated_at":"2018-08-14T16:46:07Z","closed_at":null,"author_association":"NONE","body":"## Description\r\n\r\nOn CentOS 6 a `chef-client` run using the `yum_package` provider to install a package will fail with a `No candidate version available for ...` error under fairly easy to trigger circumstances (see details under replication case)\r\n\r\nThis seems to be CentOS 6 specific. Chef 14 on CentOS 7 does not seem to have this bug. Chef 12 is unaffected.\r\n\r\n## Chef Version\r\n\r\nchef-client: all versions of Chef 14 above 14.0.136 (when the refactor of yum_package landed). I have tested Chef 14.0.136 and it is unaffected by this issue. Chef 14.0.139 is affected. I've also tested several later versions including the current \"Current\" (14.4.18) and the current Stable (14.3.37).  All newer versions since the yum refactor seem to be affected. Chef 12 is unaffected.\r\n\r\n## Platform Version\r\n\r\nCentOS 6.10 x86_64\r\n\r\n## Replication Case\r\n\r\n```\r\npackage 'foo' do\r\n    action [:remove]\r\nend\r\n\r\npackage 'bar' do\r\n    options \"--enablerepo=blah\"\r\n    action [:install]\r\nend\r\n```\r\nWhere `bar` is in repo `blah` and `blah.repo` has `enabled=0`. If `foo` is *not* already installed when the chef run occurs then the installation of `bar` will fail with a `No candidate version available for bar` error.\r\n\r\nThis pattern is fairly common in our cookbooks, ie `foo` conflicts with with `bar` so the recipe will ensure `foo` is uninstalled before attempting to install `bar`\r\n\r\nI had a dig through the Chef code. It does seem that there may be a bug in the yum Python API in CentOS 6. `yum_helper.py` appears to successfully enable the `blah` repo, but when it then calls `returnPackages` nothing comes back from the yum API for the requested package. The reason it works if `foo` is installed is that when Chef removes a package it restarts `yum_helper.py` (see here: https://github.com/chef/chef/blob/425d599c90b7a07ac903502b46fd3045cc41ae98/lib/chef/provider/package/yum.rb#L131-L135 by calling `flushcache` ). I think what's happening is that the search to find `foo` is leaving some stray state in `yum_helper.py` . I suppose the fix may be to more aggressively restart yum_helper.py on CentOS 6, but I assume that may affect performance.\r\n\r\n## Client Output\r\n\r\nSome info redacted since this is one of our production cookbooks. Note that this is running inside test kitchen during a kitchen converge\r\n\r\n```\r\n\r\n * yum_package[GeoIP] action install\r\n\r\n           * No candidate version available for GeoIP\r\n\r\n           ================================================================================\r\n\r\n           Error executing action `install` on resource 'yum_package[GeoIP]'\r\n\r\n           ================================================================================\r\n\r\n           Chef::Exceptions::Package\r\n\r\n           -------------------------\r\n\r\n           No candidate version available for GeoIP\r\n\r\n           Resource Declaration:\r\n\r\n           ---------------------\r\n\r\n           # In /tmp/kitchen/cache/cookbooks/***redacted***\r\n\r\n            16: package 'GeoIP' do\r\n\r\n            17:     options \"--enablerepo=***redacted***\"\r\n\r\n            18:     action [:install]\r\n\r\n            19: end\r\n\r\n           Compiled Resource:\r\n\r\n           ------------------\r\n\r\n           # Declared in /tmp/kitchen/cache/cookbooks/***redacted*** `from_file'\r\n\r\n           yum_package(\"GeoIP\") do\r\n\r\n             package_name \"GeoIP\"\r\n\r\n             action [:install]\r\n\r\n             default_guard_interpreter :default\r\n\r\n             declared_type :package\r\n\r\n             cookbook_name \"***redacted***\"\r\n\r\n             recipe_name \"default\"\r\n\r\n             options [\"--enablerepo=***redacted***\"]\r\n\r\n           end\r\n\r\n           System Info:\r\n\r\n           ------------\r\n\r\n           chef_version=14.2.0\r\n\r\n           platform=centos\r\n\r\n           platform_version=6.10\r\n\r\n           ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]\r\n\r\n           program_name=/opt/chef/bin/chef-solo\r\n\r\n           executable=/opt/chef/bin/chef-solo\r\n```\r\n\r\n## Stacktrace\r\n\r\nSee above\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/chef/chef/issues/comments/412938785","html_url":"https://github.com/chef/chef/issues/7540#issuecomment-412938785","issue_url":"https://api.github.com/repos/chef/chef/issues/7540","id":412938785,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjkzODc4NQ==","user":{"login":"WheresAlice","id":84906,"node_id":"MDQ6VXNlcjg0OTA2","avatar_url":"https://avatars3.githubusercontent.com/u/84906?v=4","gravatar_id":"","url":"https://api.github.com/users/WheresAlice","html_url":"https://github.com/WheresAlice","followers_url":"https://api.github.com/users/WheresAlice/followers","following_url":"https://api.github.com/users/WheresAlice/following{/other_user}","gists_url":"https://api.github.com/users/WheresAlice/gists{/gist_id}","starred_url":"https://api.github.com/users/WheresAlice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WheresAlice/subscriptions","organizations_url":"https://api.github.com/users/WheresAlice/orgs","repos_url":"https://api.github.com/users/WheresAlice/repos","events_url":"https://api.github.com/users/WheresAlice/events{/privacy}","received_events_url":"https://api.github.com/users/WheresAlice/received_events","type":"User","site_admin":false},"created_at":"2018-08-14T16:46:07Z","updated_at":"2018-08-14T16:46:07Z","author_association":"NONE","body":"This seems similar to #7215 , however in that issue it's also affecting CentOS 7 which @cosinusoidally has been unable to reproduce so far."}}
{"actor":{"display_login":"WheresAlice"}}