Skip to content

Commit bb7e93a

Browse files
committed
(PA-7407) Add more detailed error information when upgrade fails
Previously when puppet_agent fails to upgrade, only the error is given. This commit updates install_puppet.ps1 and puppet_agent_upgrade_error provider to collect & provide more information about the error. Specifically, the last 10 lines of output from the installer.log and any other error(s) that caused the failure are now included in the puppet_agent_upgrade_failure.log and are output by the puppet_agent_upgrade_error type and provider.
1 parent 8d062b8 commit bb7e93a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

files/install_puppet.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ try {
347347
Reset-PuppetresDLL $temp_puppetres
348348
}
349349
"$_" | Out-File -FilePath (Join-Path -Path $state_dir -ChildPath 'puppet_agent_upgrade_failure.log')
350+
# Put relevant errors in puppet_agent_upgrade_failure.log
351+
Get-Content -Path $logfile | Select-String -Pattern "^Error.*$|-- Error" | Add-Content -Path (Join-Path -Path $state_dir -ChildPath 'puppet_agent_upgrade_failure.log')
352+
Get-Content -Path $Logfile -Tail 10 | Add-Content -Path (Join-Path -Path $state_dir -ChildPath 'puppet_agent_upgrade_failure.log')
350353
} finally {
351354
Reset-PuppetServices $services_before
352355
Unlock-Installation $install_pid_lock

lib/puppet/provider/puppet_agent_upgrade_error/puppet_agent_upgrade_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def read_content_and_delete_file(filename)
1919
# In this scenario we need to open the file in binmode and read each line
2020
# individually, then encode the result back to UTF-8 so we can sub out both
2121
# the UTF-16 header \uFEFF and the \r\n line carriages.
22-
File.open(logfile, 'rb:UTF-16LE') { |file| file.readlines }[0].encode!('UTF-8').delete("\uFEFF").delete("\r")
22+
File.open(logfile, 'rb:UTF-16LE') { |file| file.read.encode!('UTF-8').delete("\uFEFF").delete("\r") }
2323
else
2424
File.read(logfile)
2525
end

0 commit comments

Comments
 (0)