[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH 3 of 7] CA-34933: do not gc sessions in running tasks



 ocaml/idl/datamodel.ml |  2 ++
 ocaml/xapi/db_gc.ml    |  9 +++++----
 2 files changed, 7 insertions(+), 4 deletions(-)


# HG changeset patch
# User Marcus Granado <marcus.granado@xxxxxxxxxx>
# Date 1274449016 -3600
# Node ID 3678824a34447601d81a115c6e83b8e7b2b06c99
# Parent  d14022d7376eae45eb056c5c9caa61eadb883358
CA-34933: do not gc sessions in running tasks

Signed-off-by: Marcus Granado <marcus.granado@xxxxxxxxxxxxx>

diff -r d14022d7376e -r 3678824a3444 ocaml/idl/datamodel.ml
--- a/ocaml/idl/datamodel.ml
+++ b/ocaml/idl/datamodel.ml
@@ -2858,6 +2858,7 @@
                  field ~in_product_since:rel_george ~qualifier:DynamicRO 
~default_value:(Some(VString(""))) ~ty:String "auth_user_sid" "the subject 
identifier of the user that was externally authenticated. If a session instance 
has is_local_superuser set, then the value of this field is undefined.";
                  field ~in_product_since:rel_midnight_ride 
~qualifier:DynamicRO ~default_value:(Some(VString(""))) ~ty:String 
"auth_user_name" "the subject name of the user that was externally 
authenticated. If a session instance has is_local_superuser set, then the value 
of this field is undefined.";
                  field ~in_product_since:rel_midnight_ride ~qualifier:StaticRO 
~default_value:(Some(VSet [])) ~ty:(Set(String)) "rbac_permissions" "list with 
all RBAC permissions for this session";
+                 field ~in_product_since:rel_midnight_ride 
~qualifier:DynamicRO ~ty:(Set(Ref _task)) "tasks" "list of tasks created using 
the current session";
                ]
        ()
 
@@ -5951,6 +5952,7 @@
 
     (* subtasks hierarchy *)
     (_task, "subtask_of"), (_task, "subtasks");
+    (_task, "session"), (_session, "tasks");
     
     (_pif, "bond_slave_of"), (_bond, "slaves");
     (_bond, "master"), (_pif, "bond_master_of");
diff -r d14022d7376e -r 3678824a3444 ocaml/xapi/db_gc.ml
--- a/ocaml/xapi/db_gc.ml
+++ b/ocaml/xapi/db_gc.ml
@@ -203,10 +203,14 @@
   let all_hosts = Db.Host.get_all ~__context in
   List.iter check_host all_hosts
 
+let task_status_is_completed task_status =
+    (task_status=`success) || (task_status=`failure) || 
(task_status=`cancelled)
+
 let timeout_sessions ~__context =
   let all_sessions = Db.Session.get_internal_records_where ~__context 
~expr:Db_filter_types.True in
   let not_intrapool_sessions = List.filter (fun (_, y) -> not 
y.Db_actions.session_pool) all_sessions in
-  let disposable_sessions = not_intrapool_sessions in
+  let unused_sessions = List.filter (fun (_, y) -> List.for_all (fun t -> 
task_status_is_completed (Db.Task.get_status ~__context ~self:t)) 
y.Db_actions.session_tasks) not_intrapool_sessions in
+  let disposable_sessions = unused_sessions in
   (* Only keep a list of (ref, last_active, uuid) *)
   let disposable_sessions = List.map (fun (x, y) -> x, Date.to_float 
y.Db_actions.session_last_active, y.Db_actions.session_uuid) 
disposable_sessions in
   (* Definitely invalidate sessions last used long ago *)
@@ -236,9 +240,6 @@
   let oldest_completed_time = Unix.time() -. Xapi_globs.completed_task_timeout 
(* time out completed tasks after 65 minutes *) in
   let oldest_pending_time   = Unix.time() -. Xapi_globs.pending_task_timeout   
(* time out pending tasks after 24 hours *) in
 
-  let task_status_is_completed task_status =
-    (task_status=`success) || (task_status=`failure) || 
(task_status=`cancelled) in  
-
   let should_delete_task (_, t) = 
     if task_status_is_completed t.Db_actions.task_status
     then Date.to_float t.Db_actions.task_finished < oldest_completed_time

Attachment: xen-api.hg-3.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.