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

Revert "♻️ Volumes keep track if the data requires saving 🚨 (#3974)" #4139

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions packages/models-library/src/models_library/users.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from typing import TypeAlias

from pydantic import PositiveInt

UserID: TypeAlias = PositiveInt
GroupID: TypeAlias = PositiveInt
UserID = PositiveInt
GroupID = PositiveInt
30 changes: 0 additions & 30 deletions packages/models-library/src/models_library/volumes.py

This file was deleted.

5 changes: 2 additions & 3 deletions packages/service-library/requirements/_base.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
--constraint ../../../requirements/constraints.txt
--constraint ./constraints.txt


aio-pika
aiodebug
aiofiles
aio-pika
arrow # date/time
redis
pydantic
pyinstrument
pyyaml
redis
tenacity
tqdm
13 changes: 0 additions & 13 deletions packages/service-library/src/servicelib/enum_utils.py

This file was deleted.

5 changes: 0 additions & 5 deletions packages/service-library/src/servicelib/file_constants.py

This file was deleted.

34 changes: 0 additions & 34 deletions packages/service-library/src/servicelib/volumes_utils.py

This file was deleted.

34 changes: 0 additions & 34 deletions packages/service-library/tests/test_volumes_utils.py

This file was deleted.

3 changes: 1 addition & 2 deletions services/agent/src/simcore_service_agent/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from models_library.basic_types import BootModeEnum, LogLevel
from pydantic import Field, NonNegativeInt, validator
from servicelib.file_constants import AGENT_FILE_NAME, HIDDEN_FILE_NAME
from settings_library.base import BaseCustomSettings
from settings_library.r_clone import S3Provider
from settings_library.utils_logging import MixinLoggingSettings
Expand Down Expand Up @@ -33,7 +32,7 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
5, description="parallel transfers to s3"
)
AGENT_VOLUMES_CLEANUP_EXCLUDE_FILES: list[str] = Field(
[AGENT_FILE_NAME, HIDDEN_FILE_NAME, "key_values.json"],
[".hidden_do_not_remove", "key_values.json"],
description="Files to ignore when syncing to s3",
)
AGENT_VOLUMES_CLEANUP_INTERVAL_S: NonNegativeInt = Field(
Expand Down
10 changes: 2 additions & 8 deletions services/agent/tests/unit/test_modules_volumes_cleanup_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
from aiodocker.volumes import DockerVolume
from pydantic import HttpUrl
from pytest import LogCaptureFixture
from servicelib.file_constants import (
AGENT_FILE_NAME,
HIDDEN_FILE_NAME,
KEY_VALUE_FILE_NAME,
)
from simcore_service_agent.core.settings import ApplicationSettings
from simcore_service_agent.modules.volumes_cleanup._s3 import (
S3Provider,
Expand Down Expand Up @@ -80,9 +75,8 @@ async def _download_files_from_bucket(

def _create_data(folder: Path) -> None:
for file in { # pylint:disable=use-sequence-for-iteration
AGENT_FILE_NAME,
HIDDEN_FILE_NAME,
KEY_VALUE_FILE_NAME,
".hidden_do_not_remove",
"key_values.json",
"f1.txt",
"f2.txt",
"f3.txt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ async def create_dynamic_service(
request_dns=x_dynamic_sidecar_request_dns,
request_scheme=x_dynamic_sidecar_request_scheme,
request_simcore_user_agent=x_simcore_user_agent,
can_save=service.can_save,
)

return cast(DynamicServiceGet, await scheduler.get_stack_status(service.node_uuid))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ class DynamicServiceCreate(ServiceDetails):
service_resources: ServiceResourcesDict

product_name: str = Field(..., description="Current product name")
can_save: bool = Field(
..., description="the service data must be saved when closing"
)

class Config:
schema_extra = {
Expand All @@ -52,7 +49,6 @@ class Config:
"node_uuid": "75c7f3f4-18f9-4678-8610-54a2ade78eaa",
"basepath": "/x/75c7f3f4-18f9-4678-8610-54a2ade78eaa",
"product_name": "osparc",
"can_save": True,
"service_resources": ServiceResourcesDictHelpers.Config.schema_extra[
"examples"
][0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,12 @@ def from_http_request(
request_dns: str,
request_scheme: str,
request_simcore_user_agent: str,
can_save: bool,
run_id: UUID | None = None,
) -> "SchedulerData":
# This constructor method sets current product
names_helper = DynamicSidecarNamesHelper.make(service.node_uuid)

obj_dict: dict[str, Any] = dict(
obj_dict = dict(
service_name=names_helper.service_name_dynamic_sidecar,
hostname=names_helper.service_name_dynamic_sidecar,
port=port,
Expand All @@ -465,7 +464,7 @@ def from_http_request(
request_scheme=request_scheme,
proxy_service_name=names_helper.proxy_service_name,
request_simcore_user_agent=request_simcore_user_agent,
dynamic_sidecar={"service_removal_state": {"can_save": can_save}},
dynamic_sidecar={},
)
if run_id:
obj_dict["run_id"] = run_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from models_library.projects import ProjectID
from models_library.projects_networks import DockerNetworkAlias
from models_library.projects_nodes_io import NodeID
from models_library.volumes import VolumeCategory
from pydantic import AnyHttpUrl, PositiveFloat
from servicelib.fastapi.long_running_tasks.client import (
Client,
Expand All @@ -20,7 +19,6 @@
)
from servicelib.logging_utils import log_context
from servicelib.utils import logged_gather
from servicelib.volumes_utils import VolumeStatus
from simcore_service_director_v2.core.settings import DynamicSidecarSettings

from ....models.schemas.dynamic_services import SchedulerData
Expand Down Expand Up @@ -403,19 +401,6 @@ async def restart_containers(self, dynamic_sidecar_endpoint: AnyHttpUrl) -> None
_debug_progress_callback,
)

@log_decorator(logger=logger)
async def update_volume_state(
self,
dynamic_sidecar_endpoint: AnyHttpUrl,
volume_category: VolumeCategory,
volume_status: VolumeStatus,
) -> None:
await self._thin_client.put_volumes(
dynamic_sidecar_endpoint,
volume_category=volume_category,
volume_status=volume_status,
)


async def setup(app: FastAPI) -> None:
with log_context(logger, logging.DEBUG, "dynamic-sidecar api client setup"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

from fastapi import FastAPI, status
from httpx import Response, Timeout
from models_library.volumes import VolumeCategory
from pydantic import AnyHttpUrl
from servicelib.docker_constants import SUFFIX_EGRESS_PROXY_NAME
from servicelib.volumes_utils import VolumeStatus

from ....core.settings import DynamicSidecarSettings
from ._base import BaseThinClient, expect_status, retry_on_errors
Expand Down Expand Up @@ -227,15 +225,3 @@ async def post_containers_tasks_restart(
) -> Response:
url = self._get_url(dynamic_sidecar_endpoint, "/containers:restart")
return await self.client.post(url)

@retry_on_errors
@expect_status(status.HTTP_204_NO_CONTENT)
async def put_volumes(
self,
dynamic_sidecar_endpoint: AnyHttpUrl,
volume_category: VolumeCategory,
volume_status: VolumeStatus,
) -> Response:
url = self._get_url(dynamic_sidecar_endpoint, f"/volumes/{volume_category}")

return await self.client.put(url, json={"status": volume_status})
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ async def add_service(
request_dns: str,
request_scheme: str,
request_simcore_user_agent: str,
can_save: bool,
) -> None:
"""
Adds a new service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
from models_library.rabbitmq_messages import InstrumentationRabbitMessage
from models_library.service_settings_labels import SimcoreServiceLabels
from models_library.services import ServiceKeyVersion
from models_library.volumes import VolumeCategory
from servicelib.fastapi.long_running_tasks.client import (
ProgressCallback,
TaskClientResultError,
)
from servicelib.fastapi.long_running_tasks.server import TaskProgress
from servicelib.utils import logged_gather
from servicelib.volumes_utils import VolumeStatus
from simcore_postgres_database.models.comp_tasks import NodeClass
from tenacity import TryAgain
from tenacity._asyncio import AsyncRetrying
Expand Down Expand Up @@ -139,11 +137,6 @@ async def service_save_state(
await dynamic_sidecar_client.save_service_state(
scheduler_data.endpoint, progress_callback=progress_callback
)
await dynamic_sidecar_client.update_volume_state(
scheduler_data.endpoint,
volume_category=VolumeCategory.STATES,
volume_status=VolumeStatus.CONTENT_WAS_SAVED,
)


async def service_push_outputs(
Expand All @@ -156,11 +149,6 @@ async def service_push_outputs(
await dynamic_sidecar_client.push_service_output_ports(
scheduler_data.endpoint, progress_callback=progress_callback
)
await dynamic_sidecar_client.update_volume_state(
scheduler_data.endpoint,
volume_category=VolumeCategory.OUTPUTS,
volume_status=VolumeStatus.CONTENT_WAS_SAVED,
)


async def service_remove_sidecar_proxy_docker_networks_and_volumes(
Expand Down Expand Up @@ -420,32 +408,6 @@ async def prepare_services_environment(
dynamic_sidecar_client = get_dynamic_sidecar_client(app, scheduler_data.node_uuid)
dynamic_sidecar_endpoint = scheduler_data.endpoint

# update if volume requires saving
def _get_state_params(can_save: bool | None) -> dict[str, VolumeStatus]:
return (
{"volume_status": VolumeStatus.CONTENT_WAS_SAVED}
if can_save
else {"volume_status": VolumeStatus.CONTENT_NO_SAVE_REQUIRED}
)

update_volume_state_params = _get_state_params(
scheduler_data.dynamic_sidecar.service_removal_state.can_save
)
await logged_gather(
*(
dynamic_sidecar_client.update_volume_state(
scheduler_data.endpoint,
volume_category=VolumeCategory.STATES,
**update_volume_state_params,
),
dynamic_sidecar_client.update_volume_state(
scheduler_data.endpoint,
volume_category=VolumeCategory.OUTPUTS,
**update_volume_state_params,
),
)
)

async def _pull_outputs_and_state():
tasks = [
dynamic_sidecar_client.pull_service_output_ports(dynamic_sidecar_endpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ async def add_service(
request_dns: str,
request_scheme: str,
request_simcore_user_agent: str,
can_save: bool,
) -> None:
"""Invoked before the service is started"""
scheduler_data = SchedulerData.from_http_request(
Expand All @@ -159,7 +158,6 @@ async def add_service(
request_dns=request_dns,
request_scheme=request_scheme,
request_simcore_user_agent=request_simcore_user_agent,
can_save=can_save,
)
await self._add_service(scheduler_data)

Expand Down
Loading