Skip to content

Commit 37bda6f

Browse files
committed
Make mk_podman 3.8 compat
CMK-33079 Change-Id: Ie8b5bc5d43d3f4bd9bda5e2aed980cb6d4c51bc4
1 parent 96f2f94 commit 37bda6f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

agents/plugins/mk_podman.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Copyright (C) 2025 Checkmk GmbH - License: GNU General Public License v2
33
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
44
# conditions defined in the file COPYING, which is part of this source code package.
5+
from __future__ import annotations
6+
57
import argparse
68
import configparser
79
import json
@@ -12,18 +14,19 @@
1214
import socket
1315
import subprocess
1416
import sys
15-
from collections.abc import Callable, Mapping, Sequence
17+
from collections.abc import Mapping, Sequence
1618
from dataclasses import dataclass
1719
from enum import Enum
1820
from pathlib import Path
1921
from shutil import which
20-
from typing import Any, Literal, TypedDict, TypeVar, Union
22+
from typing import Any, Callable, Literal, TypedDict, TypeVar, Union # noqa: UP035
23+
24+
_F = TypeVar("_F", bound=Callable[..., object])
2125

2226
# override decorator is only available in Python 3.12+
2327
try:
2428
from typing import override
2529
except ImportError:
26-
_F = TypeVar("_F", bound=Callable[..., object])
2730

2831
def override(func: _F, /) -> _F:
2932
return func
@@ -34,7 +37,7 @@ def override(func: _F, /) -> _F:
3437
LOGGER = logging.getLogger(__name__)
3538

3639

37-
def parse_arguments(argv: list[str] | None = None) -> argparse.Namespace:
40+
def parse_arguments(argv: Sequence[str] | None = None) -> argparse.Namespace:
3841
parser = argparse.ArgumentParser(prog="mk_podman", description="Checkmk Podman agent plugin")
3942
parser.add_argument("--debug", action="store_true", help="Debug mode: raise Python exceptions")
4043
parser.add_argument(
@@ -185,7 +188,7 @@ def load_cfg(cfg_file: Path = DEFAULT_CFG_FILE) -> Union[PodmanConfig, None]:
185188

186189
def get_socket_owner(socket_path: Path) -> Union[str, None]:
187190
try:
188-
return socket_path.owner()
191+
return pwd.getpwuid(os.stat(socket_path).st_uid).pw_name
189192
except (OSError, KeyError):
190193
return None
191194

0 commit comments

Comments
 (0)