You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2014/11/07 23:09:38 UTC
incubator-aurora git commit: Fixing beta-update OK status messaging.
Repository: incubator-aurora
Updated Branches:
refs/heads/master afee887af -> 03cb0d181
Fixing beta-update OK status messaging.
Bugs closed: AURORA-784
Reviewed at https://reviews.apache.org/r/27712/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/03cb0d18
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/03cb0d18
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/03cb0d18
Branch: refs/heads/master
Commit: 03cb0d181e4a779f26eac370b267e92979717a49
Parents: afee887
Author: Maxim Khutornenko <ma...@apache.org>
Authored: Fri Nov 7 14:09:16 2014 -0800
Committer: Maxim Khutornenko <ma...@apache.org>
Committed: Fri Nov 7 14:09:16 2014 -0800
----------------------------------------------------------------------
.../thrift/SchedulerThriftInterface.java | 5 +-
.../python/apache/aurora/client/cli/context.py | 9 +++-
.../python/apache/aurora/client/cli/jobs.py | 2 +-
.../python/apache/aurora/client/cli/quota.py | 2 +-
.../python/apache/aurora/client/cli/update.py | 29 ++++++-----
.../thrift/SchedulerThriftInterfaceTest.java | 7 ++-
.../apache/aurora/client/cli/test_supdate.py | 52 ++++++++++++++------
7 files changed, 73 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/03cb0d18/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index 175bba2..b2b66ac 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -1415,7 +1415,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
settings.getUpdateOnlyTheseInstances());
if (diff.isNoop()) {
- return addMessage(emptyResponse(), OK, "Job is unchanged by proposed update.");
+ return addMessage(emptyResponse(), OK, NOOP_JOB_UPDATE_MESSAGE);
}
Set<Integer> invalidScope = diff.getOutOfScopeInstances(
@@ -1572,6 +1572,9 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
@VisibleForTesting
static final String NO_TASKS_TO_KILL_MESSAGE = "No tasks to kill.";
+ @VisibleForTesting
+ static final String NOOP_JOB_UPDATE_MESSAGE = "Job is unchanged by proposed update.";
+
private static Response okEmptyResponse() {
return emptyResponse().setResponseCode(OK);
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/03cb0d18/src/main/python/apache/aurora/client/cli/context.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/context.py b/src/main/python/apache/aurora/client/cli/context.py
index 0a3c223..a5ebbdc 100644
--- a/src/main/python/apache/aurora/client/cli/context.py
+++ b/src/main/python/apache/aurora/client/cli/context.py
@@ -124,7 +124,12 @@ class AuroraCommandContext(Context):
self.open_page(synthesize_url(api.scheduler_proxy.scheduler_client().url,
role, env, name))
- def display_response_to_user(self, resp):
+ def print_out_response_details(self, resp):
+ if resp.details is not None:
+ for m in resp.details:
+ self.print_out(m.message)
+
+ def log_response(self, resp):
if resp.responseCode != ResponseCode.OK:
for m in resp.details:
self.print_err("\t%s" % m.message)
@@ -138,7 +143,7 @@ class AuroraCommandContext(Context):
if err_msg is None:
err_msg = resp.messageDEPRECATED
self.print_err(err_msg)
- self.display_response_to_user(resp)
+ self.log_response(resp)
if resp.responseCode != ResponseCode.OK:
raise self.CommandError(err_code, err_msg)
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/03cb0d18/src/main/python/apache/aurora/client/cli/jobs.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/jobs.py b/src/main/python/apache/aurora/client/cli/jobs.py
index b4d9360..28f9475 100644
--- a/src/main/python/apache/aurora/client/cli/jobs.py
+++ b/src/main/python/apache/aurora/client/cli/jobs.py
@@ -328,7 +328,7 @@ class AbstractKillCommand(Verb):
if resp.responseCode is not ResponseCode.OK or self.wait_kill_tasks(
context, api.scheduler_proxy, job, batch) is not EXIT_OK:
context.print_err("Kill of shards %s failed with error:" % batch)
- context.display_response_to_user(resp)
+ context.log_response(resp)
errors += 1
if errors > context.options.max_total_failures:
context.print_err("Exceeded maximum number of errors while killing instances")
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/03cb0d18/src/main/python/apache/aurora/client/cli/quota.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/quota.py b/src/main/python/apache/aurora/client/cli/quota.py
index 3130bfb..137aab1 100644
--- a/src/main/python/apache/aurora/client/cli/quota.py
+++ b/src/main/python/apache/aurora/client/cli/quota.py
@@ -76,7 +76,7 @@ class GetQuotaCmd(Verb):
(cluster, role) = context.options.role
api = context.get_api(cluster)
resp = api.get_quota(role)
- context.display_response_to_user(resp)
+ context.log_response(resp)
if resp.responseCode == ResponseCode.ERROR:
raise context.CommandError(EXIT_INVALID_PARAMETER, 'Role %s not found' % role)
elif resp.responseCode == ResponseCode.INVALID_REQUEST:
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/03cb0d18/src/main/python/apache/aurora/client/cli/update.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/update.py b/src/main/python/apache/aurora/client/cli/update.py
index 0797e30..3076392 100644
--- a/src/main/python/apache/aurora/client/cli/update.py
+++ b/src/main/python/apache/aurora/client/cli/update.py
@@ -74,8 +74,12 @@ class StartUpdate(Verb):
api = context.get_api(config.cluster())
resp = api.start_job_update(config, instances)
context.check_and_log_response(resp, err_code=EXIT_API_ERROR,
- err_msg="Failed to start scheduler-driven update due to error:")
- context.print_out("Scheduler-driven update of job %s has started." % job)
+ err_msg="Failed to start update due to error:")
+
+ if resp.result:
+ context.print_out("Job update has started.")
+ else:
+ context.print_out_response_details(resp)
return EXIT_OK
@@ -98,8 +102,8 @@ class PauseUpdate(Verb):
api = context.get_api(jobkey.cluster)
resp = api.pause_job_update(jobkey)
context.check_and_log_response(resp, err_code=EXIT_API_ERROR,
- err_msg="Failed to pause scheduler-driven update due to error:")
- context.print_out("Scheduler-driven update of job %s has been paused." % jobkey)
+ err_msg="Failed to pause update due to error:")
+ context.print_out("Update has been paused.")
return EXIT_OK
@@ -122,8 +126,8 @@ class ResumeUpdate(Verb):
api = context.get_api(jobkey.cluster)
resp = api.resume_job_update(jobkey)
context.check_and_log_response(resp, err_code=EXIT_API_ERROR,
- err_msg="Failed to resume scheduler-driven update due to error:")
- context.print_out("Scheduler-driven update of job %s has been resumed." % jobkey)
+ err_msg="Failed to resume update due to error:")
+ context.print_out("Update has been resumed.")
return EXIT_OK
@@ -139,15 +143,15 @@ class AbortUpdate(Verb):
@property
def help(self):
- return """Abort an in-pregress scheduler-driven rolling update."""
+ return """Abort an in-progress scheduler-driven rolling update."""
def execute(self, context):
jobkey = context.options.jobspec
api = context.get_api(jobkey.cluster)
resp = api.abort_job_update(jobkey)
context.check_and_log_response(resp, err_code=EXIT_API_ERROR,
- err_msg="Failed to abort scheduler-driven update due to error:")
- context.print_out("Scheduler-driven update of job %s has been aborted." % jobkey)
+ err_msg="Failed to abort update due to error:")
+ context.print_out("Update has been aborted.")
return EXIT_OK
@@ -171,7 +175,10 @@ class ListUpdates(Verb):
@property
def help(self):
- return """List all jobs updates, with summary info, about active updates that match a query."""
+ return textwrap.dedent("""\
+ List all scheduler-driven jobs updates, with summary info, about active updates
+ that match a query.
+ """)
def execute(self, context):
api = context.get_api(context.options.cluster)
@@ -217,7 +224,7 @@ class UpdateStatus(Verb):
@property
def help(self):
- return """Display detailed status information about an in-progress update."""
+ return """Display detailed status information about a scheduler-driven in-progress update."""
def _get_update_id(self, context, jobkey):
api = context.get_api(context.options.jobspec.cluster)
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/03cb0d18/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index b42f6e2..5c9ea6c 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -163,6 +163,7 @@ import static org.apache.aurora.scheduler.quota.QuotaCheckResult.Result.INSUFFIC
import static org.apache.aurora.scheduler.quota.QuotaCheckResult.Result.SUFFICIENT_QUOTA;
import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.MAX_TASKS_PER_JOB;
import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.MAX_TASK_ID_LENGTH;
+import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.NOOP_JOB_UPDATE_MESSAGE;
import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.killedByMessage;
import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.restartedByMessage;
import static org.apache.aurora.scheduler.thrift.SchedulerThriftInterface.transitionMessage;
@@ -2470,7 +2471,11 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
control.replay();
JobUpdateRequest request = buildJobUpdateRequest(update);
- assertResponse(OK, thrift.startJobUpdate(request, SESSION));
+ Response response = thrift.startJobUpdate(request, SESSION);
+ assertResponse(OK, response);
+ assertEquals(
+ NOOP_JOB_UPDATE_MESSAGE,
+ Iterables.getOnlyElement(response.getDetails()).getMessage());
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/03cb0d18/src/test/python/apache/aurora/client/cli/test_supdate.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_supdate.py b/src/test/python/apache/aurora/client/cli/test_supdate.py
index 8943f8c..09f6a85 100644
--- a/src/test/python/apache/aurora/client/cli/test_supdate.py
+++ b/src/test/python/apache/aurora/client/cli/test_supdate.py
@@ -37,7 +37,9 @@ from gen.apache.aurora.api.ttypes import (
JobUpdateSummary,
Response,
ResponseCode,
- Result
+ ResponseDetail,
+ Result,
+ StartJobUpdateResult
)
@@ -45,11 +47,13 @@ class TestUpdateCommand(AuroraClientCommandTest):
def test_start_update_command_line_succeeds(self):
mock_context = FakeAuroraCommandContext()
+ resp = self.create_simple_success_response()
+ resp.result = Result(startJobUpdateResult=StartJobUpdateResult(updateId="id"))
with contextlib.nested(
patch('apache.aurora.client.cli.update.Update.create_context', return_value=mock_context),
patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
mock_api = mock_context.get_api('west')
- mock_api.start_job_update.return_value = self.create_simple_success_response()
+ mock_api.start_job_update.return_value = resp
with temporary_file() as fp:
fp.write(self.get_valid_config())
fp.flush()
@@ -61,8 +65,30 @@ class TestUpdateCommand(AuroraClientCommandTest):
args, kwargs = mock_api.start_job_update.call_args
assert isinstance(args[0], AuroraConfig)
assert args[1] is None
- assert mock_context.get_out() == [
- "Scheduler-driven update of job west/bozo/test/hello has started."]
+ assert mock_context.get_out() == ["Job update has started."]
+ assert mock_context.get_err() == []
+
+ def test_start_update_command_line_succeeds_noop_update(self):
+ mock_context = FakeAuroraCommandContext()
+ resp = self.create_simple_success_response()
+ resp.details = [ResponseDetail(message="Noop update.")]
+ with contextlib.nested(
+ patch('apache.aurora.client.cli.update.Update.create_context', return_value=mock_context),
+ patch('apache.aurora.client.factory.CLUSTERS', new=self.TEST_CLUSTERS)):
+ mock_api = mock_context.get_api('west')
+ mock_api.start_job_update.return_value = resp
+ with temporary_file() as fp:
+ fp.write(self.get_valid_config())
+ fp.flush()
+ cmd = AuroraCommandLine()
+ result = cmd.execute(['beta-update', 'start', self.TEST_JOBSPEC, fp.name])
+ assert result == EXIT_OK
+
+ assert mock_api.start_job_update.call_count == 1
+ args, kwargs = mock_api.start_job_update.call_args
+ assert isinstance(args[0], AuroraConfig)
+ assert args[1] is None
+ assert mock_context.get_out() == ["Noop update."]
assert mock_context.get_err() == []
def test_pause_update_command_line_succeeds(self):
@@ -80,8 +106,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
assert result == EXIT_OK
mock_api.pause_job_update.assert_called_with(self.TEST_JOBKEY)
- assert mock_context.get_out() == [
- "Scheduler-driven update of job west/bozo/test/hello has been paused."]
+ assert mock_context.get_out() == ["Update has been paused."]
assert mock_context.get_err() == []
def test_abort_update_command_line_succeeds(self):
@@ -99,8 +124,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
assert result == EXIT_OK
mock_api.abort_job_update.assert_called_with(self.TEST_JOBKEY)
- assert mock_context.get_out() == [
- "Scheduler-driven update of job west/bozo/test/hello has been aborted."]
+ assert mock_context.get_out() == ["Update has been aborted."]
assert mock_context.get_err() == []
def test_resume_update_command_line_succeeds(self):
@@ -118,8 +142,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
assert result == EXIT_OK
mock_api.resume_job_update.assert_called_with(self.TEST_JOBKEY)
- assert mock_context.get_out() == [
- "Scheduler-driven update of job west/bozo/test/hello has been resumed."]
+ assert mock_context.get_out() == ["Update has been resumed."]
def test_update_invalid_config(self):
mock_context = FakeAuroraCommandContext()
@@ -151,8 +174,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
mock_api.resume_job_update.assert_called_with(self.TEST_JOBKEY)
assert mock_context.get_out() == []
- assert mock_context.get_err() == [
- "Failed to resume scheduler-driven update due to error:", "\tDamn"]
+ assert mock_context.get_err() == ["Failed to resume update due to error:", "\tDamn"]
def test_abort_update_command_line_error(self):
mock_context = FakeAuroraCommandContext()
@@ -170,8 +192,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
mock_api.abort_job_update.assert_called_with(self.TEST_JOBKEY)
assert mock_context.get_out() == []
- assert mock_context.get_err() == [
- "Failed to abort scheduler-driven update due to error:", "\tDamn"]
+ assert mock_context.get_err() == ["Failed to abort update due to error:", "\tDamn"]
def test_pause_update_command_line_error(self):
mock_context = FakeAuroraCommandContext()
@@ -189,8 +210,7 @@ class TestUpdateCommand(AuroraClientCommandTest):
mock_api.pause_job_update.assert_called_with(self.TEST_JOBKEY)
assert mock_context.get_out() == []
- assert mock_context.get_err() == [
- "Failed to pause scheduler-driven update due to error:", "\tDamn"]
+ assert mock_context.get_err() == ["Failed to pause update due to error:", "\tDamn"]
@classmethod
def get_status_query_response(cls):