Skip to content

Commit

Permalink
Merge pull request #179 from chef/nikhil/CHEF-7157-update-ruby-chef-l…
Browse files Browse the repository at this point in the history
…atest

Updated verify pipeline and dependencies
  • Loading branch information
nikhil2611 authored Oct 25, 2023
2 parents 47cca6e + 6e82e7e commit b5647f9
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 29 deletions.
12 changes: 2 additions & 10 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@ expeditor:

steps:

- label: run-lint-and-specs-ruby-2.7
- label: run-lint-and-specs-ruby-3.1
command:
- .expeditor/run_linux_tests.sh rake
expeditor:
executor:
docker:
image: ruby:2.7-buster

- label: run-lint-and-specs-ruby-3.0
command:
- .expeditor/run_linux_tests.sh rake
expeditor:
executor:
docker:
image: ruby:3.0-buster
image: ruby:3.1
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ group :development do
gem 'fakefs'
gem 'simplecov'
gem "chef-zero", "~> 15" # eval when we drop ruby 2.6
gem "chef", "~> 16" # eval when we drop ruby 2.6
gem "ohai", "~> 16" # eval when we drop ruby 2.6
gem "chef", "~> 18"
gem "ohai", "~> 18" # eval when we drop ruby 2.6
gem "knife", "~> 18"
end
4 changes: 2 additions & 2 deletions knife-ec-backup.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ Gem::Specification.new do |s|
s.email = "[email protected]"
s.homepage = "https://www.chef.io"

s.required_ruby_version = ">= 2.6"
s.required_ruby_version = ">= 3.1"

# We need a more recent version of mixlib-cli in order to support --no- options.
# ... but, we can live with those options not working, if it means the plugin
# can be included with apps that have restrictive Gemfile.locks.
# s.add_dependency "mixlib-cli", ">= 1.2.2"
s.add_dependency "sequel", "~> 5.9"
s.add_dependency "pg"
s.add_dependency "chef", ">= 11.8"
s.add_dependency "chef", "~> 18.0"
s.add_dependency "veil"
s.add_dependency "knife-tidy"

Expand Down
4 changes: 2 additions & 2 deletions lib/chef/knife/ec_backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def for_each_user
remote_users.each_pair do |name, url|
yield name, url
end
rescue Net::HTTPServerException => ex
rescue Net::HTTPClientException => ex
knife_ec_error_handler.add(ex)
end

Expand All @@ -95,7 +95,7 @@ def for_each_organization
ui.msg "Downloading organization object for #{name} from #{url}"
begin
org = rest.get(url)
rescue Net::HTTPServerException => ex
rescue Net::HTTPClientException => ex
ui.error "Failed to find organization '#{name}'."
knife_ec_error_handler.add(ex)
next
Expand Down
2 changes: 1 addition & 1 deletion lib/chef/knife/ec_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def org_admin
else
admin_users[0]
end
rescue Net::HTTPServerException => ex
rescue Net::HTTPClientException => ex
knife_ec_error_handler.add(ex)
end
end
Expand Down
14 changes: 7 additions & 7 deletions lib/chef/knife/ec_restore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run
def create_organization(orgname)
org = JSONCompat.from_json(File.read("#{dest_dir}/organizations/#{orgname}/org.json"))
rest.post('organizations', org)
rescue Net::HTTPServerException => ex
rescue Net::HTTPClientException => ex
if ex.response.code == "409"
rest.put("organizations/#{orgname}", org)
else
Expand All @@ -89,7 +89,7 @@ def restore_open_invitations(orgname)
invitations.each do |invitation|
begin
rest.post("organizations/#{orgname}/association_requests", { 'user' => invitation['username'] })
rescue Net::HTTPServerException => ex
rescue Net::HTTPClientException => ex
if ex.response.code != "409"
ui.error("Cannot create invitation #{invitation['id']}")
knife_ec_error_handler.add(ex)
Expand All @@ -106,7 +106,7 @@ def add_users_to_org(orgname)
response = rest.post("organizations/#{orgname}/association_requests", { 'user' => username })
association_id = response["uri"].split("/").last
rest.put("users/#{username}/association_requests/#{association_id}", { 'response' => 'accept' })
rescue Net::HTTPServerException => ex
rescue Net::HTTPClientException => ex
knife_ec_error_handler.add(ex) if ex.response.code != "409"
end
end
Expand Down Expand Up @@ -149,7 +149,7 @@ def restore_users
user_with_password = user.dup
user_with_password['password'] = SecureRandom.hex
rest.post('users', user_with_password)
rescue Net::HTTPServerException => ex
rescue Net::HTTPClientException => ex
if ex.response.code == "409"
rest.put("users/#{name}", user)
next
Expand All @@ -175,7 +175,7 @@ def purge_users_on_restore
ui.msg "Deleting user #{user} from remote (purge is on)"
begin
rest.delete("/users/#{user}")
rescue Net::HTTPServerException => e
rescue Net::HTTPClientException => e
ui.warn "Failed deleting user #{user} from remote #{e}"
end
end
Expand Down Expand Up @@ -321,7 +321,7 @@ def chef_fs_copy_pattern(pattern_str, chef_fs_config)
chef_fs_config.chef_fs, nil,
config, ui,
proc { |entry| chef_fs_config.format_path(entry) })
rescue Net::HTTPServerException,
rescue Net::HTTPClientException,
Chef::ChefFS::FileSystem::NotFoundError,
Chef::ChefFS::FileSystem::OperationFailedError => ex
knife_ec_error_handler.add(ex)
Expand Down Expand Up @@ -387,7 +387,7 @@ def put_acl(rest, url, acls)
rest.put("#{url}/#{permission}", { permission => acls[permission] })
end
end
rescue Net::HTTPServerException => ex
rescue Net::HTTPClientException => ex
knife_ec_error_handler.add(ex)
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/chef/knife/ec_error_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def cheffs_filesystem_exception(type)
"timestamp": "1988-04-17 00:00:00 \+0000",
"message": "I'm not real!",
"backtrace": null,
"exception": "Net::HTTPServerException"
"exception": "Net::HTTPClientException"
}
/).to_stdout
end
Expand All @@ -66,22 +66,22 @@ def cheffs_filesystem_exception(type)
"timestamp": "1988-04-17 00:00:00 +0000",
"message": "I'm not real!",
"backtrace": null,
"exception": "Net::HTTPServerException"
"exception": "Net::HTTPClientException"
}{
"timestamp": "1988-04-17 00:00:00 +0000",
"message": "I'm not real!",
"backtrace": null,
"exception": "Net::HTTPServerException"
"exception": "Net::HTTPClientException"
}{
"timestamp": "1988-04-17 00:00:00 +0000",
"message": "I'm not real!",
"backtrace": null,
"exception": "Net::HTTPServerException"
"exception": "Net::HTTPClientException"
}{
"timestamp": "1988-04-17 00:00:00 +0000",
"message": "I'm not real!",
"backtrace": null,
"exception": "Net::HTTPServerException"
"exception": "Net::HTTPClientException"
}{
"timestamp": "1988-04-17 00:00:00 +0000",
"message": "The reason",
Expand Down

0 comments on commit b5647f9

Please sign in to comment.