Sha256: 8b27355bdec52d310969adc640c444d21b3221ac6a92b5c565ce0351c0fcf358

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'open3'
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'helm_upgrade_logs'

$release_name = ARGV.find { |arg| !arg.start_with?('-') }

helm_pid = Process.spawn "helm upgrade #{ARGV.join(' ')}"

event_pid = Process.spawn 'kubectl get events --watch-only=true'
service_pid = Process.spawn 'kubectl get services --watch-only=true'

wait_for_pod_to_log

@pods = []
@pod_pids = {}

while Process.waitpid(helm_pid, Process::WNOHANG) == nil do
  pods = get_pods
  if pods != @pods
    @pods = pods
    puts "[INFO] Pods: #{pods.join(',')}"
    # Could change this each to Parallel.each
    @pods.each do |pod|
      if @pod_pids[pod].nil?
        wait_for_specific_pod_to_log pod
        log_pid = Process.spawn "kubectl logs #{pod} -f --all-containers --prefix --ignore-errors=true --timestamps=true"
        @pod_pids[pod] = log_pid
      end
    end
  end
  sleep 1
end
`kill #{event_pid}`
`kill #{service_pid}`
@pod_pids.each do |pod, pid|
  `kill #{pid}`
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
helm_upgrade_logs-0.2.3 exe/helm_upgrade_logs
helm_upgrade_logs-0.2.2 exe/helm_upgrade_logs