cem_acpt 0.8.1 → 0.8.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: c7329475f3aa0a02e2b6f65017ed0c24b35769f31eddcff07f306297d99b6558
4
- data.tar.gz: 346c753606378a5b022f2c0cd5e2f3db37dbc473468828075c1c6b9d1f2bf8d6
3
+ metadata.gz: '049c0d34c878395e52956c95a55dd0b1e2fafa9f8ec2e708982b1574865e0c71'
4
+ data.tar.gz: 5a69317f0b2da6e09d60f41cde8b45df6bb475167ec84328917f3ec9dcf0fe9c
5
5
  SHA512:
6
- metadata.gz: d3eeb3af0f675509e0e02f658656a21d66e682c2d127196155a44adedade3513f4361dd78bb818070d0bd4bb2e349782d4a475a3d1a7a51b9ab800bcc0d9b1e6
7
- data.tar.gz: 2ac9dc43f0bd592b22053599060ffce68cccb995b32755686c0c4128cf69c2d125b155738be38a0ad91cbca7e7017109ab0721bfda4adaae4da46ab72e30a00d
6
+ metadata.gz: 023d83eeceb14f629ef811781a51d28b4620c45ebd69fd8417f949d3952a1a2e89f94b42392efc93ee408399717dae0906bc820ee5d870b6052500a4f0a78879
7
+ data.tar.gz: a372082235f0aaf4a533262545f9cb1df04e4ed98f0428e90425d097b1d5e28f2ac8fc40a2b6bf9999707705e88918f6a3398c185eb58680777c95bea16357c6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cem_acpt (0.8.1)
4
+ cem_acpt (0.8.3)
5
5
  async-http (>= 0.60, < 0.70)
6
6
  bcrypt_pbkdf (>= 1.0, < 2.0)
7
7
  deep_merge (>= 1.2, < 2.0)
@@ -25,6 +25,7 @@ module CemAcpt
25
25
  @module_package_path = nil
26
26
  @private_key = nil
27
27
  @public_key = nil
28
+ @applied = false
28
29
  end
29
30
 
30
31
  # @return [Hash] A hash of instance names and IPs
@@ -36,13 +37,18 @@ module CemAcpt
36
37
  terraform_init
37
38
  terraform_plan(formatted_vars, DEFAULT_PLAN_NAME)
38
39
  terraform_apply(DEFAULT_PLAN_NAME)
39
- begin
40
- output = terraform_output('instance_name_ip', json: true)
41
- JSON.parse(output)
42
- rescue JSON::ParserError => e
43
- logger.error('CemAcpt::Provision::Terraform') { "Error parsing Terraform output: #{output}" }
44
- raise e
45
- end
40
+ @applied = true
41
+ end
42
+
43
+ def output
44
+ raise 'Terraform has not been applied yet' unless @applied
45
+
46
+ output = terraform_output('instance_name_ip', json: true)
47
+ logger.debug('CemAcpt::Provision::Terraform') { "Terraform output:\n#{output}" }
48
+ JSON.parse(output)
49
+ rescue JSON::ParserError => e
50
+ logger.error('CemAcpt::Provision::Terraform') { "Error parsing Terraform output: #{output}" }
51
+ raise e
46
52
  end
47
53
 
48
54
  def destroy
@@ -59,7 +59,8 @@ module CemAcpt
59
59
  @run_data[:nodes] = new_node_data
60
60
  logger.info('CemAcpt::TestRunner') { 'Created node data...' }
61
61
  logger.verbose('CemAcpt::TestRunner') { "Node data: #{@run_data[:nodes]}" }
62
- @instance_names_ips = provision_test_nodes
62
+ provision_test_nodes
63
+ @instance_names_ips = provisioner_output
63
64
  logger.info('CemAcpt::TestRunner') { "Instance names and IPs class: #{@instance_names_ips.class}" }
64
65
  @provisioned = true
65
66
  logger.info('CemAcpt::TestRunner') { 'Provisioned test nodes...' }
