end
def update
- if (resource_attrs.keys - [:owner_uuid, :name, :description, :properties]).empty? or @object.container_uuid.nil?
+ if (resource_attrs.keys.map(&:to_sym) - [:owner_uuid, :name, :description, :properties]).empty? or @object.container_uuid.nil?
# If no attributes are being updated besides these, there are no
# cascading changes to other rows/tables, the only lock will be
# the single row lock on SQL UPDATE.
end
def update
- if (resource_attrs.keys - [:cost, :gateway_address, :output_properties, :progress, :runtime_status]).empty?
+ if (resource_attrs.keys.map(&:to_sym) - [:cost, :gateway_address, :output_properties, :progress, :runtime_status]).empty?
# If no attributes are being updated besides these, there are no
# cascading changes to other rows/tables, the only lock will the
# single row lock on SQL UPDATE.
# SPDX-License-Identifier: AGPL-3.0
def row_lock_for_priority_update container_uuid
+ # Locks all the containers under this container, and also any
+ # immediate parent containers. This ensures we have locked
+ # everything that gets touched by either a priority update or state
+ # update.
ActiveRecord::Base.connection.exec_query %{
- select 1 from containers where containers.uuid in (select pri_container_uuid from container_tree($1)) order by containers.uuid for update
+ select 1 from containers where containers.uuid in (
+ select pri_container_uuid from container_tree($1)
+UNION
+ select container_requests.requesting_container_uuid from container_requests
+ where container_requests.container_uuid = $1
+ and container_requests.state = 'Committed'
+ and container_requests.requesting_container_uuid is not NULL
+)
+ order by containers.uuid for update
}, 'select_for_update_priorities', [[nil, container_uuid]]
end
assert_response :success
assert_not_equal 0, Container.find_by_uuid(containers(:running).uuid).priority
end
+
+ test 'update runtime_status, runtime_status is toplevel key' do
+ authorize_with :dispatch1
+ c = containers(:running)
+ patch :update, params: {id: containers(:running).uuid, runtime_status: {activity: "foo", activityDetail: "bar"}}
+ assert_response :success
+ end
+
+ test 'update runtime_status, container is toplevel key' do
+ authorize_with :dispatch1
+ c = containers(:running)
+ patch :update, params: {id: containers(:running).uuid, container: {runtime_status: {activity: "foo", activityDetail: "bar"}}}
+ assert_response :success
+ end
+
+ test 'update state, state is toplevel key' do
+ authorize_with :dispatch1
+ c = containers(:running)
+ patch :update, params: {id: containers(:running).uuid, state: "Complete", runtime_status: {activity: "finishing"}}
+ assert_response :success
+ end
end