Skip to content

Add podman socket compatability - #68867

Closed
j0hax wants to merge 2 commits into
saltstack:3008.xfrom
j0hax:3007.x
Closed

j0hax wants to merge 2 commits into
saltstack:3008.xfrom
j0hax:3007.x

Conversation

@j0hax

@j0hax j0hax commented Mar 31, 2026

Copy link
Copy Markdown

What does this PR do?

This PR checks to see if the docker socket is actually a Podman instance emulating docker.

What issues does this PR fix or reference?

Workaround for #67528

Previous Behavior

Podman support was flaky

New Behavior

If and only if Podman is detected, some adjustments are made, e.g. filtering environment variables that only Podman uses.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

@j0hax
j0hax requested a review from a team as a code owner March 31, 2026 12:23

@dwoz dwoz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs an issue and changelog.

@dwoz dwoz added the test:full Run the full test suite label Apr 5, 2026
@dwoz dwoz added this to the Chlorine v3007.15 milestone Jun 26, 2026
@dwoz
dwoz changed the base branch from 3007.x to 3006.x July 3, 2026 00:36
j0hax and others added 2 commits July 2, 2026 17:37
- Remove invalid assert_hostname kwarg from docker.tls.TLSConfig (E1123)
- Fix dangerous mutable default argument in _filter_podman_prefixes (W0102)
- Remove trailing newline at end of file (C0305)
- Clean up dead commented-out code; apply black formatting
- Add changelog/68867.added.md
- Add unit tests for _filter_podman_prefixes, Annotations ignore,
  Binds and CapDrop ordering in compare_containers
Comment thread salt/modules/dockermod.py
Comment on lines +311 to +316
res = []
for item in val:
if not any(item.startswith(prefix) for prefix in prefixes):
res.append(item)
else:
log.warning("Filtering Podman-specific value %s", item)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Issue: item.startswith(prefix) checks the raw KEY=value string. If a user has an environment variable like HOME_FOLDER=/opt, it will accidentally match the prefix "HOME" and get dropped. Additionally, log.warning inside a loop will flood minion logs on every state evaluation.

The Fix: Check against f"{prefix}=" or split the environment string to isolate the key, and downgrade the log level to log.debug.

    res = []
    for item in val:
        # Split on the first '=' to get the environment variable name
        key = item.split("=", 1)[0] if "=" in item else item
        if key not in prefixes:
            res.append(item)
        else:
            log.debug("Filtering Podman-specific environment variable: %s", item)

    return sorted(res)

Comment thread salt/modules/dockermod.py
Comment on lines +1031 to +1036
if item == "Binds":
val1 = sorted(val1)
val2 = sorted(val2)
if item == "CapDrop":
val1 = sorted(val1)
val2 = sorted(val2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Issue: If a container doesn't have any volume Binds or dropped capabilities (CapDrop), Docker or Podman may return None (or the key might be absent, defaulting to None in some blocks). Passing None into sorted() will immediately raise a TypeError: 'NoneType' object is not iterable.

The Fix: Provide an inline fallback empty list [] if the value evaluates to None or is falsy.

            if item in ("Binds", "CapDrop"):
                val1 = sorted(val1) if val1 else []
                val2 = sorted(val2) if val2 else []

Comment thread salt/modules/dockermod.py
Comment on lines +1071 to +1076
if item == "Binds":
val1 = sorted(val1)
val2 = sorted(val2)
if item == "CapDrop":
val1 = sorted(val1)
val2 = sorted(val2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the above comment:

            if item in ("Binds", "CapDrop"):
                val1 = sorted(val1) if val1 else []
                val2 = sorted(val2) if val2 else []

@twangboy

twangboy commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

We are no longer accepting bug fixes on the 3006.x branch. Please rebase against the 3008.x branch.

@dwoz

dwoz commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@j0hax 3006.x has entered security only. Please rebase these changes on 3008.x

@dwoz

dwoz commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Closing — 3006.x has entered security-only and this change doesn't apply or port cleanly to 3008.x. Reopen a fresh PR against 3008.x if you'd like to continue.

This branch had an error being deployed

1 failed deployment
ci — b01fb80b Deployed Jul 4, 2026 by dwoz via Build Onedir Packages / Windows (amd64) #25124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants