helm_upgrade_logs 0.3.0 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88dd5b1832da012298b7c2f8ce393bcc78df7b20014bc9514b37d70bb3c885fe
4
- data.tar.gz: 4dd1b474d21f68ac9849d2523358e4550d518d81c0155d187cfe3b524b3236e7
3
+ metadata.gz: c152efac3e0107333fb8a9101cb06f9eede40e5bfeb747b3815e3aca8a0d02b7
4
+ data.tar.gz: c6ef07655615775aebbe6bb347873905b9d5a43dc5a1ef3fcbfbfeaeb28c2d77
5
5
  SHA512:
6
- metadata.gz: b6a0432ce7aee7a1a3b924e4599a0764674fb8ca3c61cab4862e51fefa57fe706dffeb15b3d9d134c22652fc65fbb5ccc4ae1e7383f78f65176bba50f93851b0
7
- data.tar.gz: 8ddfd48e160614b8d7e3b03c6eca7699ab05b96f2ad3ecdcaa00f71981bcf5a040796d2fc689503496c3906fc9dc6a6a1a03a652e63f2190024f8bebe7e12458
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
@@ -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
- `kill #{event_pid}`
29
- `kill #{service_pid}`
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 "helm_upgrade_logs"
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: "helm_upgrade_logs/#{pod.gsub("/", "_")}.log"
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
- `kill #{event_pid}`
60
- `kill #{service_pid}`
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
- `kill #{pid}`
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("helm_logs/*.log")
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
- puts "[ERROR] #{msg}"
76
- puts "##vso[task.logissue type=error] #{msg}" if ENV["helm_upgrade_logs_ado_error"] == "true"
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module HelmUpgradeLogs
4
4
  # @return [String] Version of helm upgrade logs
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.3"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helm_upgrade_logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt