Skip to content

Commit

Permalink
Merge pull request #390 from DataDog/quentin/implement-retries
Browse files Browse the repository at this point in the history
Add attributes for package download retries options
  • Loading branch information
degemer authored Jan 11, 2017
2 parents a723e2f + d40aefe commit 2a7e914
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@
# Allow override with `upgrade` to get latest (Linux only)
default['datadog']['agent_package_action'] = 'install'

# Agent package options
# retries and retry_delay for package download/install
default['datadog']['agent_package_retries'] = nil
default['datadog']['agent_package_retry_delay'] = nil

# Allow downgrades of the agent (Linux only)
# Note: on apt-based platforms, this will use the `--force-yes` option on the apt-get command. Use with caution.
default['datadog']['agent_allow_downgrade'] = false
Expand Down
6 changes: 6 additions & 0 deletions recipes/_install-linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,23 @@
only_if 'rpm -q datadog-agent-base' if %w(rhel fedora).include?(node['platform_family'])
not_if 'apt-cache policy datadog-agent-base | grep "Installed: (none)"' if node['platform_family'] == 'debian'
end
package_retries = node['datadog']['agent_package_retries']
package_retry_delay = node['datadog']['agent_package_retry_delay']
# Install the regular package
case node['platform_family']
when 'debian'
apt_package 'datadog-agent' do
version dd_agent_version
retries package_retries unless package_retries.nil?
retry_delay package_retry_delay unless package_retry_delay.nil?
action node['datadog']['agent_package_action'] # default is :install
options '--force-yes' if node['datadog']['agent_allow_downgrade']
end
when 'rhel', 'fedora'
yum_package 'datadog-agent' do
version dd_agent_version
retries package_retries unless package_retries.nil?
retry_delay package_retry_delay unless package_retry_delay.nil?
action node['datadog']['agent_package_action'] # default is :install
allow_downgrade node['datadog']['agent_allow_downgrade']
end
Expand Down
5 changes: 5 additions & 0 deletions recipes/_install-windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@
dd_agent_msi = dd_agent_version ? "ddagent-cli-#{dd_agent_version}.msi" : 'ddagent-cli.msi'
temp_file = ::File.join(Chef::Config[:file_cache_path], 'ddagent-cli.msi')

package_retries = node['datadog']['agent_package_retries']
package_retry_delay = node['datadog']['agent_package_retry_delay']

# Download the installer to a temp location
remote_file temp_file do
source node['datadog']['windows_agent_url'] + dd_agent_msi
checksum node['datadog']['windows_agent_checksum'] if node['datadog']['windows_agent_checksum']
retries package_retries unless package_retries.nil?
retry_delay package_retry_delay unless package_retry_delay.nil?
# As of v1.37, the windows cookbook doesn't upgrade the package if a newer version is downloaded
# As a workaround uninstall the package first if a new MSI is downloaded
notifies :remove, 'windows_package[Datadog Agent]', :immediately
Expand Down

0 comments on commit 2a7e914

Please sign in to comment.