helm_upgrade_logs 0.2.2 → 0.2.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: fa3f3a0b230ebece6f834e3f1d350f7dce7efdc38e9798f6e88e2c2ac2e4ebea
4
- data.tar.gz: '09b2dc417d34ceada26ea29976dceab275d035c69da9fac86afbf613b2f239b1'
3
+ metadata.gz: e5195e2b08d8a4c6838d8cbf16fa070551bed1953008f46873d6f41ac07c829d
4
+ data.tar.gz: 338bab0411ebc7e0a059b66392a30342187a6a9fb1ba623a3796baee331a5119
5
5
  SHA512:
6
- metadata.gz: 6b079a3c801b1cfc3ed7ebfe43b669e8845cf02bb2980e541e58fe1b049d4138e0cbb120a64099e97335bc95b0b98f2510a934299ff470251ebf56bf247cfbb3
7
- data.tar.gz: 40d106a0b06352621fc90cfb8653fbc3f279d8676d438eeb592e6fa94a39bc896f8a690df4a6633654d410f9bae5600605790fbcd1bdbf33c95aa114d9403053
6
+ metadata.gz: 5d7b9c585181eef228e5bdaebacbc3d5d1764e6d0bbcb6aeb62db8389482f2011bba423d4d836dae44c8c16d0e2c94cab8352ef60b5376cb884b46ed2e858c75
7
+ data.tar.gz: 1417cbbe9bcbcc02501d62c30eac1b6d13b9ee8bbe060f577e2342d188539e215ea73c32d25a072bb3f401a29fd3436a5a8de524ebdd73fce829d820eed459a3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.2.3] - 2022-04-20
2
+
3
+ - Configuration on initial wait for pods logs and subsequent wait limits
4
+
1
5
  ## [0.2.2] - 2022-04-20
2
6
 
3
7
  - Wait for logs on each pod having a process for logging each pod
data/README.md CHANGED
@@ -20,7 +20,9 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- This gem is purely about an `exe` to wrap around `helm` commands and to log helpful commands.
23
+ This gem is purely about an `exe` to wrap around `helm` commands and to log events and pod logs that happen as
24
+ part of that release while it is being released.
25
+
24
26
  Once installed, install/upgrade a helm chart with
25
27
 
26
28
  ```bash
@@ -29,17 +31,29 @@ helm_upgrade_logs --install redis bitnami/redis --set auth.enabled=false --versi
29
31
 
30
32
  After the `helm_upgrade_logs` command put any options that would normally add after `helm upgrade`.
31
33
 
34
+ This library waits for logs to start in pods for 90 seconds or controlled by environment variable `helm_upgrade_logs_log_start`.
35
+ After that it waits 35 seconds for logs to start in pods after the first one.
36
+ This is controlled by environment variable `helm_upgrade_logs_pod_start`
37
+
32
38
  To test a chart showing it logs, in a similar way run
33
39
  ```bash
34
40
  helm_test_logs redis
35
41
  ```
36
42
 
37
- This also has a bash script which can be used directly. E.g., to install `nginx` from the chart `bitnami/nginx`.
43
+ ### Aside bash script
44
+
45
+ This also has a bash script which can be used directly although it will probably not work on CI
46
+ and also does not close background processes so not ideal.
47
+
48
+ However if you do want to try it, to install `nginx` from the chart `bitnami/nginx` run
38
49
 
39
50
  ```
40
51
  curl -s https://raw.githubusercontent.com/SamuelGarrattIqa/helm_upgrade_logs/main/bin/helm_upgrade_logs.sh | bash -s -- --install nginx bitnami/nginx
41
52
  ```
42
53
 
54
+ ## TODO
55
+ * Make library handle `n`, `--namespace` from helm command
56
+
43
57
  ## Development
44
58
 
45
59
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HelmUpgradeLogs
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
@@ -3,6 +3,9 @@
3
3
  require 'open3'
4
4
  require_relative "helm_upgrade_logs/version"
5
5
 
6
+ ENV['helm_upgrade_logs_log_start'] ||= '90'
7
+ ENV['helm_upgrade_logs_pod_start'] ||= '35'
8
+
6
9
  # Approach not ideal as it will for all containers to be ready and want to stream logs before that
7
10
  def wait_for_container_ready
8
11
  wait_pid = Process.spawn 'kubectl wait --for=condition=ContainersReady pod --selector "app.kubernetes.io/managed-by=Helm" --timeout=30s'
@@ -12,29 +15,29 @@ end
12
15
  # Wait for pods with logs to be present
13
16
  # Not ideal due to https://github.com/kubernetes/kubernetes/issues/28746
14
17
  def wait_for_pod_to_log
15
- 90.times {
18
+ ENV['helm_upgrade_logs_log_start'].to_i.times do |i|
16
19
  sleep 1
17
- stdout, stderr, _ = Open3.capture3 "kubectl logs -lapp.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=#{$release_name}"
20
+ stdout, stderr, _ = Open3.capture3 "kubectl logs -lapp.kubernetes.io/instance=#{$release_name}"
18
21
  if stderr.empty? && !stdout.strip.empty?
19
- puts 'Pods with logs found'
22
+ puts '[INFO] Pods with logs found'
20
23
  break
21
24
  else
22
- puts "Waiting for pod logs: #{stderr}"
25
+ puts "[INFO] Waiting for pod logs: #{stderr}" if i % 3 == 0
23
26
  end
24
- }
27
+ end
25
28
  end
26
29
 
27
30
  def wait_for_specific_pod_to_log(pod_name)
28
- 30.times {
31
+ ENV['helm_upgrade_logs_pod_start'].to_i.times do |i|
29
32
  sleep 1
30
33
  stdout, stderr, _ = Open3.capture3 "kubectl logs #{pod_name}"
31
34
  if stderr.empty? && !stdout.strip.empty?
32
- puts "Pod #{pod_name} with logs found"
35
+ puts "[INFO] Pod #{pod_name} with logs found"
33
36
  break
34
37
  else
35
- puts "Waiting for pod #{pod_name} logs: #{stderr}"
38
+ puts "[INFO] Waiting for pod #{pod_name} logs: #{stderr}" if i % 2 == 0
36
39
  end
37
- }
40
+ end
38
41
  end
39
42
 
40
43
  def get_pods
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt