From 4a8bf8da27295d6fcca4be8cae05aedfe48d7cf3 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Sun, 16 Jun 2024 23:47:50 -0400 Subject: [PATCH] fix(lxc): use default rootfs size (4Gb) prevents creation of mount points (#1398) Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- .../resource_virtual_environment_container.tf | 2 +- fwprovider/test/resource_container_test.go | 8 ++++++- proxmoxtf/resource/container/container.go | 22 +++++++++---------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/example/resource_virtual_environment_container.tf b/example/resource_virtual_environment_container.tf index 4ad06996..9e2f6f42 100644 --- a/example/resource_virtual_environment_container.tf +++ b/example/resource_virtual_environment_container.tf @@ -5,7 +5,7 @@ resource "proxmox_virtual_environment_container" "example_template" { disk { datastore_id = element(data.proxmox_virtual_environment_datastores.example.datastore_ids, index(data.proxmox_virtual_environment_datastores.example.datastore_ids, "local-lvm")) - size = 10 + size = 4 } mount_point { diff --git a/fwprovider/test/resource_container_test.go b/fwprovider/test/resource_container_test.go index c337b449..bcb95497 100644 --- a/fwprovider/test/resource_container_test.go +++ b/fwprovider/test/resource_container_test.go @@ -67,7 +67,13 @@ resource "proxmox_virtual_environment_container" "test_container" { disk { datastore_id = "local-lvm" - size = 8 + size = 4 + } + + mount_point { + volume = "local-lvm" + size = "4G" + path = "mnt/local" } description = <<-EOT diff --git a/proxmoxtf/resource/container/container.go b/proxmoxtf/resource/container/container.go index 702b8545..234a4568 100644 --- a/proxmoxtf/resource/container/container.go +++ b/proxmoxtf/resource/container/container.go @@ -1384,17 +1384,6 @@ func containerCreateCustom(ctx context.Context, d *schema.ResourceData, m interf diskDatastoreID := diskBlock[mkDiskDatastoreID].(string) - var rootFS *containers.CustomRootFS - - diskSize := diskBlock[mkDiskSize].(int) - if diskSize != dvDiskSize && diskDatastoreID != "" { - // This is a special case where the rootfs size is set to a non-default value at creation time. - // see https://pve.proxmox.com/pve-docs/chapter-pct.html#_storage_backed_mount_points - rootFS = &containers.CustomRootFS{ - Volume: fmt.Sprintf("%s:%d", diskDatastoreID, diskSize), - } - } - features, err := containerGetFeatures(container, d) if err != nil { return diag.FromErr(err) @@ -1594,6 +1583,17 @@ func containerCreateCustom(ctx context.Context, d *schema.ResourceData, m interf mountPointArray = append(mountPointArray, mountPointObject) } + var rootFS *containers.CustomRootFS + + diskSize := diskBlock[mkDiskSize].(int) + if diskDatastoreID != "" && (diskSize != dvDiskSize || len(mountPointArray) > 0) { + // This is a special case where the rootfs size is set to a non-default value at creation time. + // see https://pve.proxmox.com/pve-docs/chapter-pct.html#_storage_backed_mount_points + rootFS = &containers.CustomRootFS{ + Volume: fmt.Sprintf("%s:%d", diskDatastoreID, diskSize), + } + } + networkInterface := d.Get(mkNetworkInterface).([]interface{}) networkInterfaceArray := make(containers.CustomNetworkInterfaceArray, len(networkInterface))