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

NOMERGE Debug PRT #315

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 7 additions & 0 deletions broker/binds/containers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""A collection of classes to ease interaction with Docker and Podman libraries."""
from logzero import logger

from broker.exceptions import UserError
from broker.settings import settings

Expand Down Expand Up @@ -68,8 +70,10 @@ def __init__(self, host=None, username=None, password=None, port=22, timeout=Non
@property
def client(self):
"""Return the client instance. Create one if it does not exist."""
logger.info(f"tpapaioa ContainerBind client 1: {self._client=}")
if not isinstance(self._client, self._ClientClass):
self._client = self._ClientClass(base_url=self.uri, timeout=self.timeout)
logger.info(f"tpapaioa ContainerBind client 2: {self._client=}")
return self._client

@property
Expand Down Expand Up @@ -111,6 +115,8 @@ def create_container(self, image, command=None, **kwargs):

def execute(self, image, command=None, remove=True, **kwargs):
"""Run a container and return the raw result."""
logger.info("tpapaioa ContainerBind execute")
remove = False
return self.client.containers.run(image, command=command, remove=remove, **kwargs).decode()

def remove_container(self, container=None):
Expand Down Expand Up @@ -160,6 +166,7 @@ class PodmanBind(ContainerBind):

def __init__(self, **kwargs):
super().__init__(**kwargs)
logger.info("tpapaioa PodmanBind __init__")
from podman import PodmanClient

self._ClientClass = PodmanClient
Expand Down
1 change: 1 addition & 0 deletions broker/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def execute(self, command, timeout=None):
"""
timeout = timeout or self.default_timeout
logger.debug(f"{self.hostname} executing command: {command}")
# breakpoint()
res = self.session.run(command, timeout=timeout)
logger.debug(f"{self.hostname} command result:\n{res}")
return res
Expand Down
5 changes: 4 additions & 1 deletion broker/providers/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _host_release():
caller_host._checked_in = True


@cache
# @cache
def get_runtime(runtime_cls=None, host=None, username=None, password=None, port=None, timeout=None):
"""Return a runtime instance."""
return runtime_cls(
Expand Down Expand Up @@ -94,6 +94,7 @@ def __init__(self, **kwargs):
"Container",
f"Broker has no bind for {settings.container.runtime} containers",
)
logger.info("tpapaioa Container __init__")
self.runtime = get_runtime(
runtime_cls=self._runtime_cls,
host=settings.container.host,
Expand Down Expand Up @@ -193,6 +194,7 @@ def construct_host(self, provider_params, host_classes, **kwargs):

:return: broker object of constructed host instance
"""
# breakpoint()
logger.debug(f"constructing with {provider_params=}\n{host_classes=}\n{kwargs=}")
if not provider_params:
host_inst = host_classes[kwargs.get("type", "host")](**kwargs)
Expand Down Expand Up @@ -306,6 +308,7 @@ def run_container(self, container_host, **kwargs):
@Provider.register_action("container_app")
def execute(self, container_app, **kwargs):
"""Run a container and return the raw results."""

if not kwargs.get("name"):
kwargs["name"] = self._gen_name()
return self.runtime.execute(container_app, **kwargs)
Expand Down
Loading