Am 28. Mai 2010 03:59 schrieb Tom Limoncelli <[email protected]>:
> --- a/daemons/ganeti-watcher
> +++ b/daemons/ganeti-watcher
> @@ -48,6 +48,7 @@ from ganeti import ssconf
> -      utils.EnsureDaemon(constants.RAPI)
> +
> +      # Restart RAPI if it isn't responding to queries.
> +      # Only kill/restart RAPI once.  Otherwise just give up.
> +      rapi_restarted = False
> +      while True:
> +        utils.EnsureDaemon(constants.RAPI)
> +        logging.debug("Attempting to talk with RAPI")
> +        master_rapi = rapi_client.GanetiRapiClient("localhost",
> +          ssl_cert_file=constants.RAPI_CERT_FILE)

This won't work on master HEAD. Please implement proper SSL
certificate verification (see tools/move-instance).

> +        try:
> +          master_version = master_rapi.GetVersion()
> +        except:

Catch specific exceptions.

> +          logging.error("Could not open connection to RAPI")

logging.exception

> +          if rapi_restarted:
> +             break
> +          else:
> +             logging.debug("RAPI is running but did not speak.  Killing 
> RAPI")
> +             utils.StopDaemon(constants.RAPI)
> +             continue
> +        if master_version == 2:

Don't hardcode this, move it to a constant at least.

> +          break
> +        else:
> +          logging.fatal("RAPI version said %s, expecting 2" % master_version)
>
>       try:
>         watcher = Watcher(options, notepad)
> diff --git a/lib/utils.py b/lib/utils.py
> index 2b3e785..8594779 100644
> --- a/lib/utils.py
> +++ b/lib/utils.py
> @@ -2148,6 +2148,19 @@ def EnsureDaemon(name):
>   return True
>
>
> +def StopDaemon(name):
> +  """Stop a daemon.
> +
> +  """
> +  result = RunCmd([constants.DAEMON_UTIL, "stop", name])

Why not “restart”?

Michael

Reply via email to