Skip to content

Commit

Permalink
feat(storage): replace minio client with AWS S3 SDK client
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Jun 8, 2023
2 parents ccee237 + da01170 commit 35410ef
Show file tree
Hide file tree
Showing 6 changed files with 355 additions and 348 deletions.
3 changes: 3 additions & 0 deletions aws/buckets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/sh

awslocal s3 mb s3://archivedrecordings
63 changes: 38 additions & 25 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
version: "3"

services:
# TODO evaluate this downstream image. This allows the backend to assume that the storage buckets
# already exist in minio, which may or may not be a fair assumption for users in a production environment.
# would users prefer that assumption be made and they have to manually set up the buckets? the bucket names
# are configurable for the cryostat application so there is no forced name collision, so perhaps
# automatic creation of the buckets on startup is OK.
# minio:
# image: docker.io/bitnami/minio:latest
# hostname: minio
# s3:
# image: docker.io/localstack/localstack:1.4.0
# hostname: s3
# ports:
# - "9000:9000"
# - "9001:9001"
# - "4566:4566"
# - "4577:4577"
# environment:
# MINIO_ROOT_USER: minioroot
# MINIO_ROOT_PASSWORD: minioroot
# MINIO_DEFAULT_BUCKETS: archivedrecordings
# SERVICES: s3
# START_WEB: 1
# AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-aws_access_key_id}
# AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-aws_secret_access_key}
# DEFAULT_REGION: us-east-1
# PORT_WEB_UI: 4577
# volumes:
# - minio_data:/data
# - minio_certs:/certs
minio:
# - ./aws:/etc/localstack/init/ready.d:z
# # this buckets.sh hook script isn't working for some reason. In the meantime, after spinning up the localstack instance, do:
# # $ podman exec -it cryostat3_s3_1 /bin/bash
# # $ awslocal s3 mb s3://archivedrecordings
# labels:
# kompose.service.expose: "s3"
# restart: unless-stopped
# healthcheck:
# test: curl --fail http://localhost:4566 || exit 1
# interval: 10s
# retries: 3
# start_period: 10s
# timeout: 5s
#

s3:
image: docker.io/minio/minio:latest
hostname: minio
ports:
- "9001:9001"
- "9000:9000"
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: minioroot
MINIO_ROOT_PASSWORD: minioroot
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioroot}
MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY:-minioroot}
MINIO_DEFAULT_BUCKETS: archivedrecordings
volumes:
- minio_data:/data
- minio_certs:/certs
Expand Down Expand Up @@ -90,7 +102,7 @@ services:
cryostat:
depends_on:
- db
- minio
- s3
image: quay.io/cryostat/cryostat3:dev
hostname: cryostat3
expose:
Expand All @@ -105,12 +117,13 @@ services:
QUARKUS_DATASOURCE_USERNAME: cryostat3
QUARKUS_DATASOURCE_PASSWORD: cryostat3
QUARKUS_DATASOURCE_JDBC_URL: jdbc:postgresql://db:5432/cryostat3
QUARKUS_MINIO_URL: http://minio:9000
# create access key in minio console by visiting http://localhost:9001
# `podman-compose up minio` may be useful to start minio first to create
# these secrets, then `export MINIO_ACCESS=abcd ; export MINIO_SECRET=1234 ; podman-compose up`
QUARKUS_MINIO_ACCESS_KEY: ${MINIO_ACCESS:-minioroot}
QUARKUS_MINIO_SECRET_KEY: ${MINIO_SECRET:-minioroot}
STORAGE_BUCKETS_ARCHIVES_NAME: archivedrecordings
QUARKUS_S3_ENDPOINT_OVERRIDE: http://s3:9000
QUARKUS_S3_PATH_STYLE_ACCESS: "true" # needed for Minio, but if the specific S3 impl supports DNS subdomain style access then that should be preferred
QUARKUS_S3_AWS_REGION: us-east-1
QUARKUS_S3_AWS_CREDENTIALS_TYPE: default
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-minioroot}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-minioroot}
CRYOSTAT_JDP_ENABLED: "true"
JAVA_OPTS_APPEND: "-XX:+FlightRecorder -XX:StartFlightRecording=name=onstart,settings=default,disk=true,maxage=5m -Dcom.sun.management.jmxremote.autodiscovery=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9091 -Dcom.sun.management.jmxremote.rmi.port=9091 -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false"
restart: unless-stopped
Expand Down
10 changes: 4 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<io.cryostat.core.version>2.21.0</io.cryostat.core.version>
<io.quarkiverse.minio.version>3.1.0.Final</io.quarkiverse.minio.version>
<org.apache.commons.codec.version>1.15</org.apache.commons.codec.version>
<org.apache.commons.io.version>2.11.0</org.apache.commons.io.version>
<org.apache.httpcomponents.version>4.5.14</org.apache.httpcomponents.version>
Expand Down Expand Up @@ -112,15 +111,14 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.minio</groupId>
<artifactId>quarkus-minio</artifactId>
<version>${io.quarkiverse.minio.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.amazonservices</groupId>
<artifactId>quarkus-amazon-s3</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>url-connection-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/io/cryostat/recordings/ActiveRecording.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,11 @@ public void preUpdate(ActiveRecording activeRecording) throws Exception {
connectionManager.executeConnectedTask(
activeRecording.target,
conn -> {
conn.getService().getAvailableRecordings().stream()
.filter(rec -> rec.getId() == activeRecording.remoteId)
.findFirst()
Recordings.getDescriptorById(conn, activeRecording.remoteId)
.ifPresent(
d -> {
try {
conn.getService().close(d);
conn.getService().stop(d);
} catch (FlightRecorderException
| IOException
| ServiceNotAvailableException e) {
Expand Down
Loading

0 comments on commit 35410ef

Please sign in to comment.