mirror of
https://github.com/saltstack/salt.git
synced 2025-04-10 14:51:40 +00:00
Set virtual grain in Podman systemd container
Some checks failed
CI / Prepare Workflow Run (push) Has been cancelled
CI / Pre-Commit (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / NSIS Tests (push) Has been cancelled
CI / Prepare Release: (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / Build Source Tarball (push) Has been cancelled
CI / Build Onedir Dependencies (push) Has been cancelled
CI / Build Salt Onedir (push) Has been cancelled
CI / Build Packages (push) Has been cancelled
CI / CI Deps (push) Has been cancelled
CI / Test Package (push) Has been cancelled
CI / Test Salt (push) Has been cancelled
CI / Combine Code Coverage (push) Has been cancelled
CI / Set the Pipeline Exit Status (push) Has been cancelled
Some checks failed
CI / Prepare Workflow Run (push) Has been cancelled
CI / Pre-Commit (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / NSIS Tests (push) Has been cancelled
CI / Prepare Release: (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / Build Source Tarball (push) Has been cancelled
CI / Build Onedir Dependencies (push) Has been cancelled
CI / Build Salt Onedir (push) Has been cancelled
CI / Build Packages (push) Has been cancelled
CI / CI Deps (push) Has been cancelled
CI / Test Package (push) Has been cancelled
CI / Test Salt (push) Has been cancelled
CI / Combine Code Coverage (push) Has been cancelled
CI / Set the Pipeline Exit Status (push) Has been cancelled
Correctly handle the systemd-detect-virt output to identify a Podman container running systemd as what it is instead of as a physical machine. Signed-off-by: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
This commit is contained in:
parent
d09a741c4e
commit
24a58e8211
3 changed files with 36 additions and 0 deletions
1
changelog/67733.fixed.md
Normal file
1
changelog/67733.fixed.md
Normal file
|
@ -0,0 +1 @@
|
|||
Set correct virtual grain in systemd based Podman containers
|
|
@ -929,6 +929,10 @@ def _virtual(osdata):
|
|||
grains["virtual"] = "container"
|
||||
grains["virtual_subtype"] = "LXC"
|
||||
break
|
||||
elif "podman" in output:
|
||||
grains["virtual"] = "container"
|
||||
grains["virtual_subtype"] = "Podman"
|
||||
break
|
||||
elif "amazon" in output:
|
||||
grains["virtual"] = "Nitro"
|
||||
grains["virtual_subtype"] = "Amazon EC2"
|
||||
|
|
|
@ -1847,6 +1847,37 @@ def test_lxc_virtual_with_virt_what():
|
|||
assert ret["virtual_subtype"] == "LXC"
|
||||
|
||||
|
||||
@pytest.mark.skip_on_windows
|
||||
def test_podman_virtual_with_systemd_detect_virt():
|
||||
"""
|
||||
Test if virtual grains are parsed correctly in Podman using systemd-detect-virt.
|
||||
"""
|
||||
|
||||
def _which_side_effect(path):
|
||||
if path == "systemd-detect-virt":
|
||||
return "/usr/bin/systemd-detect-virt"
|
||||
return None
|
||||
|
||||
with patch.object(
|
||||
salt.utils.platform, "is_windows", MagicMock(return_value=False)
|
||||
), patch.object(
|
||||
salt.utils.path,
|
||||
"which",
|
||||
MagicMock(return_value=True, side_effect=_which_side_effect),
|
||||
), patch.dict(
|
||||
core.__salt__,
|
||||
{
|
||||
"cmd.run_all": MagicMock(
|
||||
return_value={"pid": 78, "retcode": 0, "stderr": "", "stdout": "podman"}
|
||||
)
|
||||
},
|
||||
):
|
||||
osdata = {"kernel": "test"}
|
||||
ret = core._virtual(osdata)
|
||||
assert ret["virtual"] == "container"
|
||||
assert ret["virtual_subtype"] == "Podman"
|
||||
|
||||
|
||||
@pytest.mark.skip_on_windows
|
||||
def test_container_inside_virtual_machine():
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue