Skip to content

Commit

Permalink
Add new parameter to /start, consistency. Supports -Ddse.consistent_r…
Browse files Browse the repository at this point in the history
…eplace=X
  • Loading branch information
burmanm committed Nov 25, 2024
1 parent 6476187 commit c7d969b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Changelog for Management API, new PRs should update the `main / unreleased` sect

## unreleased

* [ENHANCEMENT] [#574](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/574) Support consistency parameter in the /start when replacing a DSE node.

## v0.1.90 (2024-11-22)
* [FEATURE] [#566](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/566) Add listRoles and dropRole functionality to the REST interface
* [FEATURE] [#571](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/571) Add Cassandra 4.0.15 to the build matrix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean checkState() {
STATE currentState = getRequestedState();
logger.debug("Current Requested State is {}", currentState);
if (currentState != STATE.STOPPED) {
Response r = lifecycle.startNode(getActiveProfile(), null);
Response r = lifecycle.startNode(getActiveProfile(), null, null);
return r.getStatus() >= 200 && r.getStatus() < 300;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.Uninterruptibles;
import io.swagger.v3.oas.annotations.Hidden;
Expand Down Expand Up @@ -107,7 +108,9 @@ public LifecycleResources(ManagementApplication app) {
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = "error message")))
public synchronized Response startNode(
@QueryParam("profile") String profile, @QueryParam("replace_ip") String replaceIp) {
@QueryParam("profile") String profile,
@QueryParam("replace_ip") String replaceIp,
@QueryParam("replace_consistency") String consistency) {

// Todo we should add a CALL getPid command and compare;
boolean canConnect;
Expand Down Expand Up @@ -153,11 +156,20 @@ public synchronized Response startNode(

if (replaceIp != null) {
if (!replaceIp.matches(IPV4_PATTERN))
return Response.serverError()
return Response.status(HttpStatus.SC_BAD_REQUEST)
.entity(Entity.text("Invalid replace IP passed: " + replaceIp))
.build();

cmdArgs.add(String.format("-Dcassandra.replace_address_first_boot=%s", replaceIp));
if (!Strings.isNullOrEmpty(consistency)) {
if (app.dbExe.getAbsolutePath().endsWith("dse")) {
cmdArgs.add(String.format("-Ddse.consistent_replace=%s", consistency));
} else {
return Response.status(HttpStatus.SC_BAD_REQUEST)
.entity(Entity.text("Consistency parameter for replace is only accepted with DSE"))
.build();
}
}
}

// Delete stale file if it exists
Expand Down

0 comments on commit c7d969b

Please sign in to comment.