Skip to content

Commit

Permalink
(PE-39411) Add descriptive error during infrastructure upgrade when r…
Browse files Browse the repository at this point in the history
…bac token is invalid
  • Loading branch information
jhbuchanan45 committed Oct 10, 2024
1 parent 9a9703e commit a781b83
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tasks/puppet_infra_upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ def wait_until_connected(nodes:, token_file:, timeout: 120)
loop do
response = https.request(request)
unless response.is_a? Net::HTTPSuccess
raise "Unexpected result from orchestrator: #{response.class}\n#{response}"
case (response)

Check failure on line 76 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Setup Test Matrix

Style/RedundantParentheses: Don't use parentheses around a variable.

Check failure on line 76 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

Style/RedundantParentheses: Don't use parentheses around a variable.

Check failure on line 76 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

Style/RedundantParentheses: Don't use parentheses around a variable.
when Net::HTTPUnauthorized
raise "401 Unauthorized: Check your API token at #{token_file} has not been revoked. " +

Check failure on line 78 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Setup Test Matrix

Style/LineEndConcatenation: Use `\` instead of `+` or `<<` to concatenate those strings.

Check failure on line 78 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

Style/LineEndConcatenation: Use `\` instead of `+` or `<<` to concatenate those strings.

Check failure on line 78 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

Style/LineEndConcatenation: Use `\` instead of `+` or `<<` to concatenate those strings.
"An alternate token file can be specified using the token_file param. \n" +

Check failure on line 79 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Setup Test Matrix

Style/LineEndConcatenation: Use `\` instead of `+` or `<<` to concatenate those strings.

Check failure on line 79 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

Style/LineEndConcatenation: Use `\` instead of `+` or `<<` to concatenate those strings.

Check failure on line 79 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

Style/LineEndConcatenation: Use `\` instead of `+` or `<<` to concatenate those strings.
"See https://www.puppet.com/docs/pe/latest/rbac_token_auth_intro for more details"

Check failure on line 80 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Setup Test Matrix

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. (https://rubystyle.guide#consistent-string-literals)

Check failure on line 80 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. (https://rubystyle.guide#consistent-string-literals)

Check failure on line 80 in tasks/puppet_infra_upgrade.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. (https://rubystyle.guide#consistent-string-literals)
else
raise "Unexpected result from orchestrator: #{response.class}\n#{response}"
end
end
inventory = JSON.parse(response.body)
break if inventory['items'].all? { |item| item['connected'] }
Expand Down

0 comments on commit a781b83

Please sign in to comment.