Skip to content

Commit

Permalink
Add Cassandra 4.1.6 to the build matrix (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
emerkle826 authored Aug 30, 2024
1 parent 1516901 commit 868dda4
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 38 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,52 @@ jobs:
-Drun${{ matrix.cassandra-version }}testsUBI \
-Dit.test=${{ matrix.itTest }} -DfailIfNoTests=false
test-oss-41:
# This job is inetnded to run the various versiosn of Cassandra 4.1 where internal changes to OSS code
# require Java refelction tricks in the Agent code.
name: Run Cassandra ${{ matrix.itTest }} [${{ matrix.cassandra-version }}, ${{ matrix.base-platform }}]
needs: build-oss-docker-images
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 16
matrix:
cassandra-version: ['4.1']
base-platform: ['ubuntu', 'ubi8']
itTest : ['Lifecycle412IT', 'Lifecycle415IT']
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'zulu'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-oss-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Build with Maven and run tests
if: ${{ matrix.base-platform == 'ubuntu' }}
run: |
mvn -B -q install -Dskip.surefire.tests --file pom.xml \
-Drun${{ matrix.cassandra-version }}tests \
-Dit.test=${{ matrix.itTest }} -DfailIfNoTests=false
- name: Build with Maven and run tests
if: ${{ matrix.base-platform != 'ubuntu' }}
run: |
mvn -B -q install -Dskip.surefire.tests --file pom.xml \
-Drun${{ matrix.cassandra-version }}testsUBI \
-Dit.test=${{ matrix.itTest }} -DfailIfNoTests=false
test-dse:
name: Run DSE ${{ matrix.itTest }} [${{ matrix.dse-version }}, ${{ matrix.base-platform }}]
# if: github.repository_owner == 'k8ssandra'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ jobs:
fail-fast: false
max-parallel: 4
matrix:
cassandra-version: [4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5]
cassandra-version: [4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5, 4.1.6]
include:
- cassandra-version: 4.1.5
- cassandra-version: 4.1.6
latest: true
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Changelog for Management API, new PRs should update the `main / unreleased` sect
## unreleased
* [FEATURE] [#523](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/517) Trust store reload functionality for DSE only (not Cassandra)
* [FEATURE] [#517](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/517) Add DSE 6.9.0 to the build matrix
* [FEATURE] [#523](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/523) Trust store reload functionality for DSE only (not Cassandra)
* [FEATURE] [#527](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/527) Add Cassandra 4.1.6 to the build matrix
* [ENHANCEMENT] [#516](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/516) Address warnings in Dockerfiles
* [ENHANCEMENT] [#521](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/521) Add management-api to Cassandra conf in the Dockerfile, not entrypoint for DSE 6.9, Cassandra 4.1 and Cassandra 5.0. This allows to run the container with readOnlyRootFilesystem.
* [BUGFIX] [#524](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/524) Fix HintsService Hint_delays- metrics parsing and ReadCoordination metrics parsing
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The following versions of Cassandra and DSE are published to Docker and supporte
| 3.11.12 | 4.0.4 | 4.1.3 | 6.8.29 | |
| 3.11.13 | 4.0.5 | 4.1.4 | 6.8.30 | |
| 3.11.14 | 4.0.6 | 4.1.5 | 6.8.31 | |
| 3.11.15 | 4.0.7 | | 6.8.32 | |
| 3.11.15 | 4.0.7 | 4.1.6 | 6.8.32 | |
| 3.11.16 | 4.0.8 | | 6.8.33 | |
| 3.11.17 | 4.0.9 | | 6.8.34 | |
| | 4.0.10 | | 6.8.35 | |
Expand Down
2 changes: 1 addition & 1 deletion cassandra/Dockerfile-4.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG CASSANDRA_VERSION=4.1.5
ARG CASSANDRA_VERSION=4.1.6

FROM --platform=$BUILDPLATFORM maven:3.8.7-eclipse-temurin-11 AS builder

Expand Down
2 changes: 1 addition & 1 deletion cassandra/Dockerfile-4.1.ubi8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG UBI_MAJOR=8
ARG UBI_BASETAG=latest
ARG CASSANDRA_VERSION=4.1.5
ARG CASSANDRA_VERSION=4.1.6
FROM registry.access.redhat.com/ubi${UBI_MAJOR}/ubi-minimal:${UBI_BASETAG} AS builder

ARG URL_PREFIX=https://dlcdn.apache.org/cassandra
Expand Down
2 changes: 1 addition & 1 deletion management-api-agent-4.1.x/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<version>${revision}</version>
<artifactId>datastax-mgmtapi-agent-4.1.x</artifactId>
<properties>
<cassandra4.version>4.1.5</cassandra4.version>
<cassandra4.version>4.1.6</cassandra4.version>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.cassandra.cql3.QueryOptions;
import org.apache.cassandra.service.ClientState;
import org.apache.cassandra.service.QueryState;
import org.apache.cassandra.transport.Dispatcher.RequestTime;
import org.apache.cassandra.transport.messages.ResultMessage;

public class RpcStatement41x implements RpcStatementShim {
Expand All @@ -27,11 +28,22 @@ public void authorize(ClientState clientState) {}
@Override
public void validate(ClientState clientState) {}

@Override
/**
* as of Cassandra 4.1.6, CASSANDRA-19534, org.apache.cassandra.cql3.CQLStatement no longer has
* the method signature below, so we need to remove the @Override annotation.
*/
public ResultMessage execute(QueryState queryState, QueryOptions queryOptions, long l) {
return new ResultMessage.Void();
}

/**
* as of Cassandra 4.1.6, CASSANDRA-19534, org.apache.cassandra.cql3.CQLStatement now has the
* method signature below, but it does not exist in Cassandra < 4.1.6.
*/
public ResultMessage execute(QueryState queryState, QueryOptions queryOptions, RequestTime rt) {
return new ResultMessage.Void();
}

@Override
public ResultMessage executeLocally(QueryState queryState, QueryOptions queryOptions) {
return new ResultMessage.Void();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,33 @@ protected void channelRead0(ChannelHandlerContext ctx, Message.Request request)
// logger.info("Executing {} {} {}", request, connection.getVersion(),
// request.getStreamId());

Message.Response r = request.execute(qstate, queryStartNanoTime);
// In Cassandra 4.1.6, CASSANDRA-19534 changed the Message.Request.execute method signature
// to take a new Dispatcher.RequestTime object instead of a primitive long for the Query
// start time. We'll need to introduce reflection here to create the correct Objects and
// make the correct calls based on which version of 4.1.x we are.
Message.Response r = null;
try {
// First see if we have the Dispatcher.RequestTime class. If so, assume we are 4.1.6+
Class dispatcherRequestTime =
Class.forName("org.apache.cassandra.transport.Dispatcher$RequestTime");
// we are 4.1.6+, get Dispatcher.RequestTime.forImmediateExecution()
Method forImmediateExecution =
dispatcherRequestTime.getDeclaredMethod("forImmediateExecution");
Method requestExecute =
Message.Request.class.getDeclaredMethod(
"execute", QueryState.class, dispatcherRequestTime);
r =
(Message.Response)
requestExecute.invoke(request, qstate, forImmediateExecution.invoke(null));

} catch (ClassNotFoundException cfne) {
logger.debug(
"Dispatcher$RequestTime in 4.1.6+ not found, trying Request.execute from older versions");
// we must be 4.1.5-
Method requestExecute =
Message.Request.class.getDeclaredMethod("execute", QueryState.class, long.class);
r = (Message.Response) requestExecute.invoke(request, qstate, queryStartNanoTime);
}

// UnixSocket has no auth
response = r instanceof AuthenticateMessage ? new ReadyMessage() : r;
Expand Down Expand Up @@ -291,49 +317,73 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> ou
// add CASSANDRA-15241 (https://issues.apache.org/jira/browse/CASSANDRA-15241). To
// avoid splitting the 4.1 agent based on which version of Cassandra it runs with,
// we'll use reflection here to determine the correct method to invoke.
Method processRequestMethod = null;
boolean requiresStartTime = false;

// In Cassandra 4.1.6, Dispatcher.processRequest method signatures changed again for
// CASSANDRA-19534. The long value for start time was replaced by RequestTime
Message.Response response = null;
try {
// try to get the Cassandra 4.1.3+ method
processRequestMethod =
// try to see if the 4.1.6+ object RequestTime exists
Class dispatcherRequestTime =
Class.forName("org.apache.cassandra.transport.Dispatcher$RequestTime");
// it's 4.1.6+, get Dispatcher.RequestTime.forImmediateExecution()
Method forImmediateExecution =
dispatcherRequestTime.getDeclaredMethod("forImmediateExecution");
Method processRequestMethod =
Dispatcher.class.getDeclaredMethod(
"processRequest",
Channel.class,
Message.Request.class,
Overload.class,
long.class);
// 4.1.3 method found so we'll need to invoke it with a start time
requiresStartTime = true;
} catch (NoSuchMethodException ex) {
// 4.1.3+ method doesn't existy, try 4.1.2- method
logger.debug(
"Cassandra Dispatcher.processRequest() for 4.1.3 not found, trying 4.1.2 method");
try {
processRequestMethod =
Dispatcher.class.getDeclaredMethod(
"processRequest", Channel.class, Message.Request.class, Overload.class);
} catch (NoSuchMethodException ex2) {
// something is broken, need to figure out what method/signature should be used
logger.error(
"Expected Cassandra Dispatcher.processRequest() method signature not found. Management API agent will not be able to start Cassandra.",
ex2);
throw ex2;
}
}
Message.Response response;
if (requiresStartTime) {
dispatcherRequestTime);
response =
(Message.Response)
processRequestMethod.invoke(
null,
ctx.channel(),
startup,
Overload.NONE,
MonotonicClock.Global.approxTime.now());
} else {
response =
(Message.Response)
processRequestMethod.invoke(null, ctx.channel(), startup, Overload.NONE);
forImmediateExecution.invoke(null));

} catch (ClassNotFoundException cnfe) {
logger.debug(
"Dispatcher$RequestTime in 4.1.6+ not found, trying Dispatcher.processRequest from older versions");
try {
// try to get the Cassandra 4.1.3+ method
Method processRequestMethod =
Dispatcher.class.getDeclaredMethod(
"processRequest",
Channel.class,
Message.Request.class,
Overload.class,
long.class);
// 4.1.3 method found so we'll need to invoke it with a start time
response =
(Message.Response)
processRequestMethod.invoke(
null,
ctx.channel(),
startup,
Overload.NONE,
MonotonicClock.Global.approxTime.now());
} catch (NoSuchMethodException ex) {
// 4.1.3+ method doesn't existy, try 4.1.2- method
logger.debug(
"Cassandra Dispatcher.processRequest() for 4.1.3 not found, trying 4.1.2 method");
try {
Method processRequestMethod =
Dispatcher.class.getDeclaredMethod(
"processRequest", Channel.class, Message.Request.class, Overload.class);
response =
(Message.Response)
processRequestMethod.invoke(null, ctx.channel(), startup, Overload.NONE);
} catch (NoSuchMethodException ex2) {
// something is broken, need to figure out what method/signature should be used
logger.error(
"Expected Cassandra Dispatcher.processRequest() method signature not found. Management API agent will not be able to start Cassandra.",
ex2);
throw ex2;
}
}
}

if (response.type.equals(Message.Type.AUTHENTICATE))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright DataStax, Inc.
*
* Please see the included license file for details.
*/
package com.datastax.mgmtapi;

import java.io.IOException;
import java.util.ArrayList;

public class Lifecycle412IT extends LifecycleIT {

public Lifecycle412IT(String version) throws IOException {
super(version);
}
/**
* Override environment variables to specify the version of Cassandra to be used. For the test in
* here, we want Cassandra 4.1.2 to test pre-4.1.3 changes.
*
* @return A list of Docker build environment variables.
*/
@Override
protected ArrayList<String> getImageBuildArgs() {
ArrayList<String> list = super.getImageBuildArgs();
list.add("CASSANDRA_VERSION=4.1.2");
return list;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright DataStax, Inc.
*
* Please see the included license file for details.
*/
package com.datastax.mgmtapi;

import java.io.IOException;
import java.util.ArrayList;

public class Lifecycle415IT extends LifecycleIT {

public Lifecycle415IT(String version) throws IOException {
super(version);
}
/**
* Override environment variables to specify the version of Cassandra to be used. For the test in
* here, we want Cassandra 4.1.5 to test post-4.1.3 changes through pre-4.1.6 changes.
*
* @return A list of Docker build environment variables.
*/
@Override
protected ArrayList<String> getImageBuildArgs() {
ArrayList<String> list = super.getImageBuildArgs();
list.add("CASSANDRA_VERSION=4.1.5");
return list;
}
}

0 comments on commit 868dda4

Please sign in to comment.