Commit 8659b73e authored by Guido Trotter's avatar Guido Trotter
Browse files

Convert LUConnectConsole to concurrency

For ConnectConsole we just need to lock the instance we're connecting
to. We make a few rpcs to its primary node, but node daemons can now
handle multiple queries and nodes cannot be removed till they have
instances on them anyway. Note that since we return the ssh command, and
that's executed outside of the ganeti daemon, without any locks held,
the instance can then be subject to operations while we're connected to
it, but that was the previous behavior as well.

Reviewed-by: iustinp
parent 43905206
...@@ -3354,6 +3354,10 @@ class LUConnectConsole(NoHooksLU): ...@@ -3354,6 +3354,10 @@ class LUConnectConsole(NoHooksLU):
""" """
_OP_REQP = ["instance_name"] _OP_REQP = ["instance_name"]
REQ_BGL = False
def ExpandNames(self):
self._ExpandAndLockInstance()
def CheckPrereq(self): def CheckPrereq(self):
"""Check prerequisites. """Check prerequisites.
...@@ -3361,12 +3365,9 @@ class LUConnectConsole(NoHooksLU): ...@@ -3361,12 +3365,9 @@ class LUConnectConsole(NoHooksLU):
This checks that the instance is in the cluster. This checks that the instance is in the cluster.
""" """
instance = self.cfg.GetInstanceInfo( self.instance = self.cfg.GetInstanceInfo(self.op.instance_name)
self.cfg.ExpandInstanceName(self.op.instance_name)) assert self.instance is not None, \
if instance is None: "Cannot retrieve locked instance %s" % self.op.instance_name
raise errors.OpPrereqError("Instance '%s' not known" %
self.op.instance_name)
self.instance = instance
def Exec(self, feedback_fn): def Exec(self, feedback_fn):
"""Connect to the console of an instance """Connect to the console of an instance
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment