Revision 0623d351

b/daemons/ganeti-noded
93 93
      raise http.HttpNotFound()
94 94

  
95 95
    try:
96
      try:
97
        return method(req.request_body)
98
      except backend.RPCFail, err:
99
        # our custom failure exception; str(err) works fine if the
100
        # exception was constructed with a single argument, and in
101
        # this case, err.message == err.args[0] == str(err)
102
        return (False, str(err))
103
      except:
104
        logging.exception("Error in RPC call")
105
        raise
96
      return method(req.request_body)
97
    except backend.RPCFail, err:
98
      # our custom failure exception; str(err) works fine if the
99
      # exception was constructed with a single argument, and in
100
      # this case, err.message == err.args[0] == str(err)
101
      return (False, str(err))
106 102
    except errors.QuitGanetiException, err:
107 103
      # Tell parent to quit
104
      logging.info("Shutting down the node daemon, arguments: %s",
105
                   str(err.args))
108 106
      os.kill(self.noded_pid, signal.SIGTERM)
107
      # And return the error's arguments, which must be already in
108
      # correct tuple format
109
      return err.args
110
    except:
111
      logging.exception("Error in RPC call")
112
      raise
109 113

  
110 114
  # the new block devices  --------------------------
111 115

  
b/lib/backend.py
323 323

  
324 324
  try:
325 325
    priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS)
326
  except errors.OpExecError:
327
    logging.exception("Error while processing ssh files")
328
    return
329 326

  
330
  f = open(pub_key, 'r')
331
  try:
332
    utils.RemoveAuthorizedKey(auth_keys, f.read(8192))
333
  finally:
334
    f.close()
327
    f = open(pub_key, 'r')
328
    try:
329
      utils.RemoveAuthorizedKey(auth_keys, f.read(8192))
330
    finally:
331
      f.close()
335 332

  
336
  utils.RemoveFile(priv_key)
337
  utils.RemoveFile(pub_key)
333
    utils.RemoveFile(priv_key)
334
    utils.RemoveFile(pub_key)
335
  except errors.OpExecError:
336
    logging.exception("Error while processing ssh files")
338 337

  
339
  # Return a reassuring string to the caller, and quit
340
  raise errors.QuitGanetiException(False, 'Shutdown scheduled')
338
  # Raise a custom exception (handled in ganeti-noded)
339
  raise errors.QuitGanetiException(True, 'Shutdown scheduled')
341 340

  
342 341

  
343 342
def GetNodeInfo(vgname, hypervisor_type):
b/lib/bootstrap.py
322 322
  if msg:
323 323
    logging.warning("Could not disable the master role: %s" % msg)
324 324
  result = rpc.RpcRunner.call_node_leave_cluster(master)
325
  if result.failed or not result.data:
326
    logging.warning("Could not shutdown the node daemon and cleanup the node")
325
  msg = result.RemoteFailMsg()
326
  if msg:
327
    logging.warning("Could not shutdown the node daemon and cleanup"
328
                    " the node: %s", msg)
327 329

  
328 330

  
329 331
def SetupNodeDaemon(cluster_name, node, ssh_key_check):
b/lib/cmdlib.py
1917 1917

  
1918 1918
    self.context.RemoveNode(node.name)
1919 1919

  
1920
    self.rpc.call_node_leave_cluster(node.name)
1920
    result = self.rpc.call_node_leave_cluster(node.name)
1921
    msg = result.RemoteFailMsg()
1922
    if msg:
1923
      self.LogWarning("Errors encountered on the remote node while leaving"
1924
                      " the cluster: %s", msg)
1921 1925

  
1922 1926
    # Promote nodes to master candidate as needed
1923 1927
    _AdjustCandidatePool(self)
b/lib/errors.py
226 226
class QuitGanetiException(Exception):
227 227
  """Signal that Ganeti that it must quit.
228 228

  
229
  This is not necessarily an error (and thus not a subclass of GenericError),
230
  but it's an exceptional circumstance and it is thus treated. This instance
231
  should be instantiated with two values. The first one will specify whether an
232
  error should returned to the caller, and the second one will be the returned
233
  result (either as an error or as a normal result).
229
  This is not necessarily an error (and thus not a subclass of
230
  GenericError), but it's an exceptional circumstance and it is thus
231
  treated. This instance should be instantiated with two values. The
232
  first one will specify the return code to the caller, and the second
233
  one will be the returned result (either as an error or as a normal
234
  result). Usually only the leave cluster rpc call should return
235
  status True (as there it's expected we quit), every other call will
236
  return status False (as a critical error was encountered).
234 237

  
235 238
  Examples::
236 239

  
237 240
    # Return a result of "True" to the caller, but quit ganeti afterwards
238
    raise QuitGanetiException(False, True)
241
    raise QuitGanetiException(True, None)
239 242
    # Send an error to the caller, and quit ganeti
240
    raise QuitGanetiException(True, "Fatal safety violation, shutting down")
243
    raise QuitGanetiException(False, "Fatal safety violation, shutting down")
241 244

  
242 245
  """
243 246

  

Also available in: Unified diff