-
Notifications
You must be signed in to change notification settings - Fork 115
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
base: master
Are you sure you want to change the base?
colossus s3 api #5150
Changes from 47 commits
bb9a565
4fe88e9
f9544cf
ccbf56b
5d19954
a1aaed0
73a47b0
336893e
4354320
a37dcd4
940b06f
e697309
61e3ac1
1363c66
0df58f1
19cee7c
3b72202
99b8ea6
bcd5b12
2395a25
c05b69a
1bc8dfc
47f47e5
c80488d
c269c10
b45260b
270ed8f
e87c578
ac4e9e0
3d6d0ea
978b21f
f76ebfd
f74cb7d
ae0c8b3
b5e45f5
480dbd4
b33c9ad
e75df99
fc57895
8ae8d77
ae510bc
81ea8fb
4954a82
eaf1d10
613ab3a
9dfa471
196c48c
a73f483
967a893
5e88241
ae4e1a6
334e2ad
9892e01
763f77f
889a5f9
5038ae4
5c7bc1a
6e1f6e0
ebd0f03
5959615
e3bece8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 GitHub Actions / MacOS Checks (18.x)
Check warning on line 92 in cli/src/Api.ts GitHub Actions / Ubuntu Checks (18.x)
Check warning on line 92 in cli/src/Api.ts GitHub Actions / MacOS Checks (18.x)
|
||
const wsProvider: WsProvider = new WsProvider(apiUri) | ||
const api = new ApiPromise({ provider: wsProvider, metadata: metadataCache }) | ||
await api.isReadyOrError | ||
|
@@ -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 GitHub Actions / MacOS Checks (18.x)
Check warning on line 113 in cli/src/Api.ts GitHub Actions / Ubuntu Checks (18.x)
Check warning on line 113 in cli/src/Api.ts GitHub Actions / MacOS Checks (18.x)
|
||
qnApi?: QueryNodeApi | ||
): Promise<Api> { | ||
const { api, chainType } = await Api.initApi(apiUri, metadataCache) | ||
|
@@ -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]] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
const module = apiModuleByGroup[group] | ||
return this._api.query[module] | ||
} | ||
|
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} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at https://docs.localstack.cloud/references/configuration/ There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testMatch: ['**/*.test.ts'], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -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", | ||
|
@@ -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", | ||
|
@@ -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" | ||
|
@@ -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'", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. running the test I got one failed test:
|
||
"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" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
@@ -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( | ||
|
@@ -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) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type Maybe<T> = T | undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see this used anywhere. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENABLE_STORAGE_PROVIDER
andCLOUD_STORAGE_PROVIDER_NAME
probably make more sense as command line arguments.There was a problem hiding this comment.
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.