helm_upgrade_logs 0.3.0 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/exe/helm_upgrade_logs +16 -10
- data/lib/helm_upgrade_logs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c152efac3e0107333fb8a9101cb06f9eede40e5bfeb747b3815e3aca8a0d02b7
|
4
|
+
data.tar.gz: c6ef07655615775aebbe6bb347873905b9d5a43dc5a1ef3fcbfbfeaeb28c2d77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aa9f87875f45d174c337314988546e66d4af1bcb279b471a278eb7d826d4eb21362a9a060466abb7e86e27a9902cb9778593f7102e4fbbd82103a72686e68ed
|
7
|
+
data.tar.gz: 2dc02dc6e520c3997957885f68d180a88889132fbf74e3f4f8f01331b92cf3f6ee382c7e98da87557bde798e2854db7eaa5b28ff25c6670c41a7606fc2b94bdb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## [0.3.3]
|
2
|
+
|
3
|
+
- Run force kill on processes to ensure they stop
|
4
|
+
|
5
|
+
## [0.3.2]
|
6
|
+
|
7
|
+
- ADO error and normal error don't need to both be displayed
|
8
|
+
|
9
|
+
## [0.3.1]
|
10
|
+
|
11
|
+
- Fix LOG folder parsed to check error message
|
12
|
+
|
1
13
|
## [0.3.0]
|
2
14
|
|
3
15
|
- Log output to a file in a folder `helm_upgrade_logs` as well as STDOUT
|
data/exe/helm_upgrade_logs
CHANGED
@@ -5,6 +5,7 @@ require "open3"
|
|
5
5
|
require "fileutils"
|
6
6
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
7
7
|
require "helm_upgrade_logs"
|
8
|
+
UPGRADE_LOG_FOLDER = "helm_upgrade_logs"
|
8
9
|
|
9
10
|
@release_name = ARGV.find { |arg| !arg.start_with?("-") }
|
10
11
|
@namespace = namespace_from_args(ARGV)
|
@@ -25,12 +26,12 @@ wait_for_pod_to_log
|
|
25
26
|
begin
|
26
27
|
Process.waitpid(@helm_pid, Process::WNOHANG)
|
27
28
|
rescue Errno::ECHILD
|
28
|
-
|
29
|
-
|
29
|
+
Process.kill("KILL", event_pid)
|
30
|
+
Process.kill("KILL", service_pid)
|
30
31
|
raise HelmUpgradeLogs::Error, "Failed to find logs before helm finished"
|
31
32
|
end
|
32
33
|
|
33
|
-
FileUtils.mkdir_p
|
34
|
+
FileUtils.mkdir_p UPGRADE_LOG_FOLDER
|
34
35
|
|
35
36
|
while Process.waitpid(@helm_pid, Process::WNOHANG).nil?
|
36
37
|
pods = read_pods - pods_before_upgrade
|
@@ -47,7 +48,7 @@ while Process.waitpid(@helm_pid, Process::WNOHANG).nil?
|
|
47
48
|
)
|
48
49
|
logfile_pid = Process.spawn(
|
49
50
|
add_ns("kubectl logs #{pod} -f --all-containers --prefix --ignore-errors=true --timestamps=true"),
|
50
|
-
out: "
|
51
|
+
out: "#{UPGRADE_LOG_FOLDER}/#{pod.gsub("/", "_")}.log"
|
51
52
|
)
|
52
53
|
@pod_pids["#{pod}_stdout"] = std_out_pid
|
53
54
|
@pod_pids["#{pod}_fileout"] = logfile_pid
|
@@ -55,25 +56,30 @@ while Process.waitpid(@helm_pid, Process::WNOHANG).nil?
|
|
55
56
|
end
|
56
57
|
sleep 1
|
57
58
|
end
|
59
|
+
puts "[INFO] Cleaning up loggers after helm upgrade"
|
58
60
|
helm_status = $CHILD_STATUS.exitstatus
|
59
|
-
|
60
|
-
|
61
|
+
Process.kill("KILL", event_pid)
|
62
|
+
Process.kill("KILL", service_pid)
|
61
63
|
puts @pod_pids if ENV["helm_upgrade_logs_debug"] == "true"
|
62
64
|
@pod_pids.each do |_pod, pid|
|
63
65
|
puts "Terminating #{_pod} #{pid}" if ENV["helm_upgrade_logs_debug"] == "true"
|
64
|
-
|
66
|
+
Process.kill("KILL", pid)
|
65
67
|
end
|
66
68
|
|
67
69
|
if ENV["helm_upgrade_logs_error_msg"]
|
68
|
-
pod_logs_files = Dir.glob("
|
70
|
+
pod_logs_files = Dir.glob("#{UPGRADE_LOG_FOLDER}/*.log")
|
71
|
+
puts "Reading logs from #{pod_logs_files.count} pod logs" if ENV["helm_upgrade_logs_debug"] == "true"
|
69
72
|
pod_logs_files.each do |log_file|
|
70
73
|
lines = File.readlines log_file
|
71
74
|
lines.each_with_index do |line, index|
|
72
75
|
next unless line.include?(ENV["helm_upgrade_logs_error_msg"])
|
73
76
|
|
74
77
|
msg = "Helm install error: #{line} from #{log_file} (Line #{index + 1})"
|
75
|
-
|
76
|
-
|
78
|
+
if ENV["helm_upgrade_logs_ado_error"] == "true"
|
79
|
+
puts "##vso[task.logissue type=error] #{msg}"
|
80
|
+
else
|
81
|
+
puts "[ERROR] #{msg}"
|
82
|
+
end
|
77
83
|
end
|
78
84
|
end
|
79
85
|
end
|