Repository navigation
Conversation
dwoz
left a comment
There was a problem hiding this comment.
needs an issue and changelog.
- 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
| 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) |
There was a problem hiding this comment.
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)| if item == "Binds": | ||
| val1 = sorted(val1) | ||
| val2 = sorted(val2) | ||
| if item == "CapDrop": | ||
| val1 = sorted(val1) | ||
| val2 = sorted(val2) |
There was a problem hiding this comment.
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 []| if item == "Binds": | ||
| val1 = sorted(val1) | ||
| val2 = sorted(val2) | ||
| if item == "CapDrop": | ||
| val1 = sorted(val1) | ||
| val2 = sorted(val2) |
There was a problem hiding this comment.
Related to the above comment:
if item in ("Binds", "CapDrop"):
val1 = sorted(val1) if val1 else []
val2 = sorted(val2) if val2 else []|
We are no longer accepting bug fixes on the 3006.x branch. Please rebase against the 3008.x branch. |
|
@j0hax 3006.x has entered security only. Please rebase these changes on 3008.x |
|
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. |
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