(As opposed to during any update.)
Avoids a situation where a client creates a child CR with
preemptible=false, preemptible is automatically changed to true, but
then preemptible instances are removed from config, and the client
cannot change the CR state to committed without also explicitly
clearing the preemptible flag, because the automatically-enabled
preemptible flag is not allowed.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>
end
def set_preemptible
- if Rails.configuration.Containers.UsePreemptibleInstances &&
+ if (new_record? || state_changed?) &&
+ state == Committed &&
+ Rails.configuration.Containers.UsePreemptibleInstances &&
get_requesting_container_uuid() &&
self.class.any_preemptible_instances?
self.scheduling_parameters['preemptible'] = true
expect[true].push create_minimal_req!(attrs_p)
expect[true].push create_minimal_req!(attrs_nonp)
+ commit_later = create_minimal_req!()
Rails.configuration.InstanceTypes = ConfigLoader.to_OrderedOptions({})
expect[false].push create_minimal_req!(attrs_nonp)
+
+ # Even though preemptible is not allowed, we should be able to
+ # commit a CR that was created earlier when preemptible was the
+ # default.
+ commit_later.update_attributes!(priority: 1, state: "Committed")
+ expect[false].push commit_later
end
set_user_from_auth :active