[arvados] created: 2.6.0-533-ga38f5a5d70

git repository hosting git at public.arvados.org
Tue Aug 22 13:52:12 UTC 2023


        at  a38f5a5d70f836904690bcfac911b9765af479a7 (commit)


commit a38f5a5d70f836904690bcfac911b9765af479a7
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Mon Aug 21 16:56:22 2023 -0400

    20877: Don't retry trashed container requests
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb
index 5e2d449b27..e918650c9f 100644
--- a/services/api/app/models/container.rb
+++ b/services/api/app/models/container.rb
@@ -746,6 +746,7 @@ class Container < ArvadosModel
                                    joins('left outer join containers as requesting_container on container_requests.requesting_container_uuid = requesting_container.uuid').
                                    where("container_requests.container_uuid = ? and "+
                                          "container_requests.priority > 0 and "+
+                                         "container_requests.owner_uuid not in (select group_uuid from trashed_groups) "+
                                          "(requesting_container.priority is null or (requesting_container.state = 'Running' and requesting_container.priority > 0)) and "+
                                          "container_requests.state = 'Committed' and "+
                                          "container_requests.container_count < container_requests.container_count_max", uuid).

commit adc4f013f7479f2bc9df527c723c88513da9329c
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Mon Aug 21 16:42:39 2023 -0400

    20877: When trashing a project, update priorities on container requests
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/services/api/app/models/group.rb b/services/api/app/models/group.rb
index aa3a19bf87..09bb8af97d 100644
--- a/services/api/app/models/group.rb
+++ b/services/api/app/models/group.rb
@@ -4,6 +4,7 @@
 
 require 'can_be_an_owner'
 require 'trashable'
+require 'update_priorities'
 
 class Group < ArvadosModel
   include HasUuid
@@ -178,6 +179,13 @@ class Group < ArvadosModel
       "select target_uuid as group_uuid, trash_at from #{temptable} where trash_at is not NULL " +
       "on conflict (group_uuid) do update set trash_at=EXCLUDED.trash_at",
       "Group.update_trash.insert")
+    ActiveRecord::Base.connection.exec_query(
+      "select container_uuid from container_requests where " +
+      "owner_uuid in (select target_uuid from #{temptable}) and " +
+      "requesting_container_uuid is NULL and state = 'Committed' and container_uuid is not NULL",
+      "Group.update_trash.update_priorities").each do |container_uuid|
+      update_priorities container_uuid["container_uuid"]
+    end
   end
 
   def update_frozen
diff --git a/services/api/db/migrate/20230821000000_priority_update_fix.rb b/services/api/db/migrate/20230821000000_priority_update_fix.rb
new file mode 100644
index 0000000000..514f0d4e18
--- /dev/null
+++ b/services/api/db/migrate/20230821000000_priority_update_fix.rb
@@ -0,0 +1,30 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class PriorityUpdateFix < ActiveRecord::Migration[5.2]
+  def up
+    ActiveRecord::Base.connection.execute %{
+CREATE OR REPLACE FUNCTION container_priority(for_container_uuid character varying, inherited bigint, inherited_from character varying) returns bigint
+    LANGUAGE sql
+    AS $$
+/* Determine the priority of an individual container.
+   The "inherited" priority comes from the path we followed from the root, the parent container
+   priority hasn't been updated in the table yet but we need to behave it like it has been.
+*/
+select coalesce(max(case when containers.uuid = inherited_from then inherited
+                         when containers.priority is not NULL then containers.priority
+                         else container_requests.priority * 1125899906842624::bigint - (extract(epoch from container_requests.created_at)*1000)::bigint
+                    end), 0) from
+    container_requests left outer join containers on container_requests.requesting_container_uuid = containers.uuid
+    where container_requests.container_uuid = for_container_uuid and
+          container_requests.state = 'Committed' and
+          container_requests.priority > 0 and
+          container_requests.owner_uuid not in (select group_uuid from trashed_groups);
+$$;
+}
+  end
+
+  def down
+  end
+end
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 24c5ba3e46..6e8b128c9e 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -206,7 +206,10 @@ select coalesce(max(case when containers.uuid = inherited_from then inherited
                          else container_requests.priority * 1125899906842624::bigint - (extract(epoch from container_requests.created_at)*1000)::bigint
                     end), 0) from
     container_requests left outer join containers on container_requests.requesting_container_uuid = containers.uuid
-    where container_requests.container_uuid = for_container_uuid and container_requests.state = 'Committed' and container_requests.priority > 0;
+    where container_requests.container_uuid = for_container_uuid and
+          container_requests.state = 'Committed' and
+          container_requests.priority > 0 and
+          container_requests.owner_uuid not in (select group_uuid from trashed_groups);
 $$;
 
 
@@ -339,6 +342,30 @@ SET default_tablespace = '';
 
 SET default_with_oids = false;
 
+--
+-- Name: groups; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE public.groups (
+    id bigint NOT NULL,
+    uuid character varying(255),
+    owner_uuid character varying(255),
+    created_at timestamp without time zone NOT NULL,
+    modified_by_client_uuid character varying(255),
+    modified_by_user_uuid character varying(255),
+    modified_at timestamp without time zone,
+    name character varying(255) NOT NULL,
+    description character varying(524288),
+    updated_at timestamp without time zone NOT NULL,
+    group_class character varying(255),
+    trash_at timestamp without time zone,
+    is_trashed boolean DEFAULT false NOT NULL,
+    delete_at timestamp without time zone,
+    properties jsonb DEFAULT '{}'::jsonb,
+    frozen_by_uuid character varying
+);
+
+
 --
 -- Name: api_client_authorizations; Type: TABLE; Schema: public; Owner: -
 --
@@ -663,30 +690,6 @@ CREATE TABLE public.frozen_groups (
 );
 
 
---
--- Name: groups; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.groups (
-    id bigint NOT NULL,
-    uuid character varying(255),
-    owner_uuid character varying(255),
-    created_at timestamp without time zone NOT NULL,
-    modified_by_client_uuid character varying(255),
-    modified_by_user_uuid character varying(255),
-    modified_at timestamp without time zone,
-    name character varying(255) NOT NULL,
-    description character varying(524288),
-    updated_at timestamp without time zone NOT NULL,
-    group_class character varying(255),
-    trash_at timestamp without time zone,
-    is_trashed boolean DEFAULT false NOT NULL,
-    delete_at timestamp without time zone,
-    properties jsonb DEFAULT '{}'::jsonb,
-    frozen_by_uuid character varying
-);
-
-
 --
 -- Name: groups_id_seq; Type: SEQUENCE; Schema: public; Owner: -
 --
@@ -3289,6 +3292,7 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('20221230155924'),
 ('20230421142716'),
 ('20230503224107'),
-('20230815160000');
+('20230815160000'),
+('20230821000000');
 
 

commit 5d7e55e646a7f09058f223fc6192c4816b937fbb
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Mon Aug 21 14:02:23 2023 -0400

    20877: Add test for trashing project
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/services/api/test/fixtures/container_requests.yml b/services/api/test/fixtures/container_requests.yml
index dca89f56d3..cc5aedf5e6 100644
--- a/services/api/test/fixtures/container_requests.yml
+++ b/services/api/test/fixtures/container_requests.yml
@@ -535,7 +535,7 @@ canceled_with_running_container:
 
 running_to_be_deleted:
   uuid: zzzzz-xvhdp-cr5runningcntnr
-  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  owner_uuid: zzzzz-j7d0g-rew6elm53kancon
   name: running to be deleted
   state: Committed
   priority: 1
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 86e9d93bbe..71cb9d7301 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -1479,7 +1479,24 @@ class ContainerRequestTest < ActiveSupport::TestCase
       cr.destroy
 
       # the cr's container now has priority of 0
+      c.reload
+      assert_equal 0, c.priority
+    end
+  end
+
+  test "trash the project containing a container_request and check its container's priority" do
+    act_as_user users(:active) do
+      cr = ContainerRequest.find_by_uuid container_requests(:running_to_be_deleted).uuid
+
+      # initially the cr's container has priority > 0
       c = Container.find_by_uuid(cr.container_uuid)
+      assert_equal 1, c.priority
+
+      prj = Group.find_by_uuid cr.owner_uuid
+      prj.update_attributes!(trash_at: db_current_time)
+
+      # the cr's container now has priority of 0
+      c.reload
       assert_equal 0, c.priority
     end
   end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list