kubernetes_template_rendering 0.2.1.pre.dc.5 → 0.2.1.pre.dc.7

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: 53dae774584941385d8da6cd1d6adc2e1fe5b689d1150008772f3e2cf88a830c
4
- data.tar.gz: de02816725401bc5d55fd9aa83babe79c0ad8165913166d55674da16fda30d96
3
+ metadata.gz: bcdd01fc6d1d74b92773cc37605bbb89b111332e9d586f50426accf12b2e1b8b
4
+ data.tar.gz: c2e17c6100ce5f65dd77d61ab1d0d3731fbca3e15e03e7890fbc75a33c102dde
5
5
  SHA512:
6
- metadata.gz: 75a17c850e564cab7f9baf8666e2104acb6411b41b10b638525f279c2ecda52a38997d428ba2b2700a3daf66d08c6d7362c9e8e9c736845bef386c9ed8514eee
7
- data.tar.gz: 3399af3e06da59d4553c7fe68b5064dbc8a3ddba278f40216bbd23d0f3140fd56bc129b1755c9c61595803230796cb96d55631cd55fb41051dc0db66a650eac2
6
+ metadata.gz: 2de63b006e3e987b619a5b39fd1064f9780ae3b9876b0eed28b8d58cf8b641b708a76d021246938008ce09cf6804f9bbe4af6b537f7d10433b66207d2e4e5640
7
+ data.tar.gz: 21c984cb6f85512c55d4b77122a9b87681d5935ce91a3d9b7c5e6ff09d039dc4e81248ce9492479c00294fce25a228332706ee00b90dbd78c41cac5bf6226a3d
@@ -28,6 +28,7 @@ module KubernetesTemplateRendering
28
28
 
29
29
  def render(args)
30
30
  child_pids = []
31
+ failed_processes = [] # [[pid, status]]
31
32
 
32
33
  resource_sets.each do |name, resource_sets|
33
34
  puts "Rendering templates for definition #{Color.red(name)}..."
@@ -36,7 +37,7 @@ module KubernetesTemplateRendering
36
37
  if (pid = Process.fork)
37
38
  # this is the parent
38
39
  child_pids << pid
39
- wait_if_max_forked(child_pids)
40
+ wait_if_max_forked(child_pids, failed_processes)
40
41
  else
41
42
  # this is the child
42
43
  render_set(args, resource_set)
@@ -49,9 +50,11 @@ module KubernetesTemplateRendering
49
50
  end
50
51
 
51
52
  if args.fork?
52
- process_statuses = Process.waitall
53
+ Process.waitall.each do |pid, status|
54
+ status.success? or failed_processes << [pid, status]
55
+ end
53
56
 
54
- if (failed_processes = process_statuses.select { |_, status| !status.success? }).any?
57
+ if failed_processes.any?
55
58
  raise "Child process completed with non-zero status: #{failed_processes.inspect}"
56
59
  end
57
60
  end
@@ -65,16 +68,19 @@ module KubernetesTemplateRendering
65
68
 
66
69
  MAX_FORKED_PROCESSES = 9
67
70
 
68
- def wait_if_max_forked(child_pids)
71
+ def wait_if_max_forked(child_pids, failed_processes)
69
72
  while child_pids.size >= MAX_FORKED_PROCESSES
70
73
  begin
71
- Process.waitpid # this is a race condition because 1 or more processes could exit before we get here
74
+ pid, exit_status = Process.waitpid2 # this is a race condition because 1 or more processes could exit before we get here
75
+ exit_status.success? or failed_processes << [pid, exit_status]
72
76
  rescue SystemCallError # this will happen if they all exited before we called waitpid
73
77
  end
74
78
  child_pids.delete_if do |pid|
75
79
  begin
76
80
  _, exit_status = Process.waitpid2(pid, Process::WNOHANG)
77
- exit_status.success? or raise "Child process #{pid} failed"
81
+ if exit_status && !exit_status.success?
82
+ failed_processes << [pid, exit_status]
83
+ end
78
84
  rescue Errno::ECHILD # No child processes
79
85
  true
80
86
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KubernetesTemplateRendering
4
- VERSION = "0.2.1.pre.dc.5"
4
+ VERSION = "0.2.1.pre.dc.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubernetes_template_rendering
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1.pre.dc.5
4
+ version: 0.2.1.pre.dc.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Octothorpe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-14 00:00:00.000000000 Z
11
+ date: 2024-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport