Skip to content

Commit 46d91c6

Browse files
GitHKAndrei Neagu
andauthored
✨♻️ (⚠️ devops) Remove 5gb limit when uploading data via nodeports (ITISFoundation#2993)
* added r_clone and r_clone_utils * added node_ports_v2_r_clone * refactor settings * refactor settings * refactor tests * nodeports supports optional r_clone_settings * pylint * pylint * moved endpoint where it makes sense * moved rclone endpoint and settings * new way of importing * added tests and fixed existing tests for nodeports * extended stprage service * fix tests * pylint * dynamic-sidecar now requires nodeports * fix simcore-sdk requiremetns * properly formatting URL * using http in urls * moved requirements * injecting mandatory settings * test refactoring * fix env vars for rlcone * adding r_clone * fix unit test simore-sdk * fix directr-v2 integration tests * fixed first barch of directorv-2 unittest fixes * pylint * second btach of fixes director-v2 * fixed other tests * moved tests * refactor to use storage_client module * replacing caching * removed r_clone exra settings * moved region to settings * rename * more refactoring * revert * file metadata update check permissions * refactor command exception * command is now a list not a string * moving from list to *args * removed test dir which no longer exists * fix issues with encoding invalid characters * removing defaults * refactor to use exising upload_link fetching * removed unused from specs * pylint * removed old comment * pylint * dynamic-sidecar work also gets transferred via rclone * add missing file * directory watcher disabled during docker-compse up * removed log message * addind middleware to log HTTP errors serialized to client * removing logs since they get automatically captured * returning AnyUrl * more changes * rename and quote shell * added quotes and optimized checks * fixing tests * renaming * removed delete file metedata metada is updated when uploading file * removes file and metadata in case of upload error * added nosec * fix pylint * new dict format migration * update requirements * refacror installation * @sanderegg always upload instead of raising error * fix tests after merge * using full parameter names * repalced helper with validator * using full parameter names * fix issue with minio S3 endpoint format * using full parameter names * changing endpoint formatting * moved s3_region Co-authored-by: Andrei Neagu <[email protected]>
1 parent 2a3913b commit 46d91c6

File tree

78 files changed

+1223
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1223
-204
lines changed

.env-devel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ S3_BUCKET_NAME=simcore
6060
S3_ENDPOINT=172.17.0.1:9001
6161
S3_SECRET_KEY=12345678
6262
S3_SECURE=0
63-
R_CLONE_S3_PROVIDER=MINIO
63+
R_CLONE_PROVIDER=MINIO
6464

6565
SCICRUNCH_API_BASE_URL=https://scicrunch.org/api/1
6666
SCICRUNCH_API_KEY=REPLACE_ME_with_valid_api_key

.github/workflows/ci-testing-deploy.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,8 @@ jobs:
10361036
driver: docker
10371037
- name: setup docker-compose
10381038
run: sudo ./ci/github/helpers/setup_docker_compose.bash ${{ matrix.docker_compose }} ${{ matrix.docker_compose_sha }}
1039+
- name: install rclone in CI
1040+
run: sudo ./ci/github/helpers/install_rclone.bash
10391041
- name: setup python environment
10401042
uses: actions/setup-python@v3
10411043
with:
@@ -1343,7 +1345,7 @@ jobs:
13431345
- name: setup docker-compose
13441346
run: sudo ./ci/github/helpers/setup_docker_compose.bash ${{ matrix.docker_compose }} ${{ matrix.docker_compose_sha }}
13451347
- name: setup rclone docker volume plugin
1346-
run: sudo ./ci/github/helpers/install_rclone.bash
1348+
run: sudo ./ci/github/helpers/install_rclone_docker_volume_plugin.bash
13471349
- name: setup python environment
13481350
uses: actions/setup-python@v3
13491351
with:
@@ -1410,6 +1412,8 @@ jobs:
14101412
driver: docker
14111413
- name: setup docker-compose
14121414
run: sudo ./ci/github/helpers/setup_docker_compose.bash ${{ matrix.docker_compose }} ${{ matrix.docker_compose_sha }}
1415+
- name: install rclone in CI
1416+
run: sudo ./ci/github/helpers/install_rclone.bash
14131417
- name: setup python environment
14141418
uses: actions/setup-python@v3
14151419
with:

api/specs/storage/openapi.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ paths:
257257
required: true
258258
schema:
259259
type: string
260-
requestBody:
261-
content:
262-
application/json:
263-
schema:
264-
$ref: "#/components/schemas/FileMetaData"
260+
- name: user_id
261+
in: query
262+
required: true
263+
schema:
264+
type: string
265265
responses:
266266
"200":
267267
description: "Returns file metadata"

ci/github/helpers/install_rclone.bash

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ set -o pipefail # don't hide errors within pipes
1010
IFS=$'\n\t'
1111

1212

13-
# Installation instructions from https://rclone.org/docker/
14-
15-
apt-get -y install fuse=2.9.9-3
16-
mkdir -p /var/lib/docker-plugins/rclone/config
17-
mkdir -p /var/lib/docker-plugins/rclone/cache
18-
docker plugin install rclone/docker-volume-rclone:amd64-1.57.0 args="-v" --alias rclone --grant-all-permissions
19-
docker plugin list
20-
docker plugin inspect rclone
13+
R_CLONE_VERSION="1.58.0"
14+
curl --silent --location --remote-name "https://downloads.rclone.org/v${R_CLONE_VERSION}/rclone-v${R_CLONE_VERSION}-linux-amd64.deb"
15+
dpkg --install "rclone-v${R_CLONE_VERSION}-linux-amd64.deb"
16+
rm "rclone-v${R_CLONE_VERSION}-linux-amd64.deb"
17+
rclone --version
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#
3+
# Installs the latest version of rclone plugin
4+
#
5+
6+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
7+
set -o errexit # abort on nonzero exitstatus
8+
set -o nounset # abort on unbound variable
9+
set -o pipefail # don't hide errors within pipes
10+
IFS=$'\n\t'
11+
12+
13+
# Installation instructions from https://rclone.org/docker/
14+
15+
apt-get -y install fuse=2.9.9-3
16+
mkdir --parents /var/lib/docker-plugins/rclone/config
17+
mkdir --parents /var/lib/docker-plugins/rclone/cache
18+
docker plugin install rclone/docker-volume-rclone:amd64-1.57.0 args="-v" --alias rclone --grant-all-permissions
19+
docker plugin list
20+
docker plugin inspect rclone

ci/github/unit-testing/director-v2.bash

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ test() {
1818
--color=yes --cov-report=term-missing --cov-report=xml --cov-config=.coveragerc \
1919
-v -m "not travis" services/director-v2/tests/unit --ignore=services/director-v2/tests/unit/with_dbs \
2020
--asyncio-mode=auto \
21-
--ignore=services/director-v2/tests/unit/with_swarm
2221
# these tests cannot be run in parallel
2322
pytest --log-format="%(asctime)s %(levelname)s %(message)s" \
2423
--log-date-format="%Y-%m-%d %H:%M:%S" \
2524
--cov=simcore_service_director_v2 --durations=10 --cov-append \
2625
--color=yes --cov-report=term-missing --cov-report=xml --cov-config=.coveragerc \
2726
--asyncio-mode=auto \
28-
-v -m "not travis" services/director-v2/tests/unit/with_swarm services/director-v2/tests/unit/with_dbs
27+
-v -m "not travis" services/director-v2/tests/unit/with_dbs
2928
}
3029

3130
# Check if the function exists (bash specific)

packages/pytest-simcore/src/pytest_simcore/minio_service.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# pylint: disable=unused-variable
44

55
import logging
6-
from typing import Dict, Iterator
6+
from typing import Any, Iterator
77

88
import pytest
99
from _pytest.monkeypatch import MonkeyPatch
@@ -43,8 +43,8 @@ def _ensure_remove_bucket(client: Minio, bucket_name: str):
4343

4444
@pytest.fixture(scope="module")
4545
def minio_config(
46-
docker_stack: Dict, testing_environ_vars: Dict, monkeypatch_module: MonkeyPatch
47-
) -> Dict[str, str]:
46+
docker_stack: dict, testing_environ_vars: dict, monkeypatch_module: MonkeyPatch
47+
) -> dict[str, Any]:
4848
assert "pytest-ops_minio" in docker_stack["services"]
4949

