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

feat(java17): use JRE17, run tests on JRE17, compile with JDK11 #6113

Merged
merged 7 commits into from
Nov 28, 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
29 changes: 28 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
uses: docker/setup-buildx-action@v3
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: |
17
11
distribution: 'zulu'
cache: 'gradle'
- name: Prepare build variables
Expand Down Expand Up @@ -74,3 +76,28 @@ jobs:
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-unvalidated-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated-ubuntu"
- name: Build and publish slim JRE 11 container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.java11.slim
platforms: linux/amd64,linux/arm64
push: true
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-java11-unvalidated"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-java11-unvalidated-slim"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-slim"
- name: Build and publish ubuntu JRE 11 container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.java11.ubuntu
push: true
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-java11-unvalidated-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-ubuntu"
10 changes: 3 additions & 7 deletions .github/workflows/integration-tests-kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install Java 8 for cross-compilation support. Setting it up before
# Java 11 means it comes later in $PATH (because of how setup-java works)
- uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'zulu'
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: |
17
11
distribution: 'zulu'
- name: Cache on push
if: github.event_name == 'push'
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install Java 8 for cross-compilation support. Setting it up before
# Java 11 means it comes later in $PATH (because of how setup-java works)
- uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'zulu'
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: |
17
11
distribution: 'zulu'
- name: Cache on push
if: github.event_name == 'push'
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
uses: docker/setup-buildx-action@v3
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: |
17
11
distribution: 'zulu'
cache: 'gradle'
- name: Prepare build variables
Expand Down Expand Up @@ -53,3 +55,23 @@ jobs:
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-ubuntu"
- name: Build slim JRE 11 container image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.java11.slim
platforms: linux/amd64,linux/arm64
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-java11"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-java11-slim"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-slim"
- name: Build ubuntu JRE 11 container image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.java11.ubuntu
platforms: linux/amd64,linux/arm64
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-java11-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-ubuntu"
29 changes: 28 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
uses: docker/setup-buildx-action@v3
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: |
17
11
distribution: 'zulu'
cache: 'gradle'
- name: Assemble release info
Expand Down Expand Up @@ -111,6 +113,31 @@ jobs:
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-unvalidated-ubuntu"
- name: Build and publish slim JRE 11 container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.java11.slim
platforms: linux/amd64,linux/arm64
push: true
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-java11-unvalidated"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-java11-unvalidated-slim"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-slim"
- name: Build and publish ubuntu JRE 11 container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.java11.ubuntu
platforms: linux/amd64,linux/arm64
push: true
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-java11-unvalidated-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-ubuntu"
- name: Create release
if: steps.release_info.outputs.SKIP_RELEASE == 'false'
uses: softprops/action-gh-release@v1
Expand Down
59 changes: 59 additions & 0 deletions Dockerfile.java11.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM python:3.7-alpine3.16
LABEL maintainer="sig-platform@spinnaker.io"
ARG TARGETARCH

# KUBECTL_RELEASE kept one minor version behind latest to maximise compatibility overlap
ENV KUBECTL_RELEASE=1.22.17
ENV AWS_CLI_VERSION=1.22
ENV AWS_CLI_S3_CMD=2.0.2
ENV AWS_AIM_AUTHENTICATOR_VERSION=0.5.9
ENV GOOGLE_CLOUD_SDK_VERSION=412.0.0
ENV ECR_TOKEN_VERSION=v1.0.2

ENV PATH "$PATH:/usr/local/bin/:/opt/google-cloud-sdk/bin/:/usr/local/bin/aws-iam-authenticator"

RUN apk update \
&& apk upgrade \
&& apk --no-cache add --update \
bash \
ca-certificates \
wget \
openjdk11 \
git \
openssh-client

# AWS CLI
RUN pip install --upgrade --no-build-isolation awscli==${AWS_CLI_VERSION} s3cmd==${AWS_CLI_S3_CMD} python-magic \
&& pip uninstall -y pip

# Google cloud SDK
RUN [ $TARGETARCH == 'amd64' ] && export GCP_ARCH="x86_64" || export GCP_ARCH="arm" \
&& wget -nv https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-${GCP_ARCH}.tar.gz \
&& mkdir -p /opt && cd /opt \
&& tar -xzf /google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-${GCP_ARCH}.tar.gz \
&& rm /google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-${GCP_ARCH}.tar.gz \
&& CLOUDSDK_PYTHON="python3" /opt/google-cloud-sdk/install.sh --usage-reporting=false --bash-completion=false \
--additional-components app-engine-java app-engine-go gke-gcloud-auth-plugin \
&& rm -rf ~/.config/gcloud \
&& rm -rf /opt/google-cloud-sdk/.install/.backup

# kubectl + AWS IAM authenticator
RUN wget https://cdn.dl.k8s.io/release/v${KUBECTL_RELEASE}/bin/linux/${TARGETARCH}/kubectl \
&& chmod +x kubectl \
&& mv ./kubectl /usr/local/bin/kubectl \
&& wget -O aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${AWS_AIM_AUTHENTICATOR_VERSION}/aws-iam-authenticator_${AWS_AIM_AUTHENTICATOR_VERSION}_linux_${TARGETARCH} \
&& chmod +x ./aws-iam-authenticator \
&& mv ./aws-iam-authenticator /usr/local/bin/aws-iam-authenticator\
&& ln -sf /usr/local/bin/aws-iam-authenticator /usr/local/bin/heptio-authenticator-aws

RUN rm /var/cache/apk/*

RUN addgroup -S -g 10111 spinnaker
RUN adduser -S -G spinnaker -u 10111 spinnaker

COPY clouddriver-web/build/install/clouddriver /opt/clouddriver
RUN mkdir -p /opt/clouddriver/plugins && chown -R spinnaker:nogroup /opt/clouddriver/plugins

USER spinnaker

CMD ["/opt/clouddriver/bin/clouddriver"]
54 changes: 54 additions & 0 deletions Dockerfile.java11.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM ubuntu:jammy
LABEL maintainer="sig-platform@spinnaker.io"
ARG TARGETARCH
ENV GOOGLE_CLOUD_SDK_VERSION=412.0.0
ENV PATH "$PATH:/opt/google-cloud-sdk/bin/"
ENV KUBECTL_RELEASE=1.22.17
ENV AWS_CLI_VERSION=1.22
ENV AWS_CLI_S3_CMD=2.0.2
ENV AWS_AIM_AUTHENTICATOR_VERSION=0.5.9

RUN apt-get update && apt-get install -y curl gnupg && \
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
echo "deb https://packages.cloud.google.com/apt cloud-sdk main" > /etc/apt/sources.list.d/cloud-sdk.list && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
openjdk-11-jre-headless \
wget \
python3-pip \
python3 \
git \
openssh-client && \
rm -rf ~/.config/gcloud

# AWS CLI
RUN pip install --upgrade --no-build-isolation awscli==${AWS_CLI_VERSION} s3cmd==${AWS_CLI_S3_CMD} python-magic \
&& apt remove -y python3-pip

# kubectl + AWS IAM authenticator
RUN wget https://cdn.dl.k8s.io/release/v${KUBECTL_RELEASE}/bin/linux/${TARGETARCH}/kubectl \
&& chmod +x kubectl \
&& mv ./kubectl /usr/local/bin/kubectl \
&& wget -O aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${AWS_AIM_AUTHENTICATOR_VERSION}/aws-iam-authenticator_${AWS_AIM_AUTHENTICATOR_VERSION}_linux_${TARGETARCH} \
&& chmod +x ./aws-iam-authenticator \
&& mv ./aws-iam-authenticator /usr/local/bin/aws-iam-authenticator\
&& ln -sf /usr/local/bin/aws-iam-authenticator /usr/local/bin/heptio-authenticator-aws

# Google cloud SDK
RUN [ $TARGETARCH == 'amd64' ] && export GCP_ARCH="x86_64" || export GCP_ARCH="arm" \
&& wget -nv https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-${GCP_ARCH}.tar.gz \
&& mkdir -p /opt && cd /opt \
&& tar -xzf /google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-${GCP_ARCH}.tar.gz \
&& rm /google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-${GCP_ARCH}.tar.gz \
&& CLOUDSDK_PYTHON="python3" /opt/google-cloud-sdk/install.sh --usage-reporting=false --bash-completion=false \
--additional-components app-engine-java app-engine-go gke-gcloud-auth-plugin \
&& rm -rf ~/.config/gcloud \
&& rm -rf /opt/google-cloud-sdk/.install/.backup


RUN adduser --system --uid 10111 --group spinnaker
COPY clouddriver-web/build/install/clouddriver /opt/clouddriver
RUN mkdir -p /opt/clouddriver/plugins && chown -R spinnaker:nogroup /opt/clouddriver/plugins
USER spinnaker
CMD ["/opt/clouddriver/bin/clouddriver"]
2 changes: 1 addition & 1 deletion Dockerfile.slim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN apk update \
bash \
ca-certificates \
wget \
openjdk11 \
openjdk17 \
git \
openssh-client

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y curl gnupg && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
openjdk-11-jre-headless \
openjdk-17-jre-headless \
wget \
python3-pip \
python3 \
Expand Down
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ subprojects {
}
}

tasks.withType(JavaCompile).configureEach {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(11)
}
}
tasks.withType(Test).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}

tasks.withType(JavaExec) {
if (System.getProperty('DEBUG', 'false') == 'true') {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7102'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class CacheExecutionSpec extends Specification {
]
}
1 * cachingAgent.getCacheKeyPatterns() >> {
return [
return Optional.of([
"securityGroups": "securityGroups:*:test:us-west-1"
]
])
}
1 * providerCache.filterIdentifiers("securityGroups", "securityGroups:*:test:us-west-1") >> {
return [
Expand Down
1 change: 1 addition & 0 deletions clouddriver-appengine/clouddriver-appengine.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {
implementation "io.spinnaker.kork:kork-retrofit"
implementation "com.netflix.spectator:spectator-api"
implementation "com.squareup.okhttp:okhttp"
implementation "com.squareup.retrofit:converter-jackson"
implementation "com.squareup.retrofit:retrofit"
implementation "commons-io:commons-io"
implementation "org.apache.commons:commons-compress:1.21"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import retrofit.RestAdapter;
import retrofit.client.OkClient;
import retrofit.client.Response;
import retrofit.converter.JacksonConverter;
import retrofit.http.GET;
import retrofit.http.Headers;
import retrofit.mime.TypedByteArray;
Expand Down Expand Up @@ -103,6 +104,7 @@ static MetadataService createMetadataService() {
RestAdapter restAdapter =
new RestAdapter.Builder()
.setEndpoint(metadataUrl)
.setConverter(new JacksonConverter())
.setClient(new OkClient(client))
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance())
.build();
Expand Down
1 change: 1 addition & 0 deletions clouddriver-consul/clouddriver-consul.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dependencies {
implementation project(":clouddriver-core")

implementation "com.squareup.okhttp:okhttp"
implementation "com.squareup.retrofit:converter-jackson"
implementation "com.squareup.retrofit:retrofit"
implementation "org.codehaus.groovy:groovy"
implementation "org.codehaus.groovy:groovy-json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHand
import com.squareup.okhttp.OkHttpClient
import retrofit.RestAdapter
import retrofit.client.OkClient
import retrofit.converter.JacksonConverter

class Consul<T> {
T api
Expand All @@ -39,6 +40,7 @@ class Consul<T> {
this.api = new RestAdapter.Builder()
.setEndpoint(this.endpoint)
.setClient(new OkClient(new OkHttpClient()))
.setConverter(new JacksonConverter())
.setLogLevel(RestAdapter.LogLevel.NONE)
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance())
.build()
Expand Down
3 changes: 2 additions & 1 deletion clouddriver-core/clouddriver-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ dependencies {
testImplementation project(":clouddriver-core-tck")

testImplementation "cglib:cglib-nodep"
testImplementation "com.github.stefanbirkner:system-lambda:1.2.1"
testImplementation "uk.org.webcompere:system-stubs-core:2.1.5"
testImplementation "uk.org.webcompere:system-stubs-jupiter:2.1.5"
testImplementation "io.spinnaker.kork:kork-jedis-test"
testImplementation "io.spinnaker.kork:kork-test"
testImplementation "org.objenesis:objenesis"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class InMemoryTaskRepository implements TaskRepository {

private String getNextId() {
while (true) {
def maybeNext = new BigInteger(new Random().nextInt(Integer.MAX_VALUE)).toString(36)
def maybeNext = BigInteger.valueOf(new Random().nextInt(Integer.MAX_VALUE)).toString(36)
if (!repository.containsKey(maybeNext)) {
return maybeNext
}
Expand Down
Loading