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 47 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-key
AWS_SECRET_ACCESS_KEY=test-secret
ignazio-bovo marked this conversation as resolved.
Show resolved Hide resolved
AWS_REGION=eu-west-1
AWS_BUCKET_NAME=sample-bucket
Copy link
Member

Choose a reason for hiding this comment

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

One bucket name is not sufficient, since the tests and when running playgrounds we could have multiple storage nodes.

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 @@ -89,7 +89,7 @@
return this._api as unknown as UnaugmentedApiPromise
}

private static async initApi(apiUri: string = DEFAULT_API_URI, metadataCache: Record<string, any>) {

Check warning on line 92 in cli/src/Api.ts

View workflow job for this annotation

GitHub Actions / MacOS Checks (18.x)

Unexpected any. Specify a different type

Check warning on line 92 in cli/src/Api.ts

View workflow job for this annotation

GitHub Actions / Ubuntu Checks (18.x)

Unexpected any. Specify a different type

Check warning on line 92 in cli/src/Api.ts

View workflow job for this annotation

GitHub Actions / MacOS Checks (18.x)

Unexpected any. Specify a different type

Check warning on line 92 in cli/src/Api.ts

View workflow job for this annotation

GitHub Actions / Ubuntu Checks (18.x)

Unexpected any. Specify a different type
const wsProvider: WsProvider = new WsProvider(apiUri)
const api = new ApiPromise({ provider: wsProvider, metadata: metadataCache })
await api.isReadyOrError
Expand All @@ -110,7 +110,7 @@

static async create(
apiUri = DEFAULT_API_URI,
metadataCache: Record<string, any>,

Check warning on line 113 in cli/src/Api.ts

View workflow job for this annotation

GitHub Actions / MacOS Checks (18.x)

Unexpected any. Specify a different type

Check warning on line 113 in cli/src/Api.ts

View workflow job for this annotation

GitHub Actions / Ubuntu Checks (18.x)

Unexpected any. Specify a different type

Check warning on line 113 in cli/src/Api.ts

View workflow job for this annotation

GitHub Actions / MacOS Checks (18.x)

Unexpected any. Specify a different type

Check warning on line 113 in cli/src/Api.ts

View workflow job for this annotation

GitHub Actions / Ubuntu Checks (18.x)

Unexpected any. Specify a different type
qnApi?: QueryNodeApi
): Promise<Api> {
const { api, chainType } = await Api.initApi(apiUri, metadataCache)
Expand Down Expand Up @@ -182,7 +182,7 @@
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
26 changes: 26 additions & 0 deletions docker-compose.localstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.4'
services:
localstack:
container_name: local_stack
image: localstack/localstack
ignazio-bovo marked this conversation as resolved.
Show resolved Hide resolved
network_mode: bridge
environment:
- SERVICES=s3 # we only need s3 bucket
- DEBUG=1
- DEFAULT_REGION=${AWS_REGION}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- LOCALSTACK_ENDPOINT=${LOCALSTACK_ENDPOINT}
Copy link
Member

Choose a reason for hiding this comment

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

Looking at https://docs.localstack.cloud/references/configuration/
default_region is deprecated, there are no key configuration, localstack just ignores secret and key ids for now.

Copy link
Member

Choose a reason for hiding this comment

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

And here I think you meant to configure LOCALSTACK_HOST. LOCALSTACK_ENDPOINT is not a configuration option for localstack anymore

ports:
- 4566:4566
volumes:
- localstack-data:/var/lib/localstack'

networks:
joystream:
external: true
name: joystream_default

volumes:
localstack-data:
driver: local
69 changes: 38 additions & 31 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,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 Down Expand Up @@ -38,15 +38,20 @@ services:
- OTEL_EXPORTER_OTLP_ENDPOINT=${TELEMETRY_ENDPOINT}
- OTEL_RESOURCE_ATTRIBUTES=service.name=colossus-1,deployment.environment=production
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 +76,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 @@ -110,15 +115,20 @@ services:
# ACCOUNT_URI overrides command line arg --accountUri
- ACCOUNT_URI=${COLOSSUS_2_TRANSACTOR_URI}
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 +153,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 +203,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 +289,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 +299,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 +318,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 +451,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
6 changes: 6 additions & 0 deletions storage-node/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export interface DataStatsResponse {
* @memberof DataStatsResponse
*/
'pendingObjects'?: number;
/**
*
* @type {string}
* @memberof DataStatsResponse
*/
'cloudProvider'?: string;
}
/**
*
Expand Down
5 changes: 5 additions & 0 deletions storage-node/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
};
6 changes: 6 additions & 0 deletions storage-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"bugs": "https://github.com/Joystream/joystream/issues",
"dependencies": {
"@apollo/client": "^3.3.21",
"@aws-sdk/client-s3": "^3.577.0",
"@aws-sdk/s3-request-presigner": "^3.577.0",
"@elastic/ecs-winston-format": "^1.3.1",
"@joystream/metadata-protobuf": "^2.15.0",
"@joystream/opentelemetry": "1.0.0",
Expand Down Expand Up @@ -72,6 +74,7 @@
"@graphql-codegen/typescript": "^1.22.0",
"@graphql-codegen/typescript-document-nodes": "^1.17.11",
"@graphql-codegen/typescript-operations": "^1.17.16",
"@jest/globals": "^29.7.0",
"@joystream/eslint-config": "^1.0.0",
"@oclif/dev-cli": "^1",
"@oclif/test": "^1",
Expand All @@ -90,6 +93,7 @@
"eslint-config-oclif": "^3.1",
"eslint-config-oclif-typescript": "^0.1",
"globby": "^10",
"jest": "^29.7.0",
"json-schema-to-typescript": "^10.1.4",
"mocha": "^5",
"nyc": "^14",
Expand All @@ -98,6 +102,7 @@
"prettier": "^2.3.0",
"sinon": "^11.1.1",
"swagger-ui-express": "^4.1.6",
"ts-jest": "^29.1.2",
"ts-node": "^10.2.1",
"type-doc": "^0.1.41",
"typescript": "^5.0.2"
Expand Down Expand Up @@ -167,6 +172,7 @@
"ensure": "yarn format && yarn lint --fix && yarn build",
"checks": "tsc --noEmit --pretty && prettier ./src --check && yarn lint",
"start": "./bin/run server",
"test:integration:cloudProvider": "jest --detectOpenHandles './src/services/storageProviders/tests/**/syncService.test.ts'",
Copy link
Member

Choose a reason for hiding this comment

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

running the test I got one failed test:

Mokhtars-MBP:storage-node mokhtar$ yarn test:integration:cloudProvider
yarn run v1.22.19
$ jest --detectOpenHandles './src/services/storageProviders/tests/**/syncService.test.ts'
  Invalid testPattern ./src/services/storageProviders/tests/**/syncService.test.ts supplied. Running all tests instead.
  Invalid testPattern ./src/services/storageProviders/tests/**/syncService.test.ts supplied. Running all tests instead.
 PASS  src/services/storageProviders/tests/integration/setupLocalCache.test.ts (13.784 s)
 PASS  src/services/storageProviders/tests/integration/acceptObject.test.ts
 FAIL  src/services/storageProviders/tests/integration/acceptObjectService.test.ts
  ● accept pending object flow test suite › accept pending object happy path › should call accept objects/maxTxBatchSize times

    expect(jest.fn()).toHaveBeenCalledTimes(expected)

    Expected number of calls: 2
    Received number of calls: 0

      70 |
      71 |       expect(acceptPendingDataObjectsBatch).toHaveBeenCalledTimes(2)
    > 72 |       expect(acceptObject).toHaveBeenCalledTimes(2)
         |                            ^
      73 |       expect(addDataObjectIdToCache).toHaveBeenCalledTimes(2)
      74 |     })
      75 |   })

      at Object.<anonymous> (src/services/storageProviders/tests/integration/acceptObjectService.test.ts:72:28)

