Skip to content
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
4 changes: 2 additions & 2 deletions src/drunc/controller/children_interface/child_node.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from druncschema.controller_pb2 import Status
from druncschema.description_pb2 import OldDescription
from druncschema.request_response_pb2 import Response

from drunc.connectivity_service.exceptions import ApplicationLookupUnsuccessful
Expand All @@ -16,7 +17,6 @@
)

from druncschema.request_response_pb2 import ( # isort: skip
Description,
ResponseFlag,
)
from druncschema.token_pb2 import Token # isort: skip
Expand Down Expand Up @@ -98,7 +98,7 @@ def describe(self, token: Token) -> Response:
descriptionType = self.configuration.data.controller.application_name
descriptionName = self.configuration.data.controller.id

d = Description(
d = OldDescription(
type=descriptionType,
name=descriptionName,
endpoint=self.get_endpoint(),
Expand Down
5 changes: 3 additions & 2 deletions src/drunc/controller/children_interface/grpc_child.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import grpc
from druncschema.controller_pb2_grpc import ControllerStub
from druncschema.request_response_pb2 import Description, Response
from druncschema.description_pb2 import OldDescription
from druncschema.request_response_pb2 import Response

from drunc.broadcast.client.broadcast_handler import BroadcastHandler
from drunc.broadcast.client.configuration import BroadcastClientConfHandler
Expand Down Expand Up @@ -45,7 +46,7 @@ def __init__(self, name, configuration: gRCPChildConfHandler, init_token, uri):
self.channel = grpc.insecure_channel(self.uri)
self.controller = ControllerStub(self.channel)

desc = Description()
desc = OldDescription()
ntries = 20

for itry in range(ntries):
Expand Down
5 changes: 3 additions & 2 deletions src/drunc/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
Status,
)
from druncschema.controller_pb2_grpc import ControllerServicer
from druncschema.description_pb2 import OldDescription
from druncschema.generic_pb2 import PlainText, Stacktrace
from druncschema.opmon.generic_pb2 import RunInfo
from druncschema.request_response_pb2 import Description, Response, ResponseFlag
from druncschema.request_response_pb2 import Response, ResponseFlag
from druncschema.token_pb2 import Token
from google.protobuf.any_pb2 import Any

Expand Down Expand Up @@ -611,7 +612,7 @@ def describe(

if execute_on_self:
bd = self.describe_broadcast()
d = Description(
d = OldDescription(
type="controller",
name=self.name,
endpoint=self.uri if self.uri is not None else "unknown",
Expand Down
7 changes: 5 additions & 2 deletions src/drunc/controller/controller_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
Status,
)
from druncschema.controller_pb2_grpc import ControllerStub
from druncschema.description_pb2 import OldDescription
from druncschema.generic_pb2 import PlainText
from druncschema.request_response_pb2 import Description

from drunc.utils.shell_utils import DecodedResponse, GRPCDriver

Expand Down Expand Up @@ -51,7 +51,10 @@ def describe(
self, addressed_command: AddressedCommand, timeout: int | float = 60
) -> DecodedResponse:
return self.send_command(
"describe", data=addressed_command, outformat=Description, timeout=timeout
"describe",
data=addressed_command,
outformat=OldDescription,
timeout=timeout,
)

@pack_empty_addressed_command
Expand Down
11 changes: 6 additions & 5 deletions src/drunc/controller/interface/shell_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
FSMResponseFlag,
Status,
)
from druncschema.description_pb2 import OldDescription
from druncschema.generic_pb2 import bool_msg, float_msg, int_msg, string_msg
from druncschema.request_response_pb2 import Description, ResponseFlag
from druncschema.request_response_pb2 import ResponseFlag
from rich.console import ConsoleRenderable, Group, RichCast
from rich.progress import (
BarColumn,
Expand Down Expand Up @@ -48,8 +49,8 @@ def generate_none_status() -> Status:
)


def generate_none_description() -> Description:
return Description(
def generate_none_description() -> OldDescription:
return OldDescription(
type="none",
name="none",
endpoint="none",
Expand Down Expand Up @@ -103,7 +104,7 @@ def get_status_table(status: DecodedResponse, description: DecodedResponse):
t.add_column("Endpoint")

def add_status_to_table(table, status, description, prefix):
valid_description = check_message_type(description, "Description")
valid_description = check_message_type(description, "OldDescription")
valid_status = check_message_type(status, "Status")

if not valid_description or not valid_status:
Expand Down Expand Up @@ -228,7 +229,7 @@ def controller_setup(ctx, controller_address):
"This context is not compatible with a controller, you need to add a 'took_control' bool member"
)

desc = Description()
desc = OldDescription()

timeout = 60

Expand Down
9 changes: 4 additions & 5 deletions src/drunc/process_manager/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from druncschema.authoriser_pb2 import ActionType, SystemType
from druncschema.broadcast_pb2 import BroadcastType
from druncschema.description_pb2 import CommandDescription, OldDescription
from druncschema.opmon.process_manager_pb2 import ProcessStatus
from druncschema.process_manager_pb2 import (
BootRequest,
Expand All @@ -19,8 +20,6 @@
)
from druncschema.process_manager_pb2_grpc import ProcessManagerServicer
from druncschema.request_response_pb2 import (
CommandDescription,
Description,
Request,
Response,
ResponseFlag,
Expand Down Expand Up @@ -106,7 +105,7 @@ def __init__(
name="describe",
data_type=["None"],
help="Describe self (return a list of commands, the type of endpoint, the name and session).",
return_type="request_response_pb2.Description",
return_type="description_pb2.OldDescription",
),
CommandDescription(
name="kill",
Expand Down Expand Up @@ -479,7 +478,7 @@ def flush(self, request: Request, context: ServicerContext) -> Response:
def describe(self, request: Request, context: ServicerContext) -> Response:
self.log.debug(f"{self.name} running describe")
bd = self.describe_broadcast()
d = Description(
d = OldDescription(
type="process_manager",
name=self.name,
info=self.configuration.log_path,
Expand All @@ -506,7 +505,7 @@ def _logs_impl(self, request_data: LogRequest) -> LogLines:
@authentified_and_authorised(
action=ActionType.READ, system=SystemType.PROCESS_MANAGER
) # 2nd step
def logs(self, request:Request, context:ServicerContext) -> Response:
def logs(self, request: Request, context: ServicerContext) -> Response:
"""Fetch logs for a process.

Args:
Expand Down
14 changes: 5 additions & 9 deletions src/drunc/process_manager/process_manager_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
from time import sleep

from druncschema.description_pb2 import OldDescription
from druncschema.process_manager_pb2 import (
BootRequest,
LogLines,
Expand All @@ -18,7 +19,6 @@
ProcessRestriction,
)
from druncschema.process_manager_pb2_grpc import ProcessManagerStub
from druncschema.request_response_pb2 import Description

from drunc.connectivity_service.client import ConnectivityServiceClient
from drunc.connectivity_service.exceptions import ApplicationLookupUnsuccessful
Expand Down Expand Up @@ -393,9 +393,7 @@ def terminate(
"terminate", outformat=ProcessInstanceList, timeout=timeout
)

def kill(
self, query: ProcessQuery, timeout: int | float = 60
) -> ProcessInstance:
def kill(self, query: ProcessQuery, timeout: int | float = 60) -> ProcessInstance:
return self.send_command(
"kill",
data=query,
Expand All @@ -411,9 +409,7 @@ def logs(self, req: LogRequest, timeout: int | float = 60) -> LogLines:
timeout=timeout,
)

def ps(
self, query: ProcessQuery, timeout: int | float = 60
) -> ProcessInstanceList:
def ps(self, query: ProcessQuery, timeout: int | float = 60) -> ProcessInstanceList:
return self.send_command(
"ps",
data=query,
Expand Down Expand Up @@ -441,9 +437,9 @@ def restart(
timeout=timeout,
)

def describe(self, timeout: int | float = 60) -> Description:
def describe(self, timeout: int | float = 60) -> OldDescription:
return self.send_command(
"describe",
outformat=Description,
outformat=OldDescription,
timeout=timeout,
)
55 changes: 20 additions & 35 deletions src/drunc/session_manager/session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
from pathlib import Path

from conffwk import Configuration
from druncschema.description_pb2 import CommandDescription, Description
from druncschema.request_response_pb2 import (
CommandDescription,
Description,
Request,
Response,
ResponseFlag,
)
from druncschema.session_manager_pb2 import (
Expand All @@ -22,7 +20,6 @@
from grpc import ServicerContext

from drunc.session_manager.configuration import SessionManagerConfHandler
from drunc.utils.grpc_utils import pack_to_any
from drunc.utils.utils import get_logger, pid_info_str


Expand All @@ -49,7 +46,7 @@ def __init__(self, name: str, configuration: SessionManagerConfHandler):
self.name = name
self.configuration = configuration

def describe(self, request:Request, context:ServicerContext) -> Response:
def describe(self, request: Request, context: ServicerContext) -> Description:
"""Respond with a description of this session manager service.

Args:
Expand All @@ -61,12 +58,12 @@ def describe(self, request:Request, context:ServicerContext) -> Response:
"""
self.log.debug(f"{self.name} running describe")

command_descriptions = [
commands = [
CommandDescription(
name="describe",
data_type=["None"],
help="List the methods exposed by this endpoint.",
return_type="request_response_pb2.Description",
return_type="description_pb2.Description",
),
CommandDescription(
name="list_all_sessions",
Expand All @@ -82,22 +79,19 @@ def describe(self, request:Request, context:ServicerContext) -> Response:
),
]

description = Description(
return Description(
type="session_manager",
name=self.name,
session=self.name,
commands=command_descriptions,
)

return Response(
name=self.name,
token=None,
data=pack_to_any(description),
flag=ResponseFlag.EXECUTED_SUCCESSFULLY,
commands=commands,
children=[],
flag=ResponseFlag.EXECUTED_SUCCESSFULLY,
token=None,
)

def list_all_sessions(self, request:Request, context:ServicerContext) -> Response:
def list_all_sessions(
self, request: Request, context: ServicerContext
) -> AllActiveSessions:
"""Respond with a list of all active sessions.

Args:
Expand All @@ -120,19 +114,16 @@ def list_all_sessions(self, request:Request, context:ServicerContext) -> Respons
config_key=dummy_config,
)

all_sessions = AllActiveSessions(
active_sessions=[dummy_session],
)

return Response(
return AllActiveSessions(
name=self.name,
token=None,
data=pack_to_any(all_sessions),
active_sessions=[dummy_session],
flag=ResponseFlag.EXECUTED_SUCCESSFULLY,
children=[],
)

def list_all_configs(self, request:Request, context:ServicerContext) -> Response:
def list_all_configs(
self, request: Request, context: ServicerContext
) -> AllConfigKeys:
"""Respond with a list of all available configurations.

Args:
Expand All @@ -148,12 +139,11 @@ def list_all_configs(self, request:Request, context:ServicerContext) -> Response
search_paths = getenv("DUNEDAQ_DB_PATH")
if search_paths is None:
self.log.error("DUNEDAQ_DB_PATH not set")
return Response(
return AllConfigKeys(
name=self.name,
token=None,
data=pack_to_any(None),
config_keys=[],
flag=ResponseFlag.FAILED,
children=[],
)

# Find all configuration files.
Expand All @@ -179,14 +169,9 @@ def list_all_configs(self, request:Request, context:ServicerContext) -> Response
)
configs.append(config_key)

all_configs = AllConfigKeys(
config_keys=configs,
)

return Response(
return AllConfigKeys(
name=self.name,
token=None,
data=pack_to_any(all_configs),
config_keys=configs,
flag=ResponseFlag.EXECUTED_SUCCESSFULLY,
children=[],
)
8 changes: 4 additions & 4 deletions src/drunc/session_manager/session_manager_driver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Driver for the session manager service."""

from druncschema.request_response_pb2 import Description
from druncschema.description_pb2 import Description
from druncschema.session_manager_pb2 import AllActiveSessions, AllConfigKeys
from druncschema.session_manager_pb2_grpc import SessionManagerStub
from druncschema.token_pb2 import Token
Expand Down Expand Up @@ -43,22 +43,22 @@ def describe(self) -> DecodedResponse | None:
"""Describe the session manager service.

Returns:
A decoded response object containing the description of the service.
A response containing the description of the service.
"""
return self.send_command("describe", outformat=Description)

def list_all_sessions(self) -> DecodedResponse | None:
"""List all active sessions managed by the session manager.

Returns:
A decoded response object containing a list of all active sessions.
A response containing a list of all active sessions.
"""
return self.send_command("list_all_sessions", outformat=AllActiveSessions)

def list_all_configs(self) -> DecodedResponse | None:
"""List all available configurations in the session manager.

Returns:
A decoded response object containing all available configuration keys.
A response containing all available configuration keys.
"""
return self.send_command("list_all_configs", outformat=AllConfigKeys)
Loading
Loading