5050
config = {
@@ -68,7 +68,7 @@ def minio_config(
6868

6969

7070
@pytest.fixture(scope="module")
71-
def minio_service(minio_config: Dict[str, str]) -> Iterator[Minio]:
71+
def minio_service(minio_config: dict[str, str]) -> Iterator[Minio]:
7272

7373
client = Minio(**minio_config["client"])
7474

@@ -99,7 +99,7 @@ def minio_service(minio_config: Dict[str, str]) -> Iterator[Minio]:
9999

100100

101101
@pytest.fixture(scope="module")
102-
def bucket(minio_config: Dict[str, str], minio_service: Minio) -> Iterator[str]:
102+
def bucket(minio_config: dict[str, str], minio_service: Minio) -> Iterator[str]:
103103
bucket_name = minio_config["bucket_name"]
104104

105105
_ensure_remove_bucket(minio_service, bucket_name)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
from aiohttp.web import Application, middleware, Request, HTTPError
3+
from servicelib.aiohttp.typing_extension import Handler, Middleware
4+
import logging
5+
import traceback
6+
7+
logger = logging.getLogger(__name__)
8+
9+
_SEP = "|||"
10+
11+
12+
def _middleware_factory() -> Middleware:
13+
@middleware
14+
async def middleware_handler(request: Request, handler: Handler):
15+
try:
16+
return await handler(request)
17+
except HTTPError as err:
18+
fields = {
19+
"Body": err.body,
20+
"Status": err.status,
21+
"Reason": err.reason,
22+
"Headers": err.headers,
23+
"Traceback": "\n".join(traceback.format_tb(err.__traceback__)),
24+
}
25+
formatted_error = "".join(
26+
[f"\n{_SEP}{k}{_SEP}\n{v}" for k, v in fields.items()]
27+
)
28+
logger.debug("Error serialized to client:%s", formatted_error)
29+
raise err
30+
31+
return middleware_handler
32+
33+
34+
def setup_dev_error_logger(app: Application) -> None:
35+
logger.info("Setting up dev_error_logger")
36+
app.middlewares.append(_middleware_factory())
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from enum import Enum
2+
3+
from pydantic import Field
4+
from .base import BaseCustomSettings
5+
from .s3 import S3Settings
6+
7+
8+
class S3Provider(str, Enum):
9+
AWS = "AWS"
10+
CEPH = "CEPH"
11+
MINIO = "MINIO"
12+
13+
14+
class RCloneSettings(BaseCustomSettings):
15+
R_CLONE_S3: S3Settings = Field(auto_default_from_env=True)
16+
R_CLONE_PROVIDER: S3Provider
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
from typing import Optional
22

33
from .base import BaseCustomSettings
4+
from pydantic import validator
45

56

67
class S3Settings(BaseCustomSettings):
7-
S3_ENDPOINT: str = "minio:9000"
8-
S3_ACCESS_KEY: str = "12345678"
9-
S3_SECRET_KEY: str = "12345678"
8+
S3_ENDPOINT: str
9+
S3_ACCESS_KEY: str
10+
S3_SECRET_KEY: str
1011
S3_ACCESS_TOKEN: Optional[str] = None
11-
S3_BUCKET_NAME: str = "simcore"
12+
S3_BUCKET_NAME: str
1213
S3_SECURE: bool = False
14+
S3_REGION: str = "us-east-1"
15+
16+
@validator("S3_ENDPOINT", pre=True)
17+
@classmethod
18+
def ensure_scheme(cls, v: str, values) -> str:
19+
if not v.startswith("http"):
20+
scheme = "https" if values.get("S3_SECURE") else "http"
21+
return f"{scheme}://{v}"
22+
return v

0 commit comments

Comments
 (0)