@@ -156,6 +157,24 @@ module CemAcpt
156
157
  @provisioner.provision
157
158
  end
158
159
 
160
+ def provisioner_output
161
+ logger.info('CemAcpt::TestRunner') { 'Getting provisioner output...' }
162
+ @attempts = 0
163
+ @max_attempts = 3
164
+ output = nil
165
+ while @attempts < @max_attempts
166
+ @attempts += 1
167
+ output = @provisioner.output
168
+ break unless (output.nil? || output.empty?) && @attempts < @max_attempts # Don't sleep if this is last attempt
169
+
170
+ logger.info('CemAcpt::TestRunner') { "Provisioner output is nil or empty, retrying (#{@attempts}/#{@max_attempts})" }
171
+ sleep 3
172
+ end
173
+ raise 'Provisioner output is nil or empty' if output.nil? || output.empty?
174
+
175
+ output
176
+ end
177
+
159
178
  def destroy_test_nodes
160
179
  logger.info('CemAcpt::TestRunner') { 'Destroying test nodes if necessary...' }
161
180
  if !@provisioned
@@ -30,19 +30,10 @@ module CemAcpt
30
30
  stdin.close
31
31
  outerr.sync = true
32
32
  output_thread = Thread.new do
33
- while (line = outerr.readline_nonblock)
33
+ while (line = outerr.gets("\n"))
34
34
  output << line if output
35
35
  io_outerr.write(line) unless line.chomp.empty?
36
36
  end
37
- rescue IO::WaitReadable
38
- begin
39
- IO.select([outerr])
40
- retry
41
- rescue IOError
42
- # outerr closed, won't retry
43
- end
44
- rescue EOFError
45
- # outerr closed, won't retry
46
37
  end
47
38
  wait_thr.join
48
39
  output_thread.exit
@@ -70,21 +61,6 @@ module CemAcpt
70
61
  end
71
62
  nil
72
63
  end
73
-
74
- # IO monkey patch for non-blocking readline
75
- class ::IO
76
- def readline_nonblock
77
- rlnb = []
78
- rnlb << read_nonblock(1) while rlnb[-1] != "\n"
79
- rlnb.join
80
- rescue IO::WaitReadable => blocking
81
- raise blocking if rlnb.empty?
82
-
83
- rlnb.join
84
- rescue EOFError
85
- rlnb.join
86
- end
87
- end
88
64
  end
89
65
  end
90
66
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CemAcpt
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.3'
5
5
  end
@@ -1,6 +1,6 @@
1
1
  command:
2
2
  puppet_idempotent:
3
- exec: 'sudo /opt/puppetlabs/puppet/bin/puppet apply --logdest console,/opt/cem_acpt/idempotent_apply.log --debug --verbose --detailed-exitcodes /opt/cem_acpt/manifest.pp'
3
+ exec: '/opt/puppetlabs/puppet/bin/puppet apply --logdest console,/opt/cem_acpt/idempotent_apply.log --debug --verbose --detailed-exitcodes /opt/cem_acpt/manifest.pp'
4
4
  timeout: 300000 # 5 mins in miliseconds
5
5
  stdout:
6
6
  - "/Applied catalog in.*/"
@@ -1,6 +1,6 @@
1
1
  command:
2
2
  puppet_noop:
3
- exec: 'sudo /opt/puppetlabs/puppet/bin/puppet apply --logdest console,/opt/cem_acpt/noop_apply.log --debug --verbose --detailed-exitcodes --noop /opt/cem_acpt/manifest.pp'
3
+ exec: '/opt/puppetlabs/puppet/bin/puppet apply --logdest console,/opt/cem_acpt/noop_apply.log --debug --verbose --detailed-exitcodes --noop /opt/cem_acpt/manifest.pp'
4
4
  timeout: 300000 # 5 mins in miliseconds
5
5
  stdout:
6
6
  - "Applied catalog in"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cem_acpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - puppetlabs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-05 00:00:00.000000000 Z
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http