[ARVADOS] created: 9cc813f25cb1d0c912c90ad8ed58166cbaaeff1c
Git user
git at public.curoverse.com
Thu Nov 10 17:17:36 EST 2016
at 9cc813f25cb1d0c912c90ad8ed58166cbaaeff1c (commit)
commit 9cc813f25cb1d0c912c90ad8ed58166cbaaeff1c
Author: radhika <radhika at curoverse.com>
Date: Thu Nov 10 17:16:52 2016 -0500
10293: add output_uuid to container_request and set it during finalize.
diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index 05738de..bac4032 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -42,6 +42,7 @@ class ContainerRequest < ArvadosModel
t.add :runtime_constraints
t.add :state
t.add :use_existing
+ t.add :output_uuid
end
# Supported states for a container request
@@ -79,13 +80,13 @@ class ContainerRequest < ArvadosModel
# Finalize the container request after the container has
# finished/cancelled.
def finalize!
- update_attributes!(state: Final)
+ out_uuid = nil
c = Container.find_by_uuid(container_uuid)
['output', 'log'].each do |out_type|
pdh = c.send(out_type)
next if pdh.nil?
manifest = Collection.where(portable_data_hash: pdh).first.manifest_text
- Collection.create!(owner_uuid: owner_uuid,
+ coll = Collection.create!(owner_uuid: owner_uuid,
manifest_text: manifest,
portable_data_hash: pdh,
name: "Container #{out_type} for request #{uuid}",
@@ -93,7 +94,9 @@ class ContainerRequest < ArvadosModel
'type' => out_type,
'container_request' => uuid,
})
+ out_uuid = coll.uuid if out_type == 'output'
end
+ update_attributes!(state: Final, output_uuid: out_uuid)
end
protected
@@ -271,8 +274,8 @@ class ContainerRequest < ArvadosModel
errors.add :state, "of container request can only be set to Final by system."
end
- if self.state_changed? || self.name_changed? || self.description_changed?
- permitted.push :state, :name, :description
+ if self.state_changed? || self.name_changed? || self.description_changed? || self.output_uuid_changed?
+ permitted.push :state, :name, :description, :output_uuid
else
errors.add :state, "does not allow updates"
end
diff --git a/services/api/db/migrate/20161110171221_add_output_uuid_to_container_request.rb b/services/api/db/migrate/20161110171221_add_output_uuid_to_container_request.rb
new file mode 100644
index 0000000..3c590b1
--- /dev/null
+++ b/services/api/db/migrate/20161110171221_add_output_uuid_to_container_request.rb
@@ -0,0 +1,18 @@
+require 'has_uuid'
+
+class AddOutputUuidToContainerRequest < ActiveRecord::Migration
+ extend HasUuid::ClassMethods
+
+ def up
+ add_column :container_requests, :output_uuid, :string
+
+ no_such_coll = Server::Application.config.uuid_prefix + '-' + '4zz18' + '-xxxxxxxxxxxxxxx'
+ update_sql <<-EOS
+update container_requests set output_uuid = ('#{no_such_coll}');
+EOS
+ end
+
+ def down
+ remove_column :container_requests, :output_uuid
+ end
+end
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 0db782a..a3f4f55 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -291,7 +291,8 @@ CREATE TABLE container_requests (
filters text,
updated_at timestamp without time zone NOT NULL,
container_count integer DEFAULT 0,
- use_existing boolean DEFAULT true
+ use_existing boolean DEFAULT true,
+ output_uuid character varying(255)
);
@@ -2694,4 +2695,6 @@ INSERT INTO schema_migrations (version) VALUES ('20160909181442');
INSERT INTO schema_migrations (version) VALUES ('20160926194129');
-INSERT INTO schema_migrations (version) VALUES ('20161019171346');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20161019171346');
+
+INSERT INTO schema_migrations (version) VALUES ('20161110171221');
\ No newline at end of file
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 34aa442..aa6a34d 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -230,9 +230,10 @@ class ContainerRequestTest < ActiveSupport::TestCase
cr.reload
assert_equal "Committed", cr.state
+ output_pdh = '1f4b0bc7583c2a7f9102c395f4ffc5e3+45'
act_as_system_user do
c.update_attributes!(state: Container::Complete,
- output: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45',
+ output: output_pdh,
log: 'fa7aeb5140e2848d39b416daeef4ffc5+45')
end
@@ -244,6 +245,9 @@ class ContainerRequestTest < ActiveSupport::TestCase
owner_uuid: project.uuid).count,
"Container #{out_type} should be copied to #{project.uuid}")
end
+ assert_not_nil cr.output_uuid
+ output = Collection.find_by_uuid cr.output_uuid
+ assert_equal output_pdh, output.portable_data_hash
end
test "Container makes container request, then is cancelled" do
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list