Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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;
Expand All @@ -43,6 +42,10 @@
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>
Expand Down Expand Up @@ -113,15 +116,13 @@ protected void handleInternal(RoutingContext routingContext, HttpServerRequest h
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."));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

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;
Expand All @@ -37,6 +36,9 @@
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>
Expand Down Expand Up @@ -73,9 +75,8 @@ protected void handleInternal(RoutingContext routingContext, HttpServerRequest h
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void testUpdatingStatusSecondTimeShouldFail(VertxTestContext context)
.send()
.compose(response -> {
assertThat(response.statusCode()).isEqualTo(HttpResponseStatus.BAD_REQUEST.code());
assertThat(response.bodyAsJsonObject()).isNotNull();
return Future.succeededFuture();
}))
.onSuccess(r -> context.completeNow())
Expand Down Expand Up @@ -251,6 +252,7 @@ void testCompleteStatusShouldNotSucceedWhenFetchingMigrationMapFails(VertxTestCo
.send()
.compose(response -> {
assertThat(response.statusCode()).isEqualTo(HttpResponseStatus.SERVICE_UNAVAILABLE.code());
assertThat(response.bodyAsJsonObject()).isNotNull();
return Future.succeededFuture();
})
.onSuccess(r -> context.completeNow())
Expand Down