Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ocp_resources/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(
included_namespaces: list[str] | None = None,
excluded_resources: list[str] | None = None,
snapshot_move_data: bool = False,
default_volumes_to_fs_backup: bool | None = None,
storage_location: str = "",
**kwargs: Any,
):
Expand All @@ -34,6 +35,7 @@ def __init__(
self.excluded_resources = excluded_resources
self.snapshot_move_data = snapshot_move_data
self.storage_location = storage_location
self.default_volumes_to_fs_backup = default_volumes_to_fs_backup

def to_dict(self) -> None:
super().to_dict()
Expand All @@ -53,3 +55,7 @@ def to_dict(self) -> None:

if self.storage_location:
spec_dict["storageLocation"] = self.storage_location

spec_dict["defaultVolumesToFsBackup"] = (
self.default_volumes_to_fs_backup if self.default_volumes_to_fs_backup is not None else False
)
Comment on lines +59 to +61
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

defaultVolumesToFsBackup is always emitted, even when the caller never set it — inconsistent with all other optional fields.

Every other optional field in to_dict() is guarded by a truthiness or existence check and is omitted from the spec when not provided. This field unconditionally writes defaultVolumesToFsBackup: false whenever default_volumes_to_fs_backup is None, which can silently override a server-side or cluster-level default that differs from false.

The bool | None = None signature already signals "this field is optional"; the serialisation should honour that by only emitting the key when the caller explicitly provides a value (including an explicit False).

♻️ Proposed fix
-            spec_dict["defaultVolumesToFsBackup"] = (
-                self.default_volumes_to_fs_backup if self.default_volumes_to_fs_backup is not None else False
-            )
+            if self.default_volumes_to_fs_backup is not None:
+                spec_dict["defaultVolumesToFsBackup"] = self.default_volumes_to_fs_backup
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ocp_resources/backup.py` around lines 59 - 61, In to_dict() fix the
unconditional emission of spec_dict["defaultVolumesToFsBackup"] — instead of
always writing False when self.default_volumes_to_fs_backup is None, only set
spec_dict["defaultVolumesToFsBackup"] when self.default_volumes_to_fs_backup is
not None (so an explicit False is preserved but None omits the key); locate the
logic around the default_volumes_to_fs_backup attribute in the to_dict() method
and change the assignment to a conditional presence check before adding the
"defaultVolumesToFsBackup" key.