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] CA-40030: Cancel grace-retry timer when calling Host.a

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CA-40030: Cancel grace-retry timer when calling Host.apply_edition
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Fri, 9 Apr 2010 14:15:27 +0100
Delivery-date: Fri, 09 Apr 2010 06:17:41 -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 Rob Hoes <rob.hoes@xxxxxxxxxx>
CA-40030: Cancel grace-retry timer when calling Host.apply_edition

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r 74fbfc29d523 ocaml/license/grace_retry.ml
--- a/ocaml/license/grace_retry.ml      Fri Apr 09 14:08:56 2010 +0100
+++ b/ocaml/license/grace_retry.ml      Fri Apr 09 14:09:33 2010 +0100
@@ -16,24 +16,27 @@
  
 open Client
 
+let event_name = "retry after obtaining grace license"
+let schedule = Xapi_periodic_scheduler.OneShot
+
 (** Schedule a timer to call [Host.apply_edition] again after an hour. Call 
this
  *  after getting a "grace" license in order to check whether the license 
server
  *  happened to come back. If so, a "real" license will be checked out.
  *  Note: the LPE already does a similar thing, but does not notify the 
product (xapi)
  *  if it succeeds to check out a "real" license! *)
 let retry_periodically host edition =
-       let period = 
+       let period =
                if Xapi_fist.reduce_grace_retry_period () then
-                       300.    (* 1h *)
+                       300.    (* 5min *)
                else
-                       3600.   (* 5min *)
+                       3600.   (* 1h *)
        in
-       let schedule = Xapi_periodic_scheduler.OneShot in
        let retry_fn () = 
-           let now = (Unix.gettimeofday ()) in
+               let now = (Unix.gettimeofday ()) in
                Server_helpers.exec_with_new_task "grace_retry"
                        (fun __context ->
                                Helpers.call_api_functions ~__context (fun rpc 
session_id ->
+                                       (* Retry checkout *)
                                        Client.Host.apply_edition rpc 
session_id host edition;
                                        (* Remove any newly generated grace 
alerts *)
                                        let alerts = Client.Message.get_since 
rpc session_id (Date.of_float now) in
@@ -46,5 +49,7 @@
                                )
                        )
        in
-       Xapi_periodic_scheduler.add_to_queue "retry after obtaining grace 
license" schedule period retry_fn
+       Xapi_periodic_scheduler.add_to_queue event_name schedule period retry_fn
        
+let cancel () =
+       Xapi_periodic_scheduler.remove_from_queue event_name
diff -r 74fbfc29d523 ocaml/xapi/xapi_host.ml
--- a/ocaml/xapi/xapi_host.ml   Fri Apr 09 14:08:56 2010 +0100
+++ b/ocaml/xapi/xapi_host.ml   Fri Apr 09 14:09:33 2010 +0100
@@ -1202,7 +1202,8 @@
 (* Licensing *)
                
 let apply_edition ~__context ~host ~edition =
-       debug "apply_edition to %s" edition;
+       debug "apply_edition to %s" edition; (* cancel any existing grace-retry 
timer *)
+       Grace_retry.cancel ();
        let current_edition = Db.Host.get_edition ~__context ~self:host in
        let current_license = !License.license in
        let default = License.default () in

Attachment: grace-retry-fix
Description: Text document

_______________________________________________
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] CA-40030: Cancel grace-retry timer when calling Host.apply_edition, Rob Hoes <=