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

colossus s3 api #5150

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
bb9a565
feat: :art: env var in order to run content-directory scenario
Apr 19, 2024
4fe88e9
feat: :art: create s3 api model
Apr 19, 2024
f9544cf
Merge branch 'master' into feat/colossus-s3-api
Apr 19, 2024
ccbf56b
feat: :art: refactor filemodel
Apr 22, 2024
5d19954
feat: :art: add connection handler abstract in order to conect to blo…
Apr 23, 2024
a1aaed0
refactor: :recycle: connection handlers
Apr 23, 2024
73a47b0
feat: :art: file cache improvements
Apr 24, 2024
336893e
refactor: :art: refactor to accomodate synch task
May 7, 2024
4354320
feat: :art: list files functionality
May 7, 2024
a37dcd4
feat: :art: improvements on connection handlers
May 12, 2024
940b06f
feat: :art: refactor sync task and add task for remote storage provid…
May 12, 2024
e697309
feat: :art: renaming the storage provider module and sync/task module…
May 12, 2024
61e3ac1
feat: :zap: server setup with remote storage provider connection
May 12, 2024
1363c66
feat: :art: add file verification error class
May 12, 2024
0df58f1
fix: :fire: add onLocal volume / onCloud Storage flag to data Object …
May 13, 2024
19cee7c
feat: :art: improve accepted asset logic to accomodate cloud bucket u…
May 13, 2024
3b72202
fix: :art: upload file flow
May 13, 2024
99b8ea6
feat: :art: getFile pipe stream
May 14, 2024
bcd5b12
feat: :zap: adapt abstractConnectionHandler
May 14, 2024
2395a25
feat: :art: improve S3 connection handler
May 14, 2024
c05b69a
fix: :bug: list object list ALL objects in the bucket
May 14, 2024
1bc8dfc
style: :truck: rename files
May 14, 2024
47f47e5
feat: :zap: setup cloud provider config options
May 15, 2024
c80488d
fix: :bug: compiler errorrs
May 16, 2024
c269c10
feat: :art: utilise redirect url for getFile request
May 16, 2024
b45260b
feat: :art: handle multipart uploads
May 16, 2024
270ed8f
docs: :memo: update documentation
May 16, 2024
e87c578
feat: :art: add functionality for removing object from bucket
May 20, 2024
ac4e9e0
test: :art: setup jest integration tests
May 21, 2024
3d6d0ea
test: :white_check_mark: finally have a working jest test setup
May 22, 2024
978b21f
test: :white_check_mark: add unhappy path for move To accepted location
May 22, 2024
f76ebfd
test: :white_check_mark: add test for sync service
May 23, 2024
f74cb7d
feat: :art: rewrite file acceptance logic for accept object and sync …
May 23, 2024
ae0c8b3
test: :white_check_mark: full green test suite for acceptObject
May 23, 2024
b5e45f5
test: :white_check_mark: add for cache setup
May 23, 2024
480dbd4
test: :white_check_mark: add for cache setup
May 23, 2024
b33c9ad
test: :white_check_mark: add test setup with localstack
May 29, 2024
e75df99
fix: :zap: fix startup flag for storage provider
May 29, 2024
fc57895
test: :fire: testing
May 29, 2024
8ae8d77
Merge branch 'petra' into feat/colossus-s3-api
Jun 17, 2024
ae510bc
test: :white_check_mark: setup localstack
Jun 17, 2024
81ea8fb
fix: :white_check_mark: integration test setup
Jun 19, 2024
4954a82
fix: :bento: env variable setup
Jun 19, 2024
eaf1d10
fix: :white_check_mark: localstack integration test setup
Jun 19, 2024
613ab3a
fix: :memo: docker compose config
Jun 19, 2024
9dfa471
refactor: :recycle: refactor docker compose files
Jun 19, 2024
196c48c
Merge branch 'master' into feat/colossus-s3-api
Aug 23, 2024
a73f483
fix integration tests
mnaamani Aug 24, 2024
967a893
docker compose instead of docker-compose
mnaamani Aug 24, 2024
5e88241
fix used pip before activating venv
mnaamani Aug 24, 2024
ae4e1a6
revert docker image names used in local testing
mnaamani Aug 24, 2024
334e2ad
Update .env
Aug 27, 2024
9892e01
Update storage-node/src/services/webApi/controllers/filesApi.ts
Aug 27, 2024
763f77f
Update tests/network-tests/run-tests.sh
Aug 27, 2024
889a5f9
Update docker-compose.localstack.yml
Aug 27, 2024
5038ae4
Update storage-node/src/services/helpers/acceptObject.ts
Aug 27, 2024
5c7bc1a
Merge branch 'feat/colossus-s3-api' into colossus-s3-api-integration-…
Aug 28, 2024
6e1f6e0
Merge pull request #17 from mnaamani/colossus-s3-api-integration-test…
Aug 28, 2024
ebd0f03
fix: :zap: add test and configuration for existing file uploads
Aug 27, 2024
5959615
feat: :art: adding uploadfile if not exisitng test
Aug 28, 2024
e3bece8
fix: :art: overall fixes for awsConnectionHandler test and upload wit…
Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
15 changes: 15 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,18 @@ SQUID_GQL_PORT=4352
# Archive gateway host (Should not be set in local development)
# For running a production storage-squid instance uncomment the following line (to use the subsquid hosted archive)
# SQUID_ARCHIVE_GATEWAY_URL=${CUSTOM_ARCHIVE_GATEWAY_URL:-https://v2.archive.subsquid.io/network/joystream}

