Skip to content

Commit

Permalink
Specify release but not epoch for RPM packages on Chef < 14 (DataDog#858
Browse files Browse the repository at this point in the history
)

In DataDog#856, we reverted the logic introduced in DataDog#839 when Chef < 14 is used, as the yum logic in Chef < 14 doesn't support the use of epochs.

However, before DataDog#839, the release was added in all cases to the package version. In DataDog#856 we forgot to restore that, which this PR does.
  • Loading branch information
KSerrania authored Aug 19, 2022
1 parent e3616d0 commit 7b75cc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions libraries/recipe_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ def agent_version(node)
dd_agent_version = dd_agent_version[platform_family]
end
if !dd_agent_version.nil? && dd_agent_version.match(/^[0-9]+\.[0-9]+\.[0-9]+((?:~|-)[^0-9\s-]+[^-\s]*)?$/)
# For RHEL-based distros, we can only add epoch and release when running Chef >= 14, as Chef < 14
# has different yum logic that doesn't know how to work with epoch and/or release
# For RHEL-based distros:
# - we can only add epoch and release when running Chef >= 14, as Chef < 14
# has different yum logic that doesn't know how to work with epoch and release
# - for Chef < 14, we only add release
if %w[debian suse].include?(node['platform_family']) ||
(%w[amazon fedora rhel].include?(node['platform_family']) && chef_version_ge?(14))
dd_agent_version = '1:' + dd_agent_version + '-1'
elsif %w[amazon fedora rhel].include?(node['platform_family'])
dd_agent_version += '-1'
end
end
dd_agent_version
Expand Down
2 changes: 1 addition & 1 deletion spec/dd-agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ def set_env_var(name, value)
if Chef::Datadog.chef_version_ge? 14
expect(chef_run).to install_dnf_package('datadog-agent').with_version('1:6.16.0-1')
else
expect(chef_run).to install_dnf_package('datadog-agent').with_version('6.16.0')
expect(chef_run).to install_dnf_package('datadog-agent').with_version('6.16.0-1')
end
end
end
Expand Down

0 comments on commit 7b75cc7

Please sign in to comment.