You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by fr...@apache.org on 2026/01/07 19:22:23 UTC
(cassandra-sidecar) branch trunk updated: CASSSIDECAR-395: Returning JSON response for live migration status endpoints when returning error status codes (#307)
This is an automated email from the ASF dual-hosted git repository.
frankgh pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-sidecar.git
The following commit(s) were added to refs/heads/trunk by this push:
new 2d1444ff CASSSIDECAR-395: Returning JSON response for live migration status endpoints when returning error status codes (#307)
2d1444ff is described below
commit 2d1444ff355c9953bbaecd36405a1c3d93c384d0
Author: N V Harikrishna <n....@gmail.com>
AuthorDate: Thu Jan 8 00:52:17 2026 +0530
CASSSIDECAR-395: Returning JSON response for live migration status endpoints when returning error status codes (#307)
Patch by N V Harikrishna; reviewed by Francisco Guerrero, Yifan Cai for CASSSIDECAR-395
---
CHANGES.txt | 1 +
.../livemigration/LiveMigrationStatusCompleteHandler.java | 15 ++++++++-------
.../livemigration/LiveMigrationStatusGetHandler.java | 9 +++++----
.../livemigration/LiveMigrationStatusHandlersTest.java | 2 ++
4 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 6ddd84af..46ffa359 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
0.3.0
-----
+ * Returning JSON responses for live migration status endpoints in case of errors (CASSSIDECAR-395)
* Upgrade vertx to 4.5.23 (CASSSIDECAR-391)
* Fix for deadlock during JMX reconnection (CASSSIDECAR-390)
* Fix request execution continues on wrong thread (CASSSIDECAR-368)
diff --git a/server/src/main/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusCompleteHandler.java b/server/src/main/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusCompleteHandler.java
index 75e3d3cb..e319d8cb 100644
--- a/server/src/main/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusCompleteHandler.java
+++ b/server/src/main/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusCompleteHandler.java
@@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.core.Future;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.json.Json;
@@ -43,6 +42,10 @@ import org.apache.cassandra.sidecar.utils.CassandraInputValidator;
import org.apache.cassandra.sidecar.utils.InstanceMetadataFetcher;
import org.jetbrains.annotations.NotNull;
+import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
+import static io.netty.handler.codec.http.HttpResponseStatus.SERVICE_UNAVAILABLE;
+import static org.apache.cassandra.sidecar.utils.HttpExceptions.wrapHttpException;
+
/**
* Handler to safely mark a live migration as COMPLETED for an instance.
* <p>
@@ -113,15 +116,13 @@ public class LiveMigrationStatusCompleteHandler extends AbstractHandler<Void> im
instanceMetadata.host(), e);
if (e instanceof IllegalStateException)
{
- routingContext.response()
- .setStatusCode(HttpResponseStatus.BAD_REQUEST.code())
- .end("Live migration marked as COMPLETED earlier.");
+ routingContext.fail(wrapHttpException(BAD_REQUEST,
+ "Live migration marked as COMPLETED earlier."));
}
else
{
- routingContext.response()
- .setStatusCode(HttpResponseStatus.SERVICE_UNAVAILABLE.code())
- .end("Could not update Live Migration as complete.");
+ routingContext.fail(wrapHttpException(SERVICE_UNAVAILABLE,
+ "Could not update Live Migration as complete."));
}
});
}
diff --git a/server/src/main/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusGetHandler.java b/server/src/main/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusGetHandler.java
index 9cee6ad0..e2974a59 100644
--- a/server/src/main/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusGetHandler.java
+++ b/server/src/main/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusGetHandler.java
@@ -22,7 +22,6 @@ import java.util.Set;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.net.SocketAddress;
import io.vertx.ext.auth.authorization.Authorization;
@@ -37,6 +36,9 @@ import org.apache.cassandra.sidecar.utils.CassandraInputValidator;
import org.apache.cassandra.sidecar.utils.InstanceMetadataFetcher;
import org.jetbrains.annotations.NotNull;
+import static io.netty.handler.codec.http.HttpResponseStatus.SERVICE_UNAVAILABLE;
+import static org.apache.cassandra.sidecar.utils.HttpExceptions.wrapHttpException;
+
/**
* Handler to retrieve the current live migration status for an instance.
* <p>
@@ -73,9 +75,8 @@ public class LiveMigrationStatusGetHandler extends AbstractHandler<Void> impleme
InstanceMetadata instance = metadataFetcher.instance(host);
statusTracker.getMigrationStatus(instance)
.compose(routingContext::json)
- .onFailure(e -> routingContext.response()
- .setStatusCode(HttpResponseStatus.SERVICE_UNAVAILABLE.code())
- .end(e.getMessage()));
+ .onFailure(e -> routingContext.fail(wrapHttpException(SERVICE_UNAVAILABLE,
+ e.getMessage())));
}
@Override
diff --git a/server/src/test/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusHandlersTest.java b/server/src/test/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusHandlersTest.java
index 7f9bf810..dcf4d74d 100644
--- a/server/src/test/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusHandlersTest.java
+++ b/server/src/test/java/org/apache/cassandra/sidecar/handlers/livemigration/LiveMigrationStatusHandlersTest.java
@@ -164,6 +164,7 @@ class LiveMigrationStatusHandlersTest
.send()
.compose(response -> {
assertThat(response.statusCode()).isEqualTo(HttpResponseStatus.BAD_REQUEST.code());
+ assertThat(response.bodyAsJsonObject()).isNotNull();
return Future.succeededFuture();
}))
.onSuccess(r -> context.completeNow())
@@ -251,6 +252,7 @@ class LiveMigrationStatusHandlersTest
.send()
.compose(response -> {
assertThat(response.statusCode()).isEqualTo(HttpResponseStatus.SERVICE_UNAVAILABLE.code());
+ assertThat(response.bodyAsJsonObject()).isNotNull();
return Future.succeededFuture();
})
.onSuccess(r -> context.completeNow())
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org