# =====================================================================================
## Cloud storage provider configuration

# Enable or disable the cloud storage provider
ENABLE_STORAGE_PROVIDER=true

## Specify the cloud storage provider to use:
CLOUD_STORAGE_PROVIDER_NAME=aws
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENABLE_STORAGE_PROVIDER and CLOUD_STORAGE_PROVIDER_NAME probably make more sense as command line arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we can reduce from two params to just one, the provider name. If not empty string it means we want to use a cloud storage provider.


# AWS S3 (replace with your own configuration and credentials)
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_REGION=eu-west-1
AWS_BUCKET_NAME=test-bucket
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ runtime-inputs/
devops/infrastructure

joystream.tar.gz

# localstack for s3 backend colossus testing
localstack/localstack_init
2 changes: 1 addition & 1 deletion cli/src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default class Api {
return new Date(blockTime.toNumber())
}

protected workingGroupApiQuery<T extends WorkingGroups>(group: T): ApiPromise['query'][typeof apiModuleByGroup[T]] {
protected workingGroupApiQuery<T extends WorkingGroups>(group: T): ApiPromise['query'][(typeof apiModuleByGroup)[T]] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please checkout any code changes to cli, they all seem to be code style changes and best to be in a different PR.
Let keep changes in the PR focused on storage-node

const module = apiModuleByGroup[group]
return this._api.query[module]
}
Expand Down
8 changes: 4 additions & 4 deletions cli/src/base/ContentDirectoryCommandBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const CATEGORIES_CONTEXTS = ['Lead', 'Curator'] as const
const MODERATION_ACTION_CONTEXTS = ['Lead', 'Curator'] as const
const CHANNEL_MANAGEMENT_CONTEXTS = ['Owner', 'Curator', 'Collaborator'] as const

type ChannelManagementContext = typeof CHANNEL_MANAGEMENT_CONTEXTS[number]
type ChannelCreationContext = typeof CHANNEL_CREATION_CONTEXTS[number]
type CategoriesContext = typeof CATEGORIES_CONTEXTS[number]
type ModerationActionContext = typeof MODERATION_ACTION_CONTEXTS[number]
type ChannelManagementContext = (typeof CHANNEL_MANAGEMENT_CONTEXTS)[number]
type ChannelCreationContext = (typeof CHANNEL_CREATION_CONTEXTS)[number]
type CategoriesContext = (typeof CATEGORIES_CONTEXTS)[number]
type ModerationActionContext = (typeof MODERATION_ACTION_CONTEXTS)[number]

