WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] minor bug in patch support

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] minor bug in patch support
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Wed, 24 Mar 2010 11:07:38 +0000
Delivery-date: Wed, 24 Mar 2010 04:01:04 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1269428813 0
# Node ID 72cd96315c86de4311cbaefbae5967e0b7b55f7a
# Parent  8b359da7c685ed5deac3390d59ba5947e338cdc7
CA-36934: in the API call patch "precheck", if the patch has been downloaded 
from the master then delete the patch afterwards. This makes leaks of patch 
files less likely (although they're going to be rare since there aren't going 
to be many patches)

Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>

diff -r 8b359da7c685 -r 72cd96315c86 ocaml/xapi/xapi_pool_patch.ml
--- a/ocaml/xapi/xapi_pool_patch.ml     Wed Mar 17 17:57:21 2010 +0000
+++ b/ocaml/xapi/xapi_pool_patch.ml     Wed Mar 24 11:06:53 2010 +0000
@@ -639,14 +639,7 @@
   | Bad_precheck_xml error ->
       raise (Api_errors.Server_error (Api_errors.invalid_patch_with_log, 
[error]))
 
-let precheck ~__context ~self ~host =
-  (* check we're not on oem *)
-  if on_oem ~__context
-    then raise (Api_errors.Server_error 
(Api_errors.not_allowed_on_oem_edition, ["patch-precheck"]));
-
-  (* get the patch from the master (no-op if we're the master) *)
-  get_patch_to_local ~__context ~self;
-
+let run_precheck ~__context ~self ~host =
   let path = Db.Pool_patch.get_filename ~__context ~self in
     match execute_patch path [ "precheck" ] with
       | Success(output, _) -> output
@@ -658,6 +651,25 @@
         let msg = Printf.sprintf "Error running prechecks on patch %s: %s" 
(Ref.string_of self) log in
           debug "%s" msg;
           raise 
(Api_errors.Server_error(Api_errors.patch_precheck_failed_unknown_error, 
[Ref.string_of self; msg]))
+
+(* precheck API call entrypoint *)
+let precheck ~__context ~self ~host =
+  (* check we're not on oem *)
+  if on_oem ~__context
+    then raise (Api_errors.Server_error 
(Api_errors.not_allowed_on_oem_edition, ["patch-precheck"]));
+
+  (* get the patch from the master (no-op if we're the master) *)
+  get_patch_to_local ~__context ~self;
+
+  finally 
+         (fun () -> run_precheck ~__context ~self ~host)
+         (fun () ->
+                  (* This prevents leaking space on the slave if the patch is 
repeatedly uploaded, prechecked and then destroyed *)
+                  if not (Pool_role.is_master ()) then begin              
+                        let path = Db.Pool_patch.get_filename ~__context ~self 
in
+                        Unixext.unlink_safe path;                 
+                  end
+         )
 
 let apply ~__context ~self ~host = 
   (* 0th, check we're not on oem *)
@@ -673,7 +685,7 @@
   
   let path = Db.Pool_patch.get_filename ~__context ~self in
     (* 3rd, run prechecks *)
-    precheck ~__context ~self ~host;
+    run_precheck ~__context ~self ~host;
  
     (* 4th, apply the patch *)
     begin
1 file changed, 21 insertions(+), 9 deletions(-)
ocaml/xapi/xapi_pool_patch.ml |   30 +++++++++++++++++++++---------


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

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] minor bug in patch support, David Scott <=