Skip to content

Commit

Permalink
common: restore default disk backup behaviour
Browse files Browse the repository at this point in the history
In testing it was observed that the upstream disk API changes are excluding disks from Proxmox backup jobs by default (setting backup=0).
This commit reinstates the behaviour of previous versions of this packer-plugin-proxmox where disks created by Packer are enabled for backup by default.
A new ExcludeFromBackup disk field has been added to opt out of this behaviour.
  • Loading branch information
mpywell committed Jul 15, 2024
1 parent e635f0e commit 8370873
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .web-docs/components/builder/clone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ Example:
- `asyncio` (string) - Configure Asynchronous I/O. Can be `native`, `threads`, or `io_uring`.
Defaults to io_uring.

- `exclude_from_backup` (bool) - Exclude disk from Proxmox backup jobs
Defaults to false.

- `discard` (bool) - Relay TRIM commands to the underlying storage. Defaults
to false. See the
[Proxmox documentation](https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_hard_disk_discard)
Expand Down
3 changes: 3 additions & 0 deletions .web-docs/components/builder/iso/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ Example:
- `asyncio` (string) - Configure Asynchronous I/O. Can be `native`, `threads`, or `io_uring`.
Defaults to io_uring.

- `exclude_from_backup` (bool) - Exclude disk from Proxmox backup jobs
Defaults to false.

- `discard` (bool) - Relay TRIM commands to the underlying storage. Defaults
to false. See the
[Proxmox documentation](https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_hard_disk_discard)
Expand Down
3 changes: 3 additions & 0 deletions builder/proxmox/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ type diskConfig struct {
// Configure Asynchronous I/O. Can be `native`, `threads`, or `io_uring`.
// Defaults to io_uring.
AsyncIO string `mapstructure:"asyncio"`
// Exclude disk from Proxmox backup jobs
// Defaults to false.
ExcludeFromBackup bool `mapstructure:"exclude_from_backup"`
// Relay TRIM commands to the underlying storage. Defaults
// to false. See the
// [Proxmox documentation](https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_hard_disk_discard)
Expand Down
42 changes: 22 additions & 20 deletions builder/proxmox/common/config.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions builder/proxmox/common/step_start_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ func generateProxmoxDisks(disks []diskConfig, isos []ISOsConfig, cloneSourceDisk
case "K":
size = proxmox.QemuDiskSize(tmpSize)
}
backup := true
if disks[idx].ExcludeFromBackup {
backup = false
}

switch disks[idx].Type {
case "ide":
Expand All @@ -311,6 +315,7 @@ func generateProxmoxDisks(disks []diskConfig, isos []ISOsConfig, cloneSourceDisk
Format: proxmox.QemuDiskFormat(disks[idx].DiskFormat),
Discard: disks[idx].Discard,
EmulateSSD: disks[idx].SSD,
Backup: backup,
},
}
for {
Expand Down Expand Up @@ -371,6 +376,7 @@ func generateProxmoxDisks(disks []diskConfig, isos []ISOsConfig, cloneSourceDisk
Discard: disks[idx].Discard,
EmulateSSD: disks[idx].SSD,
IOThread: disks[idx].IOThread,
Backup: backup,
},
}
for {
Expand Down Expand Up @@ -400,6 +406,7 @@ func generateProxmoxDisks(disks []diskConfig, isos []ISOsConfig, cloneSourceDisk
Format: proxmox.QemuDiskFormat(disks[idx].DiskFormat),
Discard: disks[idx].Discard,
EmulateSSD: disks[idx].SSD,
Backup: backup,
},
}
for {
Expand Down Expand Up @@ -429,6 +436,7 @@ func generateProxmoxDisks(disks []diskConfig, isos []ISOsConfig, cloneSourceDisk
Format: proxmox.QemuDiskFormat(disks[idx].DiskFormat),
Discard: disks[idx].Discard,
IOThread: disks[idx].IOThread,
Backup: backup,
},
}
for {
Expand Down
Loading

0 comments on commit 8370873

Please sign in to comment.