Test Suites: 1 failed, 2 passed, 3 total
Tests:       1 failed, 23 passed, 24 total

"start:with-instrumentation": "export OTEL_APPLICATION=storage-node; export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8200; export OTEL_RESOURCE_ATTRIBUTES=service.name=colossus,deployment.environment=production; node --require @joystream/opentelemetry ./bin/run server"
},
"types": "lib/index.d.ts"
Expand Down
2 changes: 2 additions & 0 deletions storage-node/src/api-spec/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ components:
pendingObjects:
type: integer
format: int64
cloudProvider:
type: string
VersionResponse:
type: object
required:
Expand Down
1 change: 1 addition & 0 deletions storage-node/src/command-base/ExitCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum ExitCodes {
ApiError = 200,
UnsuccessfulRuntimeCall,
KeyringNotReady,
CacheInitError,

// NOTE: never exceed exit code 255 or it will be modulated by `256` and create problems
}
Expand Down
14 changes: 12 additions & 2 deletions storage-node/src/commands/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ import { getStorageBucketIdsByWorkerId } from '../services/sync/storageObligatio
import { PendingDirName, TempDirName, performSync } from '../services/sync/synchronizer'
import { createApp } from '../services/webApi/app'
import ExitCodes from './../command-base/ExitCodes'
import { IConnectionHandler, parseConfigOptionAndBuildConnection } from '../services/storageProviders'
const fsPromises = fs.promises

// Global variable for storage provider connection, initialised by server, then readonly
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the best place to store these values.

let storageProviderConnection: IConnectionHandler | undefined
export const getStorageProviderConnection = () => storageProviderConnection
export const isStorageProviderConnectionEnabled = () => storageProviderConnection !== undefined

/**
* CLI command:
* Starts the storage node server.
Expand Down Expand Up @@ -228,8 +234,8 @@ Supported values: warn, error, debug, info. Default:debug`,
logger.warn(`Only subset of buckets will process uploads!`)
}

logger.info(`Buckets synced and served: ${selectedBuckets}`)
logger.info(`Buckets accepting uploads: ${writableBuckets}`)
logger.info(`Buckets synced and served: [${selectedBuckets}]`)
logger.info(`Buckets accepting uploads: [${writableBuckets}]`)

if (!flags.tempFolder) {
logger.warn(
Expand Down Expand Up @@ -260,6 +266,10 @@ Supported values: warn, error, debug, info. Default:debug`,
this.error('Paths for pending and uploads folders must be unique.')
}

// initialise storage provider connection: undefined if not enabled
storageProviderConnection = await parseConfigOptionAndBuildConnection()
logger.debug(`remote storage provider connection status: ${isStorageProviderConnectionEnabled()}`)

await createDirectory(flags.uploads)
await loadDataObjectIdCache(flags.uploads)

Expand Down
1 change: 1 addition & 0 deletions storage-node/src/commands/util/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Maybe<T> = T | undefined
Copy link
Member

Choose a reason for hiding this comment

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

I don't see this used anywhere.

Loading
Loading