Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Management API port configurable #418

Merged
merged 5 commits into from
Nov 7, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
cassandra-version: ['3.11', '4.0', '4.1', '3.11_ubi', '4.0_ubi', '4.1_ubi', '5.0_ubi']
itTest : ['LifecycleIT', 'KeepAliveIT', 'NonDestructiveOpsIT', 'DestructiveOpsIT', 'NonDestructiveOpsResourcesV2IT', 'DockerImageIT']
itTest : ['LifecycleIT', 'KeepAliveIT', 'NonDestructiveOpsIT', 'DestructiveOpsIT', 'NonDestructiveOpsResourcesV2IT', 'DockerImageIT', 'AsyncRepairIT', 'PortOverrideIT']
include:
- cassandra-version: '3.11'
run311tests: true
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
fail-fast: false
matrix:
platform-version: ['jdk8', 'ubi']
itTest : ['LifecycleIT', 'KeepAliveIT', 'NonDestructiveOpsIT', 'DestructiveOpsIT', 'DSESpecificIT', 'NonDestructiveOpsResourcesV2IT', 'DockerImageIT']
itTest : ['LifecycleIT', 'KeepAliveIT', 'NonDestructiveOpsIT', 'DestructiveOpsIT', 'DSESpecificIT', 'NonDestructiveOpsResourcesV2IT', 'DockerImageIT', 'AsyncRepairIT', 'PortOverrideIT']
include:
- platform-version: 'jdk8'
runDSEtests: true
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Changelog for Management API, new PRs should update the `main / unreleased` sect
## unreleased
* [BUGFIX] [#413](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/413) UBI8 images do not terminate correctly
* [BUGFIX] [#360](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/360) Support Cassandra 5.0-alpha1
* [FEATURE] [#398](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/398) Make Management API port configurable

## v0.1.70 (2023-10-17)
* [BUGFIX] [#411](https://github.com/k8ssandra/management-api-for-apache-cassandra/pull/411) Serialize long types as Strings to avoid float64 conversion
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ For building an image based on DSE 6.8, see the [DSE README](management-api-agen
> curl http://localhost:8080/api/v0/probes/readiness
OK

### Specifying an alternate listen port

By default, all images will listen on port 8080 for Management API connections. This can be overridden by specifying
the environment variable `MGMT_API_LISTEN_TCP_PORT` and setting it to your desired port. For example:

> docker run -e MGMT_API_LISTEN_TCP_PORT=9090 -p 9090:9090 k8ssandra/cass-management-api:3.11.15

The above would run a Cassandra 3.11.15 image with Management API listening on port 9090 (instead of 8080).

## Usage with DSE

Please see the [DSE README](management-api-agent-dse-6.8/README.md) for details.
Expand Down
105 changes: 0 additions & 105 deletions astra-4.0/Dockerfile

This file was deleted.

96 changes: 0 additions & 96 deletions astra-4.0/docker-entrypoint.sh

This file was deleted.

5 changes: 3 additions & 2 deletions cassandra-trunk/files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ if [ "$1" = 'mgmtapi' ]; then
fi

MGMT_API_ARGS=""

# set the listen port to 8080 if not already set
: ${MGMT_API_LISTEN_TCP_PORT='8080'}
# Hardcoding these for now
MGMT_API_CASSANDRA_SOCKET="--cassandra-socket /tmp/cassandra.sock"
MGMT_API_LISTEN_TCP="--host tcp://0.0.0.0:8080"
MGMT_API_LISTEN_TCP="--host tcp://0.0.0.0:${MGMT_API_LISTEN_TCP_PORT}"
MGMT_API_LISTEN_SOCKET="--host file:///tmp/oss-mgmt.sock"

MGMT_API_ARGS="$MGMT_API_ARGS $MGMT_API_CASSANDRA_SOCKET $MGMT_API_LISTEN_TCP $MGMT_API_LISTEN_SOCKET"
Expand Down
7 changes: 3 additions & 4 deletions dse-68/Dockerfile.ubi8
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,15 @@ COPY --from=dse-server-base /etc/gshadow /etc/gshadow

# Copy trimmed installation
COPY --chown=dse:root --from=dse-server-base ${DSE_HOME} ${DSE_HOME}
COPY --chown=dse:root --from=dse-server-base /entrypoint.sh /entrypoint.sh
COPY --chown=dse:root --from=dse-server-base /overwritable-conf-files /overwritable-conf-files
COPY --chown=dse:root --from=dse-server-base /base-checks.sh /base-checks.sh

# Copy license in to appropriate directory
COPY --from=dse-server-base /LICENSE /licenses/

# Replace bin/cassandra with modified that doesn't hang in k8s
COPY dse-68/files/cassandra ${DSE_HOME}/resources/cassandra/bin/cassandra

COPY --chown=dse:root dse-68/files/cassandra ${DSE_HOME}/resources/cassandra/bin/cassandra
COPY --chown=dse:root dse-68/files/entrypoint.sh /entrypoint.sh
copy --chown=dse:root dse-68/files/overwritable-conf-files /overwritable-conf-files
# Update permissions and build directories
RUN chmod 0555 /entrypoint.sh /overwritable-conf-files /licenses /base-checks.sh && \
(for dir in /var/lib/cassandra \
Expand Down
5 changes: 3 additions & 2 deletions dse-68/files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ if [ "$USE_MGMT_API" = "true" ] && [ -d "$MAAC_PATH" ] ; then
fi

MGMT_API_ARGS=""

# set the listen port to 8080 if not already set
: ${MGMT_API_LISTEN_TCP_PORT='8080'}
# Hardcoding these for now
DSE_MGMT_DSE_SOCKET="--db-socket /tmp/dse.sock"
DSE_MGMT_LISTEN_TCP="--host tcp://0.0.0.0:8080"
DSE_MGMT_LISTEN_TCP="--host tcp://0.0.0.0:${MGMT_API_LISTEN_TCP_PORT}"
DSE_MGMT_LISTEN_SOCKET="--host file:///tmp/dse-mgmt.sock"

MGMT_API_ARGS="$MGMT_API_ARGS $DSE_MGMT_DSE_SOCKET $DSE_MGMT_LISTEN_TCP $DSE_MGMT_LISTEN_SOCKET"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright DataStax, Inc.
*
* Please see the included license file for details.
*/
package com.datastax.mgmtapi;

import static com.datastax.mgmtapi.BaseDockerIntegrationTest.BASE_PATH;
import static com.datastax.mgmtapi.BaseDockerIntegrationTest.BASE_PATH_V1;
import static com.datastax.mgmtapi.BaseDockerIntegrationTest.BASE_URL;
import static com.datastax.mgmtapi.BaseDockerIntegrationTest.JSON_MAPPER;
import static com.datastax.mgmtapi.NonDestructiveOpsIT.ensureStarted;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertFalse;
import static org.junit.Assume.assumeTrue;

import com.datastax.mgmtapi.helpers.IntegrationTestUtils;
import com.datastax.mgmtapi.helpers.NettyHttpClient;
import com.datastax.mgmtapi.resources.models.Job;
import com.datastax.mgmtapi.resources.models.RepairRequest;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.json.JsonMapper;
import io.netty.util.IllegalReferenceCountException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.Duration;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

@RunWith(Parameterized.class)
public class AsyncRepairIT extends BaseDockerIntegrationTest {

public AsyncRepairIT(String version) throws IOException {
super(version);
}

@Test
public void testAsyncRepair() throws IOException, URISyntaxException, InterruptedException {
assumeTrue(IntegrationTestUtils.shouldRun());
ensureStarted();

// create a keyspace with RF of at least 2
NettyHttpClient client = new NettyHttpClient(BASE_URL);
String localDc =
client
.get(new URIBuilder(BASE_PATH + "/metadata/localdc").build().toURL())
.thenApply(this::responseAsString)
.join();

String ks = "someTestKeyspace";
createKeyspace(client, localDc, ks, 2);

URIBuilder uriBuilder = new URIBuilder(BASE_PATH_V1 + "/ops/node/repair");
URI repairUri = uriBuilder.build();

// execute repair
RepairRequest repairRequest = new RepairRequest("someTestKeyspace", null, Boolean.TRUE);
String requestAsJSON = JSON_MAPPER.writeValueAsString(repairRequest);

Pair<Integer, String> repairResponse =
client.post(repairUri.toURL(), requestAsJSON).thenApply(this::responseAsCodeAndBody).join();
assertThat(repairResponse.getLeft()).isEqualTo(HttpStatus.SC_ACCEPTED);
String jobId = repairResponse.getRight();
assertThat(jobId).isNotEmpty();

URI getJobDetailsUri =
new URIBuilder(BASE_PATH + "/ops/executor/job").addParameter("job_id", jobId).build();

await()
.atMost(Duration.ofMinutes(5))
.untilAsserted(
() -> {
Pair<Integer, String> getJobDetailsResponse;
try {
getJobDetailsResponse =
client
.get(getJobDetailsUri.toURL())
.thenApply(this::responseAsCodeAndBody)
.join();
} catch (IllegalReferenceCountException e) {
// Just retry
assertFalse(true);
return;
}
assertThat(getJobDetailsResponse.getLeft()).isEqualTo(HttpStatus.SC_OK);
Job jobDetails =
new JsonMapper()
.readValue(getJobDetailsResponse.getRight(), new TypeReference<Job>() {});
assertThat(jobDetails.getJobId()).isEqualTo(jobId);
assertThat(jobDetails.getJobType()).isEqualTo("repair");
assertThat(jobDetails.getStatus().toString()).isIn("COMPLETED", "ERROR");
});
}
}
Loading