Skip to content

Commit

Permalink
[FLINK-36332] Add option to select the Fabric8 httpclient implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
SamBarker authored Oct 7, 2024
1 parent 70eb2b6 commit 4f87bc2
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 19 deletions.
67 changes: 66 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,72 @@ jobs:
cd flink-autoscaler-plugin-jdbc
mvn -B verify -Dit.skip=false
cd ..
e2e_smoke_test:
name: HTTP Client smoke test
runs-on: ubuntu-latest
strategy:
matrix:
http-client: [ "okhttp", "jdk", "jetty", "vertx" ]
version: ["v1_20"]
mode: ["native"]
namespace: ["default"]
java-version: ["21"]
test:
- test_application_operations.sh
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: 'maven'
- name: Start minikube
run: |
source e2e-tests/utils.sh
start_minikube
- name: Install cert-manager
run: |
kubectl get pods -A
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.8.2/cert-manager.yaml
kubectl -n cert-manager wait --all=true --for=condition=Available --timeout=300s deploy
- name: Build image
run: |
export SHELL=/bin/bash
export DOCKER_BUILDKIT=1
eval $(minikube -p minikube docker-env)
JAVA_VERSION=${{matrix.java-version}}
HTTP_CLIENT=${{ matrix.http-client }}
docker build --progress=plain --no-cache -f ./Dockerfile -t flink-kubernetes-operator:ci-latest --progress plain --build-arg JAVA_VERSION="${JAVA_VERSION:-11}" --build-arg HTTP_CLIENT="${HTTP_CLIENT:-okhttp}" .
docker images
- name: Start the operator
run: |
if [[ "${{ matrix.test }}" == "test_flink_operator_ha.sh" ]]; then
sed -i "s/# kubernetes.operator.leader-election.enabled: false/kubernetes.operator.leader-election.enabled: true/" helm/flink-kubernetes-operator/conf/flink-conf.yaml
sed -i "s/# kubernetes.operator.leader-election.lease-name: flink-operator-lease/kubernetes.operator.leader-election.lease-name: flink-operator-lease/" helm/flink-kubernetes-operator/conf/flink-conf.yaml
sed -i "s/replicas: 1/replicas: 2/" helm/flink-kubernetes-operator/values.yaml
fi
helm --debug install flink-kubernetes-operator -n ${{ matrix.namespace }} helm/flink-kubernetes-operator --set image.repository=flink-kubernetes-operator --set image.tag=ci-latest ${{ matrix.extraArgs }}
kubectl wait --for=condition=Available --timeout=120s -n ${{ matrix.namespace }} deploy/flink-kubernetes-operator
kubectl get pods -n ${{ matrix.namespace }}
- name: Run Flink e2e tests
run: |
sed -i "s/image: flink:.*/image: ${{ matrix.image }}/" e2e-tests/data/*.yaml
sed -i "s/flinkVersion: .*/flinkVersion: ${{ matrix.version }}/" e2e-tests/data/*.yaml
sed -i "s/mode: .*/mode: ${{ matrix.mode }}/" e2e-tests/data/*.yaml
git diff HEAD
echo "Running e2e-tests/$test"
bash e2e-tests/${{ matrix.test }} || exit 1
git reset --hard
- name: Stop the operator
run: |
helm uninstall -n ${{ matrix.namespace }} flink-kubernetes-operator
- name: Stop minikube
run: |
source e2e-tests/utils.sh
stop_minikube
e2e_ci:
needs: e2e_smoke_test
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -166,7 +231,7 @@ jobs:
export SHELL=/bin/bash
export DOCKER_BUILDKIT=1
eval $(minikube -p minikube docker-env)
export JAVA_VERSION=${{ matrix.java-version }}
JAVA_VERSION=${{ matrix.java-version }}
docker build --progress=plain --no-cache -f ./Dockerfile -t flink-kubernetes-operator:ci-latest --progress plain --build-arg JAVA_VERSION="${JAVA_VERSION:-11}" .
docker images
- name: Start the operator
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
ARG JAVA_VERSION=11
FROM maven:3.8.8-eclipse-temurin-${JAVA_VERSION} AS build
ARG SKIP_TESTS=true
ARG HTTP_CLIENT=okhttp

WORKDIR /app

COPY . .

RUN --mount=type=cache,target=/root/.m2 mvn -ntp clean install -pl flink-kubernetes-standalone,flink-kubernetes-operator-api,flink-kubernetes-operator,flink-autoscaler,flink-kubernetes-webhook -DskipTests=$SKIP_TESTS
RUN --mount=type=cache,target=/root/.m2 mvn -ntp clean install -pl flink-kubernetes-standalone,flink-kubernetes-operator-api,flink-kubernetes-operator,flink-autoscaler,flink-kubernetes-webhook -DskipTests=$SKIP_TESTS -Dfabric8.httpclinent.impl="$HTTP_CLIENT"

RUN cd /app/tools/license; mkdir jars; cd jars; \
cp /app/flink-kubernetes-operator/target/flink-kubernetes-operator-*-shaded.jar . && \
Expand Down
45 changes: 33 additions & 12 deletions flink-kubernetes-operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ under the License.
<!-- required by FlinkConfigManagerTest -->
--add-opens=java.base/java.util=ALL-UNNAMED
</surefire.module.config>
<!-- valid options can be checked at https://central.sonatype.com/search?q=kubernetes-httpclient- currently: okhttp, jdk, jetty, vertx -->
<fabric8.httpclinent.impl>okhttp</fabric8.httpclinent.impl>
</properties>

<dependencies>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework</artifactId>
<version>${operator.sdk.version}</version>
<exclusions>
<exclusion>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -60,26 +68,17 @@ under the License.
</dependency>

<dependency>
<!-- https://github.com/fabric8io/kubernetes-client/blob/main/doc/FAQ.md#what-artifacts-should-my-project-depend-on-->
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-httpclient-okhttp</artifactId>
<artifactId>kubernetes-httpclient-${fabric8.httpclinent.impl}</artifactId>
<version>${fabric8.version}</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>*</artifactId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${okhttp.version}</version>
</dependency>

<!-- Flink -->
<dependency>
Expand Down Expand Up @@ -174,6 +173,12 @@ under the License.
<artifactId>kubernetes-server-mock</artifactId>
<version>${fabric8.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -413,6 +418,22 @@ under the License.
</plugins>
</build>
</profile>
<profile>
<id>depend-on-okhttp4</id>
<activation>
<property>
<name>fabric8.httpclinent.impl</name>
<value>okhttp</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import io.javaoperatorsdk.operator.processing.event.ResourceID;
import lombok.SneakyThrows;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -202,7 +201,7 @@ public Map<String, String> getParallelismOverrides(KubernetesJobAutoScalerContex
.orElse(new HashMap<>());
}

@NotNull
@Nonnull
@Override
public ConfigChanges getConfigChanges(KubernetesJobAutoScalerContext jobContext) {
return configMapStore
Expand Down
4 changes: 2 additions & 2 deletions flink-kubernetes-operator/src/main/resources/META-INF/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ This project bundles the following dependencies under the Apache Software Licens
- io.fabric8:kubernetes-model-scheduling:jar:6.13.2
- io.fabric8:kubernetes-model-storageclass:jar:6.13.2
- io.fabric8:zjsonpatch:jar:0.3.0
- io.javaoperatorsdk:operator-framework-core:jar:4.8.3
- io.javaoperatorsdk:operator-framework:jar:4.8.3
- io.javaoperatorsdk:operator-framework-core:jar:4.9.4
- io.javaoperatorsdk:operator-framework:jar:4.9.4
- org.apache.commons:commons-compress:1.21
- org.apache.commons:commons-lang3:3.14.0
- org.apache.commons:commons-math3:3.6.1
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ under the License.
<maven-javadoc-plugin.version>3.3.2</maven-javadoc-plugin.version>
<git-commit-id-maven-plugin.version>5.0.0</git-commit-id-maven-plugin.version>

<operator.sdk.version>4.8.3</operator.sdk.version>
<operator.sdk.version>4.9.4</operator.sdk.version>
<operator.sdk.webhook-framework.version>1.1.1</operator.sdk.webhook-framework.version>

<fabric8.version>6.13.2</fabric8.version>
Expand Down

0 comments on commit 4f87bc2

Please sign in to comment.