helm_upgrade_logs 0.3.1 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b0bd4dec8d15bd330ceb45ba82dc81e0a5ca0301c8032037462bd532ed6f75a
4
- data.tar.gz: d4bd99f9a4d04e25b8f34089169f3355ac43d75081438aa3d8ed6854b0f787f6
3
+ metadata.gz: ff847ee96c1dbced9f3dbd122b6245f695fe599462d7e1899d1dd09e483051cf
4
+ data.tar.gz: a3b10b6e66cfbb71ddeb5490f9073fd868868cf9b0afb3e35c620f01ee17e6ad
5
5
  SHA512:
6
- metadata.gz: c097c2af0698ad0c844c97c78f94498edafa94f66213d782a9fa9b5dc959cc6a0f9bf3ae11b39ce70860b7e91de92e00d4da6d0cd07b361145b4c6d04f118115
7
- data.tar.gz: a8e3188650ec71f1a8de1c44c2f6105d02c09247e18feebbd2f625b898a9cc983f92c4eab9e0dec08d7daabd4e1298f720fc901a985be65658f274e5a8764c97
6
+ metadata.gz: adb0f2c697a023259f264cb6af3580a63f44448b025cb91400a8733b34ed3731e656807f40f52a376ac6688eb0fb287a73ec2b87c4cda23f257bfa30e8e797e4
7
+ data.tar.gz: '09bcd240fd9519e938c1fe0112907e922a57f21d2a67215f1f42270a8f67a6fecc5501cadd3968a07abaf4f2c73e358b77b79e95db976d2e44d132e51ac57ed0'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.3.4]
2
+
3
+ - Only log to folder if `helm_upgrade_logs_error_msg` env variable set
4
+
5
+ ## [0.3.3]
6
+
7
+ - Run force kill on processes to ensure they stop
8
+
9
+ ## [0.3.2]
10
+
11
+ - ADO error and normal error don't need to both be displayed
12
+
1
13
  ## [0.3.1]
2
14
 
3
15
  - Fix LOG folder parsed to check error message
@@ -26,12 +26,12 @@ wait_for_pod_to_log
26
26
  begin
27
27
  Process.waitpid(@helm_pid, Process::WNOHANG)
28
28
  rescue Errno::ECHILD
29
- `kill #{event_pid}`
30
- `kill #{service_pid}`
29
+ Process.kill("KILL", event_pid)
30
+ Process.kill("KILL", service_pid)
31
31
  raise HelmUpgradeLogs::Error, "Failed to find logs before helm finished"
32
32
  end
33
33
 
34
- FileUtils.mkdir_p UPGRADE_LOG_FOLDER
34
+ FileUtils.mkdir_p(UPGRADE_LOG_FOLDER) if ENV["helm_upgrade_logs_error_msg"]
35
35
 
36
36
  while Process.waitpid(@helm_pid, Process::WNOHANG).nil?
37
37
  pods = read_pods - pods_before_upgrade
@@ -46,24 +46,35 @@ while Process.waitpid(@helm_pid, Process::WNOHANG).nil?
46
46
  std_out_pid = Process.spawn(
47
47
  add_ns("kubectl logs #{pod} -f --all-containers --prefix --ignore-errors=true --timestamps=true")
48
48
  )
49
+ @pod_pids["#{pod}_stdout"] = std_out_pid
50
+ next unless ENV["helm_upgrade_logs_error_msg"]
51
+
49
52
  logfile_pid = Process.spawn(
50
53
  add_ns("kubectl logs #{pod} -f --all-containers --prefix --ignore-errors=true --timestamps=true"),
51
54
  out: "#{UPGRADE_LOG_FOLDER}/#{pod.gsub("/", "_")}.log"
52
55
  )
53
- @pod_pids["#{pod}_stdout"] = std_out_pid
54
56
  @pod_pids["#{pod}_fileout"] = logfile_pid
55
57
  end
56
58
  end
57
59
  sleep 1
58
60
  end
61
+ puts "[INFO] Cleaning up loggers after helm upgrade"
59
62
  helm_status = $CHILD_STATUS.exitstatus
60
- `kill #{event_pid}`
61
- `kill #{service_pid}`
62
- puts @pod_pids if ENV["helm_upgrade_logs_debug"] == "true"
63
+ Process.kill("KILL", event_pid)
64
+ Process.wait event_pid
65
+ Process.kill("KILL", service_pid)
66
+ Process.wait service_pid
67
+
68
+ if ENV["helm_upgrade_logs_debug"] == "true"
69
+ puts "[INFO] Log processes"
70
+ puts @pod_pids
71
+ end
63
72
  @pod_pids.each do |_pod, pid|
64
73
  puts "Terminating #{_pod} #{pid}" if ENV["helm_upgrade_logs_debug"] == "true"
65
- `kill #{pid}`
74
+ Process.kill("KILL", pid)
75
+ Process.wait pid
66
76
  end
77
+ puts `ps` if ENV["helm_upgrade_logs_debug"] == "true"
67
78
 
68
79
  if ENV["helm_upgrade_logs_error_msg"]
69
80
  pod_logs_files = Dir.glob("#{UPGRADE_LOG_FOLDER}/*.log")
@@ -74,8 +85,11 @@ if ENV["helm_upgrade_logs_error_msg"]
74
85
  next unless line.include?(ENV["helm_upgrade_logs_error_msg"])
75
86
 
76
87
  msg = "Helm install error: #{line} from #{log_file} (Line #{index + 1})"
77
- puts "[ERROR] #{msg}"
78
- puts "##vso[task.logissue type=error] #{msg}" if ENV["helm_upgrade_logs_ado_error"] == "true"
88
+ if ENV["helm_upgrade_logs_ado_error"] == "true"
89
+ puts "##vso[task.logissue type=error] #{msg}"
90
+ else
91
+ puts "[ERROR] #{msg}"
92
+ end
79
93
  end
80
94
  end
81
95
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module HelmUpgradeLogs
4
4
  # @return [String] Version of helm upgrade logs
5
- VERSION = "0.3.1"
5
+ VERSION = "0.3.4"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helm_upgrade_logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-29 00:00:00.000000000 Z
11
+ date: 2022-06-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Basic wrapper around helm and kubectl to allow easy debugging of a helm
14
14
  release. All arguments after a usual helm upgrade are used as normal