Skip to content

Commit

Permalink
core: services: stop using python-based memory limiting
Browse files Browse the repository at this point in the history
This only limits virtual memory:
https://linux.die.net/man/2/setrlimit#:~:text=RLIMIT_AS,resource%20is%20unlimited.

on top of it, it is also redundant with the ulimit limiter at run-service.sh
  • Loading branch information
Williangalvani authored and patrickelectric committed Feb 19, 2024
1 parent 2cb13dc commit 274bab8
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 44 deletions.
5 changes: 1 addition & 4 deletions core/services/ardupilot_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
StackedHTTPException,
)
from commonwealth.utils.decorators import single_threaded
from commonwealth.utils.general import is_running_as_root, limit_ram_usage
from commonwealth.utils.general import is_running_as_root
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import Body, FastAPI, File, HTTPException, UploadFile, status
from fastapi.responses import HTMLResponse
Expand All @@ -31,9 +31,6 @@

FRONTEND_FOLDER = Path.joinpath(Path(__file__).parent.absolute(), "frontend")

# We need additional RAM in order to decompress the manifest file
limit_ram_usage(400)

parser = argparse.ArgumentParser(description="ArduPilot Manager service for Blue Robotics BlueOS")
parser.add_argument("-s", "--sitl", help="run SITL instead of connecting any board", action="store_true")

Expand Down
3 changes: 0 additions & 3 deletions core/services/bag_of_holding/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import dpath
import uvicorn
from commonwealth.utils.apis import GenericErrorHandlingRoute
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import Body, FastAPI, HTTPException
from fastapi import Path as FastPath
Expand All @@ -20,8 +19,6 @@
SERVICE_NAME = "bag-of-holding"
FILE_PATH = Path(appdirs.user_config_dir(SERVICE_NAME, "db.json"))

limit_ram_usage()

logging.basicConfig(handlers=[InterceptHandler()], level=0)
init_logger(SERVICE_NAME)

Expand Down
3 changes: 0 additions & 3 deletions core/services/beacon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import psutil
from commonwealth.settings.manager import Manager
from commonwealth.utils.apis import PrettyJSONResponse
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import init_logger
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
Expand All @@ -25,8 +24,6 @@

SERVICE_NAME = "beacon"

limit_ram_usage()


class AsyncRunner:
def __init__(self, ip_version: IPVersion, interface: str, interface_name: str) -> None:
Expand Down
3 changes: 0 additions & 3 deletions core/services/bridget/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import uvicorn
from commonwealth.utils.apis import GenericErrorHandlingRoute, PrettyJSONResponse
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import FastAPI, status
from fastapi.responses import HTMLResponse
Expand All @@ -15,8 +14,6 @@

SERVICE_NAME = "bridget"

limit_ram_usage()

logging.basicConfig(handlers=[InterceptHandler()], level=0)
init_logger(SERVICE_NAME)

Expand Down
3 changes: 0 additions & 3 deletions core/services/cable_guy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from commonwealth.utils.apis import GenericErrorHandlingRoute, PrettyJSONResponse
from commonwealth.utils.decorators import temporary_cache
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import Body, FastAPI
from fastapi.responses import HTMLResponse
Expand All @@ -27,8 +26,6 @@

SERVICE_NAME = "cable-guy"

limit_ram_usage()

parser = argparse.ArgumentParser(description="CableGuy service for Blue Robotics BlueOS")
parser.add_argument(
"--default_config",
Expand Down
4 changes: 1 addition & 3 deletions core/services/commander/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import uvicorn
from commonwealth.utils.apis import GenericErrorHandlingRoute
from commonwealth.utils.commands import run_command
from commonwealth.utils.general import delete_everything, limit_ram_usage
from commonwealth.utils.general import delete_everything
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import FastAPI, HTTPException, status
from fastapi.responses import HTMLResponse
Expand All @@ -22,8 +22,6 @@
SERVICE_NAME = "commander"
LOG_FOLDER_PATH = os.environ.get("BLUEOS_LOG_FOLDER_PATH", "/var/logs/blueos")

limit_ram_usage()

logging.basicConfig(handlers=[InterceptHandler()], level=0)
init_logger(SERVICE_NAME)

Expand Down
3 changes: 0 additions & 3 deletions core/services/kraken/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Any, Iterable

from commonwealth.utils.apis import GenericErrorHandlingRoute
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import FastAPI, HTTPException, status
from fastapi.responses import HTMLResponse, PlainTextResponse, StreamingResponse
Expand All @@ -32,8 +31,6 @@ def is_valid(self) -> bool:

SERVICE_NAME = "kraken"

limit_ram_usage()

logging.basicConfig(handlers=[InterceptHandler()], level=0)
init_logger(SERVICE_NAME)

Expand Down
8 changes: 1 addition & 7 deletions core/services/log_zipper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@
import time
from typing import List

from commonwealth.utils.general import (
available_disk_space_mb,
delete_everything,
limit_ram_usage,
)
from commonwealth.utils.general import available_disk_space_mb, delete_everything
from commonwealth.utils.logs import InterceptHandler, init_logger
from loguru import logger

SERVICE_NAME = "log-zipper"

limit_ram_usage()


def zip_files(files: List[str], output_path: str) -> None:
for file in files:
Expand Down
3 changes: 0 additions & 3 deletions core/services/nmea_injector/nmea_injector/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Any, List

from commonwealth.utils.apis import GenericErrorHandlingRoute, PrettyJSONResponse
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import FastAPI, status
from fastapi.responses import HTMLResponse
Expand All @@ -17,8 +16,6 @@

SERVICE_NAME = "nmea-injector"

limit_ram_usage()

parser = argparse.ArgumentParser(description="NMEA Injector service for Blue Robotics BlueOS")
parser.add_argument("-u", "--udp", type=int, help="change the default UDP input port")
parser.add_argument("-t", "--tcp", type=int, help="change the default TCP input port")
Expand Down
3 changes: 0 additions & 3 deletions core/services/pardal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@

import aiohttp
from aiohttp import web
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import InterceptHandler, init_logger
from loguru import logger

SERVICE_NAME = "pardal"

limit_ram_usage()

parser = argparse.ArgumentParser(description="Pardal, web service to help with speed and latency tests")
parser.add_argument("-p", "--port", help="Port to run web server", action="store_true", default=9120)

Expand Down
3 changes: 0 additions & 3 deletions core/services/ping/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Any, List

from commonwealth.utils.apis import GenericErrorHandlingRoute, PrettyJSONResponse
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import FastAPI, status
from fastapi.responses import HTMLResponse
Expand All @@ -20,8 +19,6 @@

SERVICE_NAME = "ping"

limit_ram_usage()

logging.basicConfig(handlers=[InterceptHandler()], level=0)
init_logger(SERVICE_NAME)

Expand Down
3 changes: 0 additions & 3 deletions core/services/versionchooser/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
import aiodocker
import connexion
from aiohttp import web
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import InterceptHandler, init_logger
from loguru import logger

from utils.chooser import STATIC_FOLDER, VersionChooser

SERVICE_NAME = "version-chooser"

limit_ram_usage()

logging.basicConfig(handlers=[InterceptHandler()], level=0)
init_logger(SERVICE_NAME)

Expand Down
3 changes: 0 additions & 3 deletions core/services/wifi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
PrettyJSONResponse,
StackedHTTPException,
)
from commonwealth.utils.general import limit_ram_usage
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import FastAPI, HTTPException, status
from fastapi.staticfiles import StaticFiles
Expand All @@ -29,8 +28,6 @@
FRONTEND_FOLDER = Path.joinpath(Path(__file__).parent.absolute(), "frontend")
SERVICE_NAME = "wifi-manager"

limit_ram_usage()

logging.basicConfig(handlers=[InterceptHandler()], level=0)
init_logger(SERVICE_NAME)

Expand Down

0 comments on commit 274bab8

Please sign in to comment.