From 734a2a7cc712f56bef88c1d69d64cf2228662c92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com>
Date: Wed, 18 Jul 2012 11:13:09 +0200
Subject: [PATCH] Fix inconsistency in the LUXI protocol w.r.t. args
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This inconsistency was found during rebalancing. Hbal failed because,
Ganeti couldn't load the opcode. After digging through the cause, an
inconsistency with the "args" field in the LUXI protocol was triggered
by the TemplateHaskell side where it's done uniformed.

For SubmitJob and SubmitManyJobs we treat args as one argument,
containing the job definition. In every other LUXI call args is actually
a list of arguments. This patch fixes this consistency.

This change is NOT backwards compatible.

Signed-off-by: RenΓ© Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/luxi.py           | 4 ++--
 lib/server/masterd.py | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/luxi.py b/lib/luxi.py
index 5799d40e5..108b8362e 100644
--- a/lib/luxi.py
+++ b/lib/luxi.py
@@ -473,13 +473,13 @@ class Client(object):
 
   def SubmitJob(self, ops):
     ops_state = map(lambda op: op.__getstate__(), ops)
-    return self.CallMethod(REQ_SUBMIT_JOB, ops_state)
+    return self.CallMethod(REQ_SUBMIT_JOB, (ops_state, ))
 
   def SubmitManyJobs(self, jobs):
     jobs_state = []
     for ops in jobs:
       jobs_state.append([op.__getstate__() for op in ops])
-    return self.CallMethod(REQ_SUBMIT_MANY_JOBS, jobs_state)
+    return self.CallMethod(REQ_SUBMIT_MANY_JOBS, (jobs_state, ))
 
   def CancelJob(self, job_id):
     return self.CallMethod(REQ_CANCEL_JOB, (job_id, ))
diff --git a/lib/server/masterd.py b/lib/server/masterd.py
index 94c60f40f..67ea5ca7f 100644
--- a/lib/server/masterd.py
+++ b/lib/server/masterd.py
@@ -268,13 +268,15 @@ class ClientOps:
 
     if method == luxi.REQ_SUBMIT_JOB:
       logging.info("Received new job")
-      ops = [opcodes.OpCode.LoadOpCode(state) for state in args]
+      (job_def, ) = args
+      ops = [opcodes.OpCode.LoadOpCode(state) for state in job_def]
       return queue.SubmitJob(ops)
 
     if method == luxi.REQ_SUBMIT_MANY_JOBS:
       logging.info("Received multiple jobs")
+      (job_defs, ) = args
       jobs = []
-      for ops in args:
+      for ops in job_defs:
         jobs.append([opcodes.OpCode.LoadOpCode(state) for state in ops])
       return queue.SubmitManyJobs(jobs)
 
-- 
GitLab