/**
* Abstract base class for commands related to content directory
Expand Down
2 changes: 1 addition & 1 deletion cli/src/base/ForumCommandBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { AccountId } from '@polkadot/types/interfaces'
const FORUM_MODERATION_CONTEXT = ['Leader', 'Moderator'] as const

type ForumModerationContext = typeof FORUM_MODERATION_CONTEXT[number]
type ForumModerationContext = (typeof FORUM_MODERATION_CONTEXT)[number]

/**
* Abstract base class for commands related to forum management
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/api/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const TYPES_AVAILABLE = ['query', 'consts'] as const

// String literals type based on TYPES_AVAILABLE const.
// It works as if we specified: type ApiType = 'query' | 'consts'...;
type ApiType = typeof TYPES_AVAILABLE[number]
type ApiType = (typeof TYPES_AVAILABLE)[number]

export default class ApiInspect extends ApiCommandBase {
static description =
Expand Down
2 changes: 1 addition & 1 deletion cli/src/helpers/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function displayTable(rows: { [k: string]: string | number }[], cellHoriz
}, columnName.length)
const columnDef = (columnName: string) => ({
header: columnName,
get: (row: typeof rows[number]) => chalk.magentaBright(`${row[columnName]}`),
get: (row: (typeof rows)[number]) => chalk.magentaBright(`${row[columnName]}`),
minWidth: maxLength(columnName) + cellHorizontalPadding,
})
const columns: Table.table.Columns<{ [k: string]: string }> = {}
Expand Down
7 changes: 6 additions & 1 deletion docker-compose-no-bind-volumes.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Complete joystream development network
version: '3.4'
services:
joystream-node:
image: joystream/node:$JOYSTREAM_NODE_TAG
Expand Down Expand Up @@ -37,6 +36,9 @@ services:
- ACCOUNT_URI=${COLOSSUS_1_TRANSACTOR_URI}
# - OTEL_EXPORTER_OTLP_ENDPOINT=http://apm-server:8200
# - OTEL_RESOURCE_ATTRIBUTES=service.name=colossus-1,deployment.environment=production
- AWS_BUCKET_NAME=test-bucket-1
- LOCALSTACK_ENDPOINT=${LOCALSTACK_ENDPOINT}
- LOCALSTACK_ENABLED=${LOCALSTACK_ENABLED}
entrypoint: ['yarn']
command: [
'start', '--worker=${COLOSSUS_1_WORKER_ID}', '--port=3333', '--uploads=/data/uploads',
Expand Down Expand Up @@ -106,6 +108,9 @@ services:
environment:
# ACCOUNT_URI overrides command line arg --accountUri
- ACCOUNT_URI=${COLOSSUS_2_TRANSACTOR_URI}
- AWS_BUCKET_NAME=test-bucket-2
- LOCALSTACK_ENDPOINT=${LOCALSTACK_ENDPOINT}
- LOCALSTACK_ENABLED=${LOCALSTACK_ENABLED}
entrypoint: ['yarn', 'storage-node']
command: [
'server', '--worker=${COLOSSUS_2_WORKER_ID}', '--port=3333', '--uploads=/data/uploads',
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.elasticsearch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.4'

services:
# Ref: https://www.elastic.co/guide/en/elasticsearch/reference/8.7/docker.html
elasticsearch:
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.localstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
localstack:
container_name: local_stack
image: localstack/localstack:3.3
network_mode: bridge
environment:
- SERVICES=s3 # we only need s3 bucket
- DEBUG=1
- LOCALSTACK_HOST=${LOCALSTACK_HOST}
ports:
- 4566:4566
volumes:
- localstack-data:/var/lib/localstack'

networks:
joystream:
external: true
name: joystream_default

volumes:
localstack-data:
driver: local
2 changes: 0 additions & 2 deletions docker-compose.storage-squid.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
squid_db:
container_name: squid_db
Expand Down
76 changes: 44 additions & 32 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Complete joystream development network
version: '3.4'
services:
joystream-node:
image: joystream/node:$JOYSTREAM_NODE_TAG
Expand All @@ -9,8 +8,8 @@ services:
- chain-data:/data
environment:
- CHAIN=${CHAIN}
command: "--chain ${CHAIN:-dev} --alice --validator --pruning=archive --unsafe-ws-external --unsafe-rpc-external
--rpc-methods Safe --rpc-cors=all --log runtime --base-path /data --no-hardware-benchmarks"
command: '--chain ${CHAIN:-dev} --alice --validator --pruning=archive --unsafe-ws-external --unsafe-rpc-external
--rpc-methods Safe --rpc-cors=all --log runtime --base-path /data --no-hardware-benchmarks'
ports:
- 9944:9944
- 9933:9933
Expand All @@ -37,16 +36,24 @@ services:
- ACCOUNT_URI=${COLOSSUS_1_TRANSACTOR_URI}
- OTEL_EXPORTER_OTLP_ENDPOINT=${TELEMETRY_ENDPOINT}
- OTEL_RESOURCE_ATTRIBUTES=service.name=colossus-1,deployment.environment=production
- AWS_BUCKET_NAME=test-bucket-1
- LOCALSTACK_ENDPOINT=${LOCALSTACK_ENDPOINT}
- LOCALSTACK_ENABLED=${LOCALSTACK_ENABLED}
entrypoint: ['/joystream/entrypoints/storage.sh']
command: [
'server', '--worker=${COLOSSUS_1_WORKER_ID}', '--port=3333', '--uploads=/data/uploads/',
'--sync', '--syncInterval=1',
'--storageSquidEndpoint=${COLOSSUS_STORAGE_SQUID_URL}',
'--apiUrl=${JOYSTREAM_NODE_WS}',
'--logFilePath=/logs',
'--tempFolder=/data/temp/',
'--pendingFolder=/data/pending/'
]
command:
[
'server',
'--worker=${COLOSSUS_1_WORKER_ID}',
'--port=3333',
'--uploads=/data/uploads/',
'--sync',
'--syncInterval=1',
'--storageSquidEndpoint=${COLOSSUS_STORAGE_SQUID_URL}',
'--apiUrl=${JOYSTREAM_NODE_WS}',
'--logFilePath=/logs',
'--tempFolder=/data/temp/',
'--pendingFolder=/data/pending/',
]

distributor-1:
image: node:18
Expand All @@ -71,7 +78,7 @@ services:
environment:
JOYSTREAM_DISTRIBUTOR__ID: distributor-1
JOYSTREAM_DISTRIBUTOR__ENDPOINTS__STORAGE_SQUID: ${DISTRIBUTOR_STORAGE_SQUID_URL}
JOYSTREAM_DISTRIBUTOR__KEYS: "[{\"suri\":\"${DISTRIBUTOR_1_ACCOUNT_URI}\"}]"
JOYSTREAM_DISTRIBUTOR__KEYS: '[{"suri":"${DISTRIBUTOR_1_ACCOUNT_URI}"}]'
JOYSTREAM_DISTRIBUTOR__WORKER_ID: ${DISTRIBUTOR_1_WORKER_ID}
JOYSTREAM_DISTRIBUTOR__PUBLIC_API__PORT: 3334
JOYSTREAM_DISTRIBUTOR__OPERATOR_API__PORT: 4334
Expand Down Expand Up @@ -109,16 +116,24 @@ services:
environment:
# ACCOUNT_URI overrides command line arg --accountUri
- ACCOUNT_URI=${COLOSSUS_2_TRANSACTOR_URI}
- AWS_BUCKET_NAME=test-bucket-2
- LOCALSTACK_ENDPOINT=${LOCALSTACK_ENDPOINT}
- LOCALSTACK_ENABLED=${LOCALSTACK_ENABLED}
entrypoint: ['yarn', 'storage-node']
command: [
'server', '--worker=${COLOSSUS_2_WORKER_ID}', '--port=3333', '--uploads=/data/uploads',
'--sync', '--syncInterval=1',
'--storageSquidEndpoint=${COLOSSUS_STORAGE_SQUID_URL}',
'--apiUrl=${JOYSTREAM_NODE_WS}',
'--logFilePath=/logs',
'--tempFolder=/data/temp/',
'--pendingFolder=/data/pending/'
]
command:
[
'server',
'--worker=${COLOSSUS_2_WORKER_ID}',
'--port=3333',
'--uploads=/data/uploads',
'--sync',
'--syncInterval=1',
'--storageSquidEndpoint=${COLOSSUS_STORAGE_SQUID_URL}',
'--apiUrl=${JOYSTREAM_NODE_WS}',
'--logFilePath=/logs',
'--tempFolder=/data/temp/',
'--pendingFolder=/data/pending/',
]

distributor-2:
image: node:18
Expand All @@ -143,7 +158,7 @@ services:
environment:
JOYSTREAM_DISTRIBUTOR__ID: distributor-2
JOYSTREAM_DISTRIBUTOR__ENDPOINTS__STORAGE_SQUID: ${DISTRIBUTOR_STORAGE_SQUID_URL}
JOYSTREAM_DISTRIBUTOR__KEYS: "[{\"suri\":\"${DISTRIBUTOR_2_ACCOUNT_URI}\"}]"
JOYSTREAM_DISTRIBUTOR__KEYS: '[{"suri":"${DISTRIBUTOR_2_ACCOUNT_URI}"}]'
JOYSTREAM_DISTRIBUTOR__WORKER_ID: ${DISTRIBUTOR_2_WORKER_ID}
JOYSTREAM_DISTRIBUTOR__PUBLIC_API__PORT: 3334
JOYSTREAM_DISTRIBUTOR__OPERATOR_API__PORT: 4334
Expand Down Expand Up @@ -193,8 +208,8 @@ services:
- OTEL_EXPORTER_OTLP_ENDPOINT=${TELEMETRY_ENDPOINT}
- OTEL_RESOURCE_ATTRIBUTES=service.name=query-node,deployment.environment=production
ports:
- "${GRAPHQL_SERVER_PORT}:${GRAPHQL_SERVER_PORT}"
- "127.0.0.1:${PROCESSOR_STATE_APP_PORT}:${PROCESSOR_STATE_APP_PORT}"
- '${GRAPHQL_SERVER_PORT}:${GRAPHQL_SERVER_PORT}'
- '127.0.0.1:${PROCESSOR_STATE_APP_PORT}:${PROCESSOR_STATE_APP_PORT}'
depends_on:
- db
volumes:
Expand Down Expand Up @@ -279,7 +294,7 @@ services:
- PORT=${HYDRA_INDEXER_GATEWAY_PORT}
- PGSSLMODE=disable
ports:
- "${HYDRA_INDEXER_GATEWAY_PORT}:${HYDRA_INDEXER_GATEWAY_PORT}"
- '${HYDRA_INDEXER_GATEWAY_PORT}:${HYDRA_INDEXER_GATEWAY_PORT}'
depends_on:
- db
- redis
Expand All @@ -289,7 +304,7 @@ services:
container_name: redis
restart: unless-stopped
ports:
- "127.0.0.1:6379:6379"
- '127.0.0.1:6379:6379'

faucet:
image: joystream/faucet:carthage
Expand All @@ -308,7 +323,7 @@ services:
- BALANCE_CREDIT=${BALANCE_CREDIT}
- BALANCE_LOCKED=${BALANCE_LOCKED}
ports:
- "3002:3002"
- '3002:3002'

# PostgerSQL database for Orion
orion-db:
Expand Down Expand Up @@ -441,10 +456,7 @@ services:
environment:
DATABASE_MAX_CONNECTIONS: 5
RUST_LOG: 'actix_web=info,actix_server=info'
command: [
'--database-url',
'postgres://postgres:postgres@orion_archive_db:${ARCHIVE_DB_PORT}/squid-archive',
]
command: ['--database-url', 'postgres://postgres:postgres@orion_archive_db:${ARCHIVE_DB_PORT}/squid-archive']
ports:
- '127.0.0.1:${ARCHIVE_GATEWAY_PORT}:8000'
- '[::1]:${ARCHIVE_GATEWAY_PORT}:8000'
Expand Down
Loading
Loading