helm_upgrade_logs 0.1.6 → 0.1.7

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: 4122417ed0106e7a563e3a52950a20ad697c0f945ee7a5160754698d1f5edcbc
4
- data.tar.gz: c55b4efa13bba39dbe37ee50c5d443f147dc305060334953c6b1bae505ec14b1
3
+ metadata.gz: 612089e7637694fdb0bca10be78d1cda044a99c3925a436867f0c7efd7ab5813
4
+ data.tar.gz: 0c83667889b979ca3bcd7ccf54d74ffe5c16e750de625977c117cbd53d25b536
5
5
  SHA512:
6
- metadata.gz: bc569a6d7f5c2888e3150d552d1c46b35f29260944c661a6ace0a0f82e0bf299ef3e2f40401a18af2401747af6ee617175e2a6a2f5eae184245e480768f6252c
7
- data.tar.gz: 45f62ed6b1f1abb463bf169800e3f12d0337a7fd61e73c78a7b329f8ea743967bbe9e30fbb89078f6ee5bd6c9bbbd85a4fd9ff79c82101b61d17a3f2a276dc10
6
+ metadata.gz: 1edb515198878e0f9602001bc08ba9018d657b4c1efc569a0b2e46c57ba10395a81a578cd0c57ae300ab6aee01d4e2dcd62550c1203cb64cb66cd8de3f7d7d4f
7
+ data.tar.gz: 652c953b9d59e33a58d54d880a86be9058822ca286266735016d0a1a8fffa7fc41fc51537aca66db7d24e9531fb47009336c245ed32900caec141164fbc47805
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.2.0] - 2022-04-20
2
+
3
+ - Monitor helm upgrade command and periodically reload getting logs when new pods appear
4
+
1
5
  ## [0.1.6] - 2022-04-17
2
6
 
3
7
  - Add `helm_test_logs` exe to check logs during `helm test`
@@ -13,9 +13,19 @@ event_pid = Process.spawn 'kubectl get events --watch-only=true'
13
13
  service_pid = Process.spawn 'kubectl get services --watch-only=true'
14
14
 
15
15
  wait_for_pod_to_log
16
- 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 --pod-running-timeout=300s"
17
16
 
18
- Process.wait helm_pid
19
- puts `kill #{log_pid}`
17
+ @pods = []
18
+
19
+ while Process.waitpid(helm_pid, Process::WNOHANG) == nil do
20
+ pods = get_pods
21
+ if pods != @pods
22
+ @pods = pods
23
+ 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"
26
+ end
27
+ sleep 2.5
28
+ end
29
+ puts `kill #{@log_pid}`
20
30
  puts `kill #{event_pid}`
21
31
  puts `kill #{service_pid}`
data/get_pods.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'open3'
2
+
3
+ $release_name = 'redis'
4
+ stdout, stderr, _ = Open3.capture3 "kubectl get pods -lapp.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=#{$release_name} -o name"
5
+ if stderr.empty?
6
+ puts stdout.lines.join(',')
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HelmUpgradeLogs
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
@@ -24,6 +24,15 @@ def wait_for_pod_to_log
24
24
  }
25
25
  end
26
26
 
27
+ 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"
29
+ if stderr.empty?
30
+ stdout.lines.collect { |pod| pod.strip }
31
+ else
32
+ []
33
+ end
34
+ end
35
+
27
36
  module HelmUpgradeLogs
28
37
  class Error < StandardError; end
29
38
  # Your code goes here...
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.1.6
4
+ version: 0.1.7
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-04-19 00:00:00.000000000 Z
11
+ date: 2022-04-20 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
@@ -41,6 +41,7 @@ files:
41
41
  - bin/start_kind.sh
42
42
  - exe/helm_test_logs
43
43
  - exe/helm_upgrade_logs
44
+ - get_pods.rb
44
45
  - helm_upgrade_logs.gemspec
45
46
  - lib/helm_upgrade_logs.rb
46
47
  - lib/helm_upgrade_logs/version.rb