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

Merge FEGA related components from pipeline into SDA #249

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1ed2700
Merge `broker` from sda-pipeline
jbygdell Aug 9, 2023
aba6047
Merge `storage` from sda-pipeline
jbygdell Aug 9, 2023
39548b4
Merge `config` from sda-pipeline
jbygdell Aug 9, 2023
a39aa50
Update s3inbox to use the merged config & proxy code
jbygdell Aug 9, 2023
4e49d13
Rework storage_test to run as a suite.
jbygdell Aug 9, 2023
09e00d3
Merge `bucket` from s3inbox into `internal/storage`
jbygdell Aug 10, 2023
e80bdac
Deduplicate code
jbygdell Aug 10, 2023
c1ea2a9
[integration tests] Change timings of sda healthchecks
jbygdell Aug 10, 2023
b09cb00
Remove unused variable from `SendMessage`
jbygdell Aug 10, 2023
95911f5
Rename `main` to `s3inbox`
jbygdell Aug 10, 2023
f6f3a99
Remove routingkey option for error messages
jbygdell Aug 10, 2023
0fdba22
Merge in `database` from sda-pipeline
jbygdell Aug 15, 2023
7287d71
Merge in `ingest` & `verify` from sda-pipeline
jbygdell Aug 15, 2023
6c01928
Merge in `backup` from sda-pipeline
jbygdell Aug 17, 2023
60f753b
Update GO mod files
jbygdell Aug 17, 2023
6b3c2ec
Merge in `finalize` from sda-pipeline
jbygdell Aug 17, 2023
57de69a
Simplify `SetAccessionID` database call
jbygdell Aug 18, 2023
124068d
Merge `backup` into `finalize`
jbygdell Aug 18, 2023
3a76bb4
Update GO mod
jbygdell Aug 18, 2023
31f42eb
Merge `mapper` from sda-pipeline
jbygdell Aug 21, 2023
4d935bf
Merge `intercept` from sda-pipeline
jbygdell Aug 22, 2023
549e00f
Remove old pipeline code tests
jbygdell Aug 23, 2023
f9cf354
Remove linting action for pipeline
jbygdell Aug 23, 2023
7d5312d
Don't build PR container for old pipeline
jbygdell Aug 23, 2023
e16b3cb
Remove old pipeline functionality tests
jbygdell Aug 23, 2023
479b94f
Update GO mod
jbygdell Aug 23, 2023
0befc5b
Update charts to match latest container code
jbygdell Aug 31, 2023
2d775fe
Remove `backup` from the helm chart
jbygdell Aug 31, 2023
6fdcfa7
Use `appVersion` from Chart.yaml as image tag
jbygdell Aug 31, 2023
40c79e0
[actions][build pr container] add debug on failure
jbygdell Aug 31, 2023
2df4be8
[s3inbox] fix helthcheck url
jbygdell Aug 31, 2023
97049e9
[finalize] Update readme
jbygdell Aug 31, 2023
2240f94
Graceful shutdown
jbygdell Sep 11, 2023
8d32124
Update dependencies
jbygdell Sep 12, 2023
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
2 changes: 1 addition & 1 deletion .github/integration/rabbitmq-federation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ services:
- BROKER_CLIENTKEY=/certs/client.key
- BROKER_CACERT=/certs/ca.crt
- LOG_LEVEL=debug
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}-pipeline
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}
restart: always
volumes:
- certs:/certs
Expand Down
4 changes: 2 additions & 2 deletions .github/integration/scripts/charts/deploy_charts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi
if [ "$1" == "sda-db" ]; then
ROOTPASS=$(yq e '.global.db.password' .github/integration/scripts/charts/values.yaml)
helm install postgres charts/sda-db \
--set image.tag="PR$2-postgres" \
--set image.tag="PR$2" \
--set image.pullPolicy=IfNotPresent \
--set global.postgresAdminPassword="$ROOTPASS" \
--set global.tls.clusterIssuer=cert-issuer \
Expand All @@ -27,7 +27,7 @@ fi
if [ "$1" == "sda-mq" ]; then
ADMINPASS=$(yq e '.global.broker.password' .github/integration/scripts/charts/values.yaml)
helm install broker charts/sda-mq \
--set image.tag="PR$2-rabbitmq" \
--set image.tag="PR$2" \
--set image.pullPolicy=IfNotPresent \
--set global.adminPassword="$ADMINPASS" \
--set global.adminUser=admin \
Expand Down
3 changes: 0 additions & 3 deletions .github/integration/scripts/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ global:
auth:
replicaCount: 1
resources: null
backup:
deploy: true
resources: null
doa:
deploy: false
download:
Expand Down
8 changes: 5 additions & 3 deletions .github/integration/scripts/make_sda_credentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ for n in download finalize inbox ingest mapper sync verify; do
echo "creating credentials for: $n"

if [ "$n" = inbox ]; then
psql -U postgres -h postgres -d sda -c "DROP ROLE IF EXISTS inbox;"
psql -U postgres -h postgres -d sda -c "CREATE ROLE inbox;"
psql -U postgres -h postgres -d sda -c "GRANT base, ingest TO inbox;"
psql -U postgres -h postgres -d sda -c "DROP ROLE IF EXISTS $n;"
psql -U postgres -h postgres -d sda -c "CREATE ROLE $n;"
psql -U postgres -h postgres -d sda -c "GRANT ingest TO $n;"
fi

if [ "$n" = ingest ]; then
psql -U postgres -h postgres -d sda -c "GRANT UPDATE ON local_ega.main TO ingest;"
fi

psql -U postgres -h postgres -d sda -c "GRANT base TO $n;"

psql -U postgres -h postgres -d sda -c "ALTER ROLE $n LOGIN PASSWORD '$n';"

## password and permissions for MQ
Expand Down
132 changes: 120 additions & 12 deletions .github/integration/sda-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ services:
- POSTGRES_PASSWORD=rootpasswd
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 20s
retries: 3
interval: 10s
timeout: 2s
retries: 6
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}-postgres
ports:
- "15432:5432"
Expand All @@ -46,9 +46,9 @@ services:
"-c",
"rabbitmq-diagnostics -q check_running && rabbitmq-diagnostics -q check_local_alarms",
]
interval: 5s
timeout: 20s
retries: 3
interval: 10s
timeout: 5s
retries: 6
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}-rabbitmq
ports:
- "15672:15672"
Expand All @@ -66,9 +66,9 @@ services:
- MINIO_SERVER_URL=http://127.0.0.1:9000
healthcheck:
test: ["CMD", "curl", "-fkq", "http://localhost:9000/minio/health/live"]
interval: 5s
timeout: 20s
retries: 3
interval: 10s
timeout: 2s
retries: 6
ports:
- "19000:9000"
- "19001:9001"
Expand Down Expand Up @@ -98,6 +98,7 @@ services:
environment:
- BROKER_PASSWORD=inbox
- BROKER_USER=inbox
- BROKER_ROUTINGKEY=inbox
- DB_PASSWORD=inbox
- DB_USER=inbox
restart: always
Expand All @@ -108,6 +109,105 @@ services:
- "18000:8000"
- "18001:8001"

ingest:
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}
command: [ sda-ingest ]
container_name: ingest
depends_on:
credentials:
condition: service_completed_successfully
minio:
condition: service_healthy
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
environment:
- BROKER_PASSWORD=ingest
- BROKER_USER=ingest
- BROKER_QUEUE=ingest
- BROKER_ROUTINGKEY=archived
- DB_PASSWORD=ingest
- DB_USER=ingest
restart: always
volumes:
- ./sda/config.yaml:/config.yaml
- shared:/shared

verify:
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}
command: [ sda-verify ]
container_name: verify
depends_on:
credentials:
condition: service_completed_successfully
minio:
condition: service_healthy
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
environment:
- BROKER_PASSWORD=verify
- BROKER_USER=verify
- BROKER_QUEUE=archived
- BROKER_ROUTINGKEY=verified
- DB_PASSWORD=verify
- DB_USER=verify
restart: always
volumes:
- ./sda/config.yaml:/config.yaml
- shared:/shared

finalize:
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}
command: [ sda-finalize ]
container_name: finalize
depends_on:
credentials:
condition: service_completed_successfully
minio:
condition: service_healthy
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
environment:
- BROKER_PASSWORD=finalize
- BROKER_USER=finalize
- BROKER_QUEUE=accession
- BROKER_ROUTINGKEY=completed
- DB_PASSWORD=finalize
- DB_USER=finalize
restart: always
volumes:
- ./sda/config.yaml:/config.yaml
- shared:/shared

mapper:
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}
command: [ sda-mapper ]
container_name: mapper
depends_on:
credentials:
condition: service_completed_successfully
minio:
condition: service_healthy
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
environment:
- BROKER_PASSWORD=mapper
- BROKER_USER=mapper
- BROKER_QUEUE=mappings
- DB_PASSWORD=mapper
- DB_USER=mapper
restart: always
volumes:
- ./sda/config.yaml:/config.yaml
- shared:/shared

oidc:
container_name: oidc
command:
Expand All @@ -122,9 +222,9 @@ services:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "python3", "-c", 'import requests; print(requests.get(url = "http://localhost:8080/jwk").text)']
interval: 5s
timeout: 20s
retries: 3
interval: 10s
timeout: 2s
retries: 6
image: python:3.10-slim
ports:
- "8080:8080"
Expand All @@ -142,8 +242,16 @@ services:
depends_on:
credentials:
condition: service_completed_successfully
finalize:
condition: service_started
ingest:
condition: service_started
mapper:
condition: service_started
s3inbox:
condition: service_started
verify:
condition: service_started
environment:
- PGPASSWORD=rootpasswd
image: python:3.10-slim-bullseye
Expand Down
30 changes: 27 additions & 3 deletions .github/integration/sda/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
log:
format: "json"
aws:
url: "http://s3:9000"
level: "debug"
archive:
type: s3
url: "http://s3"
port: 9000
readypath: "/minio/health/ready"
accessKey: "access"
secretKey: "secretKey"
bucket: "archive"
region: "us-east-1"
backup:
type: s3
url: "http://s3"
port: 9000
readypath: "/minio/health/ready"
accessKey: "access"
secretKey: "secretKey"
bucket: "backup"
region: "us-east-1"
inbox:
type: s3
url: "http://s3"
port: 9000
readypath: "/minio/health/ready"
accessKey: "access"
secretKey: "secretKey"
Expand All @@ -15,7 +36,7 @@ broker:
password: ""
vhost: "/sda"
exchange: "sda"
routingKey: "inbox"
routingKey: ""
ssl: "false"

db:
Expand All @@ -26,6 +47,9 @@ db:
database: "sda"
sslmode: "disable"

c4gh:
filePath: /shared/c4gh.sec.pem
passphrase: "c4ghpass"

server:
cert: ""
Expand Down
2 changes: 1 addition & 1 deletion .github/integration/tests/run_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
apt-get -o DPkg::Lock::Timeout=60 update > /dev/null
apt-get -o DPkg::Lock::Timeout=60 install -y postgresql-client > /dev/null

find "$1"/*.sh 2>/dev/null | sort -t/ -k3 -n | while read -r runscript; do
for runscript in "$1"/*.sh; do
echo "Executing test script $runscript"
bash -x "$runscript"
done
3 changes: 2 additions & 1 deletion .github/integration/tests/sda/10_upload_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ for t in curl jq postgresql-client; do
fi
done

pip -q install --upgrade pip
pip -q install s3cmd

cd shared || true

for file in NA12878.bam NA12878_20k_b37.bam; do
curl -s -L -o /shared/$file "https://github.com/ga4gh/htsget-refserver/raw/main/data/gcp/gatk-test-data/wgs_bam/$file"
if [ ! -f "$file.c4gh" ]; then
/shared/crypt4gh encrypt -p c4gh.pub.pem -f "$file"
yes | /shared/crypt4gh encrypt -p c4gh.pub.pem -f "$file"
fi
s3cmd -c s3cfg put "$file.c4gh" s3://test_dummy.org/
done
Expand Down
70 changes: 70 additions & 0 deletions .github/integration/tests/sda/20_ingest-verify_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/sh
set -e

cd shared || true

for file in NA12878.bam NA12878_20k_b37.bam; do
ENC_SHA=$(sha256sum "$file.c4gh" | cut -d' ' -f 1)
ENC_MD5=$(md5sum "$file.c4gh" | cut -d' ' -f 1)

## get correlation id from upload message
CORRID=$(
curl -s -X POST \
-H "content-type:application/json" \
-u guest:guest http://rabbitmq:15672/api/queues/sda/inbox/get \
-d '{"count":1,"encoding":"auto","ackmode":"ack_requeue_false"}' | jq -r .[0].properties.correlation_id
)

## publish message to trigger ingestion
properties=$(
jq -c -n \
--argjson delivery_mode 2 \
--arg correlation_id "$CORRID" \
--arg content_encoding UTF-8 \
--arg content_type application/json \
'$ARGS.named'
)

encrypted_checksums=$(
jq -c -n \
--arg sha256 "$ENC_SHA" \
--arg md5 "$ENC_MD5" \
'$ARGS.named|to_entries|map(with_entries(select(.key=="key").key="type"))'
)

ingest_payload=$(
jq -r -c -n \
--arg type ingest \
--arg user [email protected] \
--arg filepath test_dummy.org/"$file.c4gh" \
--argjson encrypted_checksums "$encrypted_checksums" \
'$ARGS.named|@base64'
)

ingest_body=$(
jq -c -n \
--arg vhost sda \
--arg name sda \
--argjson properties "$properties" \
--arg routing_key "ingest" \
--arg payload_encoding base64 \
--arg payload "$ingest_payload" \
'$ARGS.named'
)

curl -s -u guest:guest "http://rabbitmq:15672/api/exchanges/sda/sda/publish" \
-H 'Content-Type: application/json;charset=UTF-8' \
-d "$ingest_body"
done

echo "waiting for verify to complete"
RETRY_TIMES=0
until [ "$(curl -su guest:guest http://rabbitmq:15672/api/queues/sda/verified/ | jq -r '.messages_ready')" -eq 2 ]; do
echo "waiting for verify to complete"
RETRY_TIMES=$((RETRY_TIMES + 1))
if [ "$RETRY_TIMES" -eq 30 ]; then
echo "::error::Time out while waiting for verify to complete"
exit 1
fi
sleep 2
done
Loading
Loading