validates :command, :container_image, :output_path, :cwd, :priority, :presence => true
validate :validate_state_change
validate :validate_change
- after_save :request_finalize
+ after_save :handle_completed
has_many :container_requests, :foreign_key => :container_uuid, :class_name => 'ContainerRequest', :primary_key => :uuid
t.add :container_image
t.add :cwd
t.add :environment
+ t.add :exit_code
t.add :finished_at
t.add :log
t.add :mounts
when Complete
if self.state_changed?
- permitted.push :state, :finished_at, :output, :log
+ permitted.push :state, :finished_at, :output, :log, :exit_code
else
errors.add :state, "cannot update record"
end
check_update_whitelist permitted
end
- def request_finalize
+ def handle_completed
# This container is finished so finalize any associated container requests
# that are associated with this container.
if self.state_changed? and [Complete, Cancelled].include? self.state
act_as_system_user do
- # Try to close container requests associated with this container
+ # Notify container requests associated with this container
ContainerRequest.where(container_uuid: uuid,
:state => ContainerRequest::Committed).each do |cr|
- cr.state = ContainerRequest::Final
- cr.save
+ cr.container_completed!
end
# Try to cancel any outstanding container requests made by this container.