-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support S3-compatible blob storage (#1071)
- Loading branch information
Showing
77 changed files
with
3,294 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: S3 E2E Tests | ||
|
||
on: push | ||
|
||
jobs: | ||
s3-e2e: | ||
timeout-minutes: 15 | ||
# TODO should we use the same container as circle & central? | ||
runs-on: ubuntu-latest | ||
services: | ||
# see: https://docs.github.com/en/enterprise-server@3.5/actions/using-containerized-services/creating-postgresql-service-containers | ||
postgres: | ||
image: postgres:14.10 | ||
env: | ||
POSTGRES_PASSWORD: odktest | ||
ports: | ||
- 5432:5432 | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
minio: | ||
# see: https://github.com/minio/minio/discussions/16099 | ||
image: minio/minio:edge-cicd | ||
env: | ||
MINIO_ROOT_USER: odk-central-dev | ||
MINIO_ROOT_PASSWORD: topSecret123 | ||
# Enable encryption - this changes how s3 ETags work | ||
# See: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Object.html | ||
# See: https://github.com/minio/minio/discussions/19012 | ||
MINIO_KMS_AUTO_ENCRYPTION: on | ||
MINIO_KMS_SECRET_KEY: odk-minio-test-key:QfdUCrn3UQ58W5pqCS5SX4SOlec9sT8yb4rZ4zK24w0= | ||
ports: | ||
- 9000:9000 | ||
options: >- | ||
--health-cmd "curl -s http://localhost:9000/minio/health/live" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.10.0 | ||
cache: 'npm' | ||
- run: npm ci --legacy-peer-deps | ||
- run: node lib/bin/create-docker-databases.js | ||
- name: E2E Test | ||
timeout-minutes: 10 | ||
run: ./test/e2e/s3/run-tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"default": { | ||
"external": { | ||
"s3blobStore": { | ||
"server": "http://localhost:9000", | ||
"accessKey": "odk-central-dev", | ||
"secretKey": "topSecret123", | ||
"bucketName": "odk-central-bucket", | ||
"requestTimeout": 60000 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2024 ODK Central Developers | ||
// See the NOTICE file at the top-level directory of this distribution and at | ||
// https://github.com/getodk/central-backend/blob/master/NOTICE. | ||
// This file is part of ODK Central. It is subject to the license terms in | ||
// the LICENSE file found in the top-level directory of this distribution and at | ||
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, | ||
// including this file, may be copied, modified, propagated, or distributed | ||
// except according to the terms contained in the LICENSE file. | ||
|
||
const Minio = require('minio'); | ||
|
||
const { server, bucketName, accessKey, secretKey } = require('config').get('default.external.s3blobStore'); | ||
|
||
const minioClient = (() => { | ||
const url = new URL(server); | ||
const useSSL = url.protocol === 'https:'; | ||
const endPoint = (url.hostname + url.pathname).replace(/\/$/, ''); | ||
const port = parseInt(url.port, 10); | ||
|
||
return new Minio.Client({ endPoint, port, useSSL, accessKey, secretKey }); | ||
})(); | ||
|
||
const log = (...args) => console.log(__filename, ...args); | ||
|
||
minioClient.bucketExists(bucketName) | ||
.then(exists => { | ||
if (exists) { | ||
log('Bucket already exists.'); | ||
return; | ||
} | ||
|
||
log('Creating bucket:', bucketName); | ||
return minioClient.makeBucket(bucketName) | ||
.then(() => log('Bucket created OK.')); | ||
}) | ||
.catch(err => { | ||
log('ERROR CREATING MINIO BUCKET:', err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2024 ODK Central Developers | ||
// See the NOTICE file at the top-level directory of this distribution and at | ||
// https://github.com/getodk/central-backend/blob/master/NOTICE. | ||
// This file is part of ODK Central. It is subject to the license terms in | ||
// the LICENSE file found in the top-level directory of this distribution and at | ||
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, | ||
// including this file, may be copied, modified, propagated, or distributed | ||
// except according to the terms contained in the LICENSE file. | ||
|
||
const { program, Argument } = require('commander'); | ||
|
||
const { getCount, setFailedToPending, uploadPending } = require('../task/s3'); | ||
|
||
program.command('count-blobs') | ||
.addArgument(new Argument('status').choices(['pending', 'in_progress', 'uploaded', 'failed'])) | ||
.action(getCount); | ||
program.command('reset-failed-to-pending').action(setFailedToPending); | ||
program.command('upload-pending').action(uploadPending); | ||
program.parse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.