Skip to content

Commit

Permalink
Shorter time for podman stop
Browse files Browse the repository at this point in the history
Those are containers to be thrown away, lets stop them much faster.
  • Loading branch information
lukaszachy committed Dec 4, 2023
1 parent afae40b commit 8c43256
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tmt/steps/provision/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
DEFAULT_USER = "root"
DEFAULT_PULL_ATTEMPTS = 5
DEFAULT_PULL_INTERVAL = 5
# podman default stop time is 10s
DEFAULT_STOP_TIME = 1


@dataclasses.dataclass
Expand Down Expand Up @@ -72,6 +74,16 @@ class PodmanGuestData(tmt.steps.provision.GuestData):
""",
normalize=tmt.utils.normalize_int)

stop_time: int = field(
default=DEFAULT_STOP_TIME,
option='--stop-time',
metavar='SECONDS',
help=f"""
How long to wait before forcibly stopping the container,
{DEFAULT_STOP_TIME} seconds by default.
""",
normalize=tmt.utils.normalize_int)


@dataclasses.dataclass
class ProvisionPodmanData(PodmanGuestData, tmt.steps.provision.ProvisionStepData):
Expand All @@ -90,6 +102,7 @@ class GuestContainer(tmt.Guest):
parent: tmt.steps.Step
pull_attempts: int
pull_interval: int
stop_time: int
logger: tmt.log.Logger

@property
Expand Down Expand Up @@ -361,7 +374,8 @@ def pull(
def stop(self) -> None:
""" Stop provisioned guest """
if self.container:
self.podman(Command('container', 'stop', self.container))
self.podman(Command('container', 'stop', '--time',
str(self.stop_time), self.container))
self.info('container', 'stopped', 'green')

def remove(self) -> None:
Expand Down

0 comments on commit 8c43256

Please sign in to comment.