snapm: fix Manager.split_snapshot_sets() with empty sources#180
Merged
snapm: fix Manager.split_snapshot_sets() with empty sources#180
Conversation
The snapm.manager.Manger.split_snapshot_sets() method checks whether the
original snapshot set would be empty after the operation and raises an
error if this is the case. There is no corresponding check to ensure
that the destination snapshot set is not empty (i.e. the sources passed
to the split_snapshot_set() method were empty).
The snapm.command wrappers already require the sources argument:
root@localhost:~/src/git/snapm# snapm snapset split upgrade noupgrade
usage: snapm snapset split [-h] NAME NEW_NAME SOURCE [SOURCE ...]
snapm snapset split: error: the following arguments are required: SOURCE
But the API does not enforce this, leading to a snapshot set with no
sources and NrSnapshots == 0:
>>> p = m.split_snapshot_set("upgrade", "noupgrade", [])
DEBUG - Blocking termination signals {<Signals.SIGINT: 2>, <Signals.SIGTERM: 15>}
INFO - Attempting to split snapshot set 'upgrade'
DEBUG - Splitting snapshot from snapshot set 'upgrade'
INFO - Attempting rename for snapshot set 'upgrade' to 'noupgrade'
DEBUG - Unblocking termination signals {<Signals.SIGINT: 2>, <Signals.SIGTERM: 15>}
>>> p
<snapm._snapm.SnapshotSet object at 0x7eff5a90d220>
>>> print(p)
SnapsetName: noupgrade
Sources:
NrSnapshots: 0
Time: 2025-04-01 15:02:37
UUID: fab385b4-5912-54f6-8458-9b487eaf7b50
Status: Active
Autoactivate: yes
Bootable: no
In practice this makes the call a no-op but it's pointless and confusing
to allow this combination of arguments: raise a SnapmArgumentError if
the source_specs list is empty or None.
Fixes: a32e85f
Related: #98, #174
Resolves: #179
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
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
snapm.manager.Manger.split_snapshot_sets()method checks whether the original snapshot set would be empty after the operation and raises an error if this is the case. There is no corresponding check to ensure that the destination snapshot set is not empty (i.e. the sources passed to thesplit_snapshot_set()method were empty).The snapm.command wrappers already require the sources argument:
root@localhost:~/src/git/snapm# snapm snapset split upgrade noupgrade usage: snapm snapset split [-h] NAME NEW_NAME SOURCE [SOURCE ...] snapm snapset split: error: the following arguments are required: SOURCEBut the API does not enforce this, leading to a snapshot set with no sources and NrSnapshots == 0:
In practice this makes the call a no-op but it's pointless and confusing to allow this combination of arguments: raise a SnapmArgumentError if the source_specs list is empty or None.
Fixes: a32e85f
Related: #98, #174
Resolves: #179