Skip to content

Commit

Permalink
Fixes #37800 - Don't apply the compute profile when updating host
Browse files Browse the repository at this point in the history
(cherry picked from commit 92e7ae9)
  • Loading branch information
stejskalleos committed Sep 25, 2024
1 parent d88839a commit fbe7ac1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
1 change: 0 additions & 1 deletion app/controllers/api/v2/hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def update
@all_parameters = true

@host.attributes = host_attributes(host_params, @host)
apply_compute_profile(@host) if (params[:host] && params[:host][:compute_attributes].present?) || @host.compute_profile_id_changed?

process_response @host.save
rescue InterfaceTypeMapper::UnknownTypeException => e
Expand Down
31 changes: 3 additions & 28 deletions test/controllers/api/v2/hosts_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,10 @@ def last_record
post :create, params: { :host => valid_attrs }
end

test "update applies attribute modifiers on the host" do
disable_orchestration
expect_attribute_modifier(ComputeAttributeMerge)
expect_attribute_modifier(InterfaceMerge, :merge_compute_attributes => true)
put :update, params: { :id => @host.to_param, :host => valid_attrs }
end

test "update applies attribute modifiers on the host when compute profile is changed" do
disable_orchestration
expect_attribute_modifier(ComputeAttributeMerge)
expect_attribute_modifier(InterfaceMerge, :merge_compute_attributes => true)

test "The update of the host does not apply the compute profile" do
compute_attrs = compute_attributes(:with_interfaces)

Host.any_instance.expects(:apply_compute_profile).never
put :update, params: { :id => @host.to_param, :host => basic_attrs_with_profile(compute_attrs) }
end

Expand Down Expand Up @@ -429,22 +420,6 @@ def last_record
assert_equal('newname', Nic::Base.find(nic_id).name)
end

test "should update interfaces from compute profile" do
disable_orchestration

compute_attrs = compute_attributes(:with_interfaces)

put :update, params: { :id => @host.to_param, :host => basic_attrs_with_profile(compute_attrs) }
assert_response :success

as_admin do
@host.interfaces.reload
assert_equal compute_attrs.vm_interfaces.count, @host.interfaces.count
assert_equal expected_compute_attributes(compute_attrs, 0), @host.interfaces.find_by_primary(true).compute_attributes
assert_equal expected_compute_attributes(compute_attrs, 1), @host.interfaces.find_by_primary(false).compute_attributes
end
end

test "should update host without :host root node and rails wraps it correctly" do
put :update, params: { :id => @host.to_param, :name => 'newhostname' }
request_parameters = @request.env['action_dispatch.request.request_parameters']
Expand Down

0 comments on commit fbe7ac1

Please sign in to comment.