diff --git a/recipes/_install-linux.rb b/recipes/_install-linux.rb index 846835f8..b91876ca 100644 --- a/recipes/_install-linux.rb +++ b/recipes/_install-linux.rb @@ -28,6 +28,17 @@ package_retries = node['datadog']['agent_package_retries'] package_retry_delay = node['datadog']['agent_package_retry_delay'] +# Remove Python bytecode cache dir prior to installing/upgrading Agent (Linux only) +directory '/opt/datadog-agent/python-scripts/__pycache__' do + action :delete + recursive true + ignore_failure true + only_if do + platform_family?('debian', 'rhel', 'fedora', 'amazon', 'suse') && + ![:remove, :purge].include?((package_action.is_a?(Symbol) ? package_action : package_action.to_sym)) + end +end + # Install the regular package case node['platform_family'] when 'debian' diff --git a/test/integration/dd-agent-handler5/serverspec_datadog/dd-agent_spec.rb b/test/integration/dd-agent-handler5/serverspec_datadog/dd-agent_spec.rb index 3ce28a14..179a3814 100644 --- a/test/integration/dd-agent-handler5/serverspec_datadog/dd-agent_spec.rb +++ b/test/integration/dd-agent-handler5/serverspec_datadog/dd-agent_spec.rb @@ -24,9 +24,25 @@ # On Linux kernel >= 5.5, Agent 5 disk check fails because of old psutil version, which doesn't have fix # https://github.com/giampaolo/psutil/commit/2e0952e939d6ab517449314876d8d3488ba5b98b -describe command('/etc/init.d/datadog-agent info | grep -v "API Key is invalid" | grep -v "not sure how to interpret line"'), :if => os[:family] != 'windows' do +describe command('/etc/init.d/datadog-agent info | grep -v "API Key is invalid" | grep -v "not sure how to interpret line" | egrep -v "Unable to validate API Key. Please try again later"'), :if => os[:family] != 'windows' do its(:exit_status) { should eq 0 } its(:stdout) { should contain 'OK' } + + it 'dumps full output for debugging before ERROR check' do + output = subject.stdout + puts "\n" + "="*80 + puts "FULL DATADOG AGENT INFO OUTPUT (#{output.length} chars)" + puts "="*80 + puts output + puts "="*80 + if output.include?('ERROR') + puts "\nERROR LINES FOUND:" + output.lines.each_with_index do |line, idx| + puts "[#{idx + 1}] #{line}" if line.upcase.include?('ERROR') + end + end + end + its(:stdout) { should_not contain 'ERROR' } end