helm_upgrade_logs 0.1.7 → 0.2.2

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: 612089e7637694fdb0bca10be78d1cda044a99c3925a436867f0c7efd7ab5813
4
- data.tar.gz: 0c83667889b979ca3bcd7ccf54d74ffe5c16e750de625977c117cbd53d25b536
3
+ metadata.gz: fa3f3a0b230ebece6f834e3f1d350f7dce7efdc38e9798f6e88e2c2ac2e4ebea
4
+ data.tar.gz: '09b2dc417d34ceada26ea29976dceab275d035c69da9fac86afbf613b2f239b1'
5
5
  SHA512:
6
- metadata.gz: 1edb515198878e0f9602001bc08ba9018d657b4c1efc569a0b2e46c57ba10395a81a578cd0c57ae300ab6aee01d4e2dcd62550c1203cb64cb66cd8de3f7d7d4f
7
- data.tar.gz: 652c953b9d59e33a58d54d880a86be9058822ca286266735016d0a1a8fffa7fc41fc51537aca66db7d24e9531fb47009336c245ed32900caec141164fbc47805
6
+ metadata.gz: 6b079a3c801b1cfc3ed7ebfe43b669e8845cf02bb2980e541e58fe1b049d4138e0cbb120a64099e97335bc95b0b98f2510a934299ff470251ebf56bf247cfbb3
7
+ data.tar.gz: 40d106a0b06352621fc90cfb8653fbc3f279d8676d438eeb592e6fa94a39bc896f8a690df4a6633654d410f9bae5600605790fbcd1bdbf33c95aa114d9403053
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
+ ## [0.2.2] - 2022-04-20
2
+
3
+ - Wait for logs on each pod having a process for logging each pod
4
+
1
5
  ## [0.2.0] - 2022-04-20
2
6
 
7
+ - Monitoring pods don't filter managed by helm as some pods don't have that with selectorLabels
8
+
9
+ ## [0.1.7] - 2022-04-20
10
+
3
11
  - Monitor helm upgrade command and periodically reload getting logs when new pods appear
4
12
 
5
13
  ## [0.1.6] - 2022-04-17
@@ -15,17 +15,28 @@ service_pid = Process.spawn 'kubectl get services --watch-only=true'
15
15
  wait_for_pod_to_log
16
16
 
17
17
  @pods = []
18
+ @pod_pids = {}
18
19
 
19
20
  while Process.waitpid(helm_pid, Process::WNOHANG) == nil do
20
21
  pods = get_pods
21
22
  if pods != @pods
22
23
  @pods = pods
23
24
  puts "[INFO] Pods: #{pods.join(',')}"
24
- puts `kill #{@log_pid}` if @log_pid
25
- @log_pid = Process.spawn "kubectl logs -lapp.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=#{$release_name} -f --all-containers --prefix --ignore-errors=true --max-log-requests=20 --timestamps=true --since=0s"
25
+ # Could change this each to Parallel.each
26
+ @pods.each do |pod|
27
+ if @pod_pids[pod].nil?
28
+ wait_for_specific_pod_to_log pod
29
+ log_pid = Process.spawn "kubectl logs #{pod} -f --all-containers --prefix --ignore-errors=true --timestamps=true"
30
+ @pod_pids[pod] = log_pid
31
+ end
32
+ end
26
33
  end
27
- sleep 2.5
34
+ sleep 1
28
35
  end
29
- puts `kill #{@log_pid}`
30
- puts `kill #{event_pid}`
31
- puts `kill #{service_pid}`
36
+ `kill #{event_pid}`
37
+ `kill #{service_pid}`
38
+ @pod_pids.each do |pod, pid|
39
+ `kill #{pid}`
40
+ end
41
+
42
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HelmUpgradeLogs
4
- VERSION = "0.1.7"
4
+ VERSION = "0.2.2"
5
5
  end
@@ -24,8 +24,21 @@ def wait_for_pod_to_log
24
24
  }
25
25
  end
26
26
 
27
+ def wait_for_specific_pod_to_log(pod_name)
28
+ 30.times {
29
+ sleep 1
30
+ stdout, stderr, _ = Open3.capture3 "kubectl logs #{pod_name}"
31
+ if stderr.empty? && !stdout.strip.empty?
32
+ puts "Pod #{pod_name} with logs found"
33
+ break
34
+ else
35
+ puts "Waiting for pod #{pod_name} logs: #{stderr}"
36
+ end
37
+ }
38
+ end
39
+
27
40
  def get_pods
28
- stdout, stderr, _ = Open3.capture3 "kubectl get pods -lapp.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=#{$release_name} -o name"
41
+ stdout, stderr, _ = Open3.capture3 "kubectl get pods -lapp.kubernetes.io/instance=#{$release_name} -o name"
29
42
  if stderr.empty?
30
43
  stdout.lines.collect { |pod| pod.strip }
31
44
  else
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.1.7
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt