Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37800 - Don't apply the compute profile when updating host #10330

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading