Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The claim
How to manage files in the workload container — Write unit tests states, in the context of a host-mounted file (
testing.Mountwith asourceon the host):This asserts that writes performed by the charm inside the container propagate back to the host file backing the mount.
What this PR does
It adds a targeted refutation attempt to the
keplercharm:update-backupaction that writes to/etc/myapp/backup.yamlusing the docs' recommended library (charmlibs-pathopsContainerPath), following a common, realistic pattern: remove the existing file, then write fresh contents (unlink(missing_ok=True)thenwrite_text(data)).test_update_backup_writes_through_mount) that mounts a host file at/etc/myapp/backup.yaml, runs the action, and asserts the host file now contains the new data.What the failing test proves
tox -e unitfails on the new test: after the charm wroteupdated: data\nto the mounted path, the host file still contained the original data.Under the hood,
opstesting implements aMountas a symlink from the container's simulated filesystem to the hostsource. An in-place write (open-for-write through the symlink) does propagate to the host. But a write that replaces the file — such asunlinkthenwrite_text/push— removes the symlink from the container root and creates a fresh regular file there, leaving the host file untouched.So the claim is not universally true: it holds for in-place writes but fails for write patterns that replace the file, which is a legitimate and common way a charm might "write to" a path. The doc's blanket statement should be qualified (e.g., "writes that modify the file in place" rather than "writes to").
tox -e lintpasses; the pre-existingtest_pebble_layertest still passes.Original task for the agent:
Model: Z.ai GLM 5.2