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

Remove local maindb driver #2636

Merged
merged 9 commits into from
Nov 15, 2024
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
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ jobs:
strategy:
fail-fast: false
matrix:
maindb_driver: ["pg"]
shard: [0, 1, 2]

steps:
Expand All @@ -365,8 +364,6 @@ jobs:
- name: Run NucliaDB tests
# These tests can be flaky, let's retry them...
uses: nick-fields/retry@v3
env:
TESTING_MAINDB_DRIVERS: ${{ matrix.maindb_driver }}
with:
max_attempts: 2
retry_on: error
Expand Down
21 changes: 5 additions & 16 deletions nucliadb/src/nucliadb/common/datamanagers/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from nucliadb.common.maindb.exceptions import ConflictError, NotFoundError

# These should be refactored
from nucliadb.ingest.settings import settings as ingest_settings
from nucliadb_protos import resources_pb2
from nucliadb_utils.utilities import get_storage

Expand All @@ -37,7 +36,6 @@


KB_RESOURCE_BASIC = "/kbs/{kbid}/r/{uuid}"
KB_RESOURCE_BASIC_FS = "/kbs/{kbid}/r/{uuid}/basic" # Only used on FS driver
KB_RESOURCE_ORIGIN = "/kbs/{kbid}/r/{uuid}/origin"
KB_RESOURCE_EXTRA = "/kbs/{kbid}/r/{uuid}/extra"
KB_RESOURCE_SECURITY = "/kbs/{kbid}/r/{uuid}/security"
Expand Down Expand Up @@ -128,24 +126,15 @@ async def get_basic(txn: Transaction, *, kbid: str, rid: str) -> Optional[resour


async def get_basic_raw(txn: Transaction, *, kbid: str, rid: str) -> Optional[bytes]:
if ingest_settings.driver == "local":
raw_basic = await txn.get(KB_RESOURCE_BASIC_FS.format(kbid=kbid, uuid=rid))
else:
raw_basic = await txn.get(KB_RESOURCE_BASIC.format(kbid=kbid, uuid=rid))
raw_basic = await txn.get(KB_RESOURCE_BASIC.format(kbid=kbid, uuid=rid))
return raw_basic


async def set_basic(txn: Transaction, *, kbid: str, rid: str, basic: resources_pb2.Basic):
if ingest_settings.driver == "local":
await txn.set(
KB_RESOURCE_BASIC_FS.format(kbid=kbid, uuid=rid),
basic.SerializeToString(),
)
else:
await txn.set(
KB_RESOURCE_BASIC.format(kbid=kbid, uuid=rid),
basic.SerializeToString(),
)
await txn.set(
KB_RESOURCE_BASIC.format(kbid=kbid, uuid=rid),
basic.SerializeToString(),
)


# Origin
Expand Down
228 changes: 0 additions & 228 deletions nucliadb/src/nucliadb/common/maindb/local.py

This file was deleted.

15 changes: 0 additions & 15 deletions nucliadb/src/nucliadb/common/maindb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@
except ImportError: # pragma: no cover
PG = False

try:
from nucliadb.common.maindb.local import LocalDriver

FILES = True
except ImportError: # pragma: no cover
FILES = False


def get_driver() -> Driver:
driver = get_utility(Utility.MAINDB_DRIVER)
Expand All @@ -61,14 +54,6 @@ async def setup_driver() -> Driver:
acquire_timeout_ms=settings.driver_pg_connection_pool_acquire_timeout_ms,
)
set_utility(Utility.MAINDB_DRIVER, pg_driver)
elif settings.driver == DriverConfig.LOCAL:
if not FILES:
raise ConfigurationError("`aiofiles` python package not installed.")
if settings.driver_local_url is None:
raise ConfigurationError("No DRIVER_LOCAL_URL env var defined.")

local_driver = LocalDriver(settings.driver_local_url)
set_utility(Utility.MAINDB_DRIVER, local_driver)
else:
raise ConfigurationError(f"Invalid DRIVER defined configured: {settings.driver}")

Expand Down
3 changes: 1 addition & 2 deletions nucliadb/src/nucliadb/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ def nats_manager_healthy() -> bool:

def nodes_health_check() -> bool:
from nucliadb.common.cluster import manager
from nucliadb.ingest.settings import DriverConfig, settings

return len(manager.INDEX_NODES) > 0 or settings.driver == DriverConfig.LOCAL
return len(manager.INDEX_NODES) > 0


def pubsub_check() -> bool:
Expand Down
7 changes: 1 addition & 6 deletions nucliadb/src/nucliadb/ingest/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

class DriverConfig(Enum):
PG = "pg"
LOCAL = "local"
NOT_SET = "notset" # setting not provided

@classmethod
Expand All @@ -40,11 +39,7 @@ def _missing_(cls, value):


class DriverSettings(BaseSettings):
driver: DriverConfig = Field(default=DriverConfig.NOT_SET, description="K/V storage driver")
driver_local_url: Optional[str] = Field(
default=None,
description="Local path to store data on file system. Example: /nucliadb/data/main",
)
driver: DriverConfig = Field(default=DriverConfig.PG, description="K/V storage driver")
driver_pg_url: Optional[str] = Field(
default=None,
description="PostgreSQL DSN. The connection string to the PG server. Example: postgres://username:password@postgres:5432/nucliadb.", # noqa
Expand Down
3 changes: 1 addition & 2 deletions nucliadb/src/nucliadb/search/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from nucliadb.search import API_PREFIX
from nucliadb.search.api.v1.router import api as api_v1
from nucliadb.search.lifecycle import lifespan
from nucliadb.search.settings import settings
from nucliadb_telemetry import errors
from nucliadb_telemetry.fastapi.utils import (
client_disconnect_handler,
Expand Down Expand Up @@ -106,7 +105,7 @@ async def node_members(request: Request) -> JSONResponse:


async def alive(request: Request) -> JSONResponse:
if len(manager.get_index_nodes()) == 0 and settings.driver != "local":
if len(manager.get_index_nodes()) == 0:
return JSONResponse({"status": "error"}, status_code=503)
else:
return JSONResponse({"status": "ok"})
Expand Down
11 changes: 1 addition & 10 deletions nucliadb/src/nucliadb/standalone/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ def config_standalone_driver(nucliadb_args: Settings):

if ingest_settings.driver == DriverConfig.NOT_SET:
# no driver specified, for standalone, we force defaulting to local here
ingest_settings.driver = DriverConfig.LOCAL

if ingest_settings.driver == DriverConfig.LOCAL and ingest_settings.driver_local_url is None:
# also provide default path for local driver when none provided
ingest_settings.driver_local_url = "./data/main"
ingest_settings.driver = DriverConfig.PG

if storage_settings.file_backend == FileBackendConfig.NOT_SET:
# no driver specified, for standalone, we try to automate some settings here
Expand All @@ -57,11 +53,6 @@ def config_standalone_driver(nucliadb_args: Settings):
if storage_settings.file_backend == FileBackendConfig.LOCAL and storage_settings.local_files is None:
storage_settings.local_files = "./data/blob"

if ingest_settings.driver_local_url is not None and not os.path.isdir(
ingest_settings.driver_local_url
):
os.makedirs(ingest_settings.driver_local_url, exist_ok=True)

# need to force inject this to env var
if "DATA_PATH" not in os.environ:
os.environ["DATA_PATH"] = nucliadb_args.data_path
Expand Down
Loading
Loading