ap: Raise dbus timeout

With some recent changes on Azure Agent the default DBus call
timeout is not good enough. For example, in case of
`InstallDNSSECFirst_1_to_5` job hostnamectl received reply in ~20sec,
but later it increased to ~30sec (more subjobs - more time to reply).
It's good to raise this timeout to be more protected against minimum
performance times.

https://www.freedesktop.org/software/systemd/man/sd_bus_set_method_call_timeout.html#Description

Fixes: https://pagure.io/freeipa/issue/9207
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Stanislav Levin 2022-07-25 12:28:22 +03:00 committed by Rob Crittenden
parent 3237ade3d2
commit 0e8bde3175

View File

@ -12,7 +12,7 @@ from jinja2 import Template
from typing import NamedTuple, TYPE_CHECKING from typing import NamedTuple, TYPE_CHECKING
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import List, Tuple, Union from typing import List, Tuple, Union, Dict
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
@ -77,14 +77,19 @@ class Container:
return self._ipv6 return self._ipv6
def execute( def execute(
self, args: Union[str, List[str]], raiseonerr: bool = True self,
args: Union[str, List[str]],
raiseonerr: bool = True,
env: Union[Dict[str, str], List[str], None] = None,
) -> ExecRunReturn: ) -> ExecRunReturn:
""" """
Exec an arbitrary command within container Exec an arbitrary command within container
""" """
dcont = self.dclient.containers.get(self.name) dcont = self.dclient.containers.get(self.name)
logging.info("%s: run: %s", dcont.name, args) logging.info("%s: run: %s", dcont.name, args)
result: ExecRunReturn = dcont.exec_run(args, demux=True) result: ExecRunReturn = dcont.exec_run(
args, demux=True, environment=env
)
if result.output[0] is not None: if result.output[0] is not None:
logging.info("%s: %s", dcont.name, result.output[0]) logging.info("%s: %s", dcont.name, result.output[0])
logging.info("%s: result: %s", dcont.name, result.exit_code) logging.info("%s: result: %s", dcont.name, result.exit_code)
@ -127,13 +132,13 @@ class ContainersGroup:
for c in range(1, self.scale + 1) for c in range(1, self.scale + 1)
] ]
def execute_all(self, args): def execute_all(self, args, env=None):
""" """
Sequentially exec an arbitrary command within every container of group Sequentially exec an arbitrary command within every container of group
""" """
results = [] results = []
for cont in self.containers: for cont in self.containers:
results.append(cont.execute(args)) results.append(cont.execute(args, env=env))
return results return results
def ips(self): def ips(self):
@ -199,7 +204,8 @@ class ContainersGroup:
cont.execute(cmd) cont.execute(cmd)
cmd = ["hostnamectl", "set-hostname", cont.hostname] cmd = ["hostnamectl", "set-hostname", cont.hostname]
cont.execute(cmd) # default timeout (25s) maybe not enough
cont.execute(cmd, env={"SYSTEMD_BUS_TIMEOUT": "50"})
def setup_resolvconf(self): def setup_resolvconf(self):
""" """
@ -331,7 +337,7 @@ class Controller(Container):
return self._master_container return self._master_container
def execute(self, args): def execute(self, args, env=None):
""" """
Execute a command on controller (either master or local machine) Execute a command on controller (either master or local machine)
""" """
@ -339,7 +345,7 @@ class Controller(Container):
proc = subprocess.run(args, check=True, capture_output=True) proc = subprocess.run(args, check=True, capture_output=True)
return [proc.stdout.decode().rstrip().strip("'")] return [proc.stdout.decode().rstrip().strip("'")]
return self.master_container.execute(args) return self.master_container.execute(args, env=env)
def setup_hosts(self): def setup_hosts(self):
""" """