From ccbc3d912340c68115744681223ab4c6a264a84c Mon Sep 17 00:00:00 2001 From: katexochen <49727155+katexochen@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:47:45 +0200 Subject: [PATCH] Remove exposure of qemu ip_range_start value --- cli/internal/cloudcmd/create.go | 1 - cli/internal/terraform/terraform/qemu/main.tf | 6 ++-- .../qemu/modules/instance_group/main.tf | 3 +- .../qemu/modules/instance_group/variables.tf | 5 --- .../terraform/terraform/qemu/variables.tf | 5 --- cli/internal/terraform/terraform_test.go | 1 - cli/internal/terraform/variables.go | 3 -- internal/config/config.go | 4 --- internal/config/config_doc.go | 31 ++++++++----------- 9 files changed, 17 insertions(+), 42 deletions(-) diff --git a/cli/internal/cloudcmd/create.go b/cli/internal/cloudcmd/create.go index 3c0e53c24..454746f29 100644 --- a/cli/internal/cloudcmd/create.go +++ b/cli/internal/cloudcmd/create.go @@ -169,7 +169,6 @@ func (c *Creator) createQEMU(ctx context.Context, cl terraformClient, name strin ImageFormat: config.Provider.QEMU.ImageFormat, CPUCount: config.Provider.QEMU.VCPUs, MemorySizeMiB: config.Provider.QEMU.Memory, - IPRangeStart: config.Provider.QEMU.IPRangeStart, MetadataAPIImage: config.Provider.QEMU.MetadataAPIImage, } diff --git a/cli/internal/terraform/terraform/qemu/main.tf b/cli/internal/terraform/terraform/qemu/main.tf index 77227e34b..dcabc4fa8 100644 --- a/cli/internal/terraform/terraform/qemu/main.tf +++ b/cli/internal/terraform/terraform/qemu/main.tf @@ -25,7 +25,7 @@ provider "docker" { } resource "docker_image" "qemu-metadata" { - name = "${var.metadata_api_image}" + name = var.metadata_api_image keep_locally = true } @@ -34,7 +34,7 @@ resource "docker_container" "qemu-metadata" { image = docker_image.qemu-metadata.latest network_mode = "host" rm = true - command = [ + command = [ "--network", "${var.name}-network", ] @@ -52,7 +52,6 @@ module "control_plane" { vcpus = var.vcpus memory = var.memory state_disk_size = var.state_disk_size - ip_range_start = var.ip_range_start cidr = "10.42.1.0/24" network_id = libvirt_network.constellation.id pool = libvirt_pool.cluster.name @@ -68,7 +67,6 @@ module "worker" { vcpus = var.vcpus memory = var.memory state_disk_size = var.state_disk_size - ip_range_start = var.ip_range_start cidr = "10.42.2.0/24" network_id = libvirt_network.constellation.id pool = libvirt_pool.cluster.name diff --git a/cli/internal/terraform/terraform/qemu/modules/instance_group/main.tf b/cli/internal/terraform/terraform/qemu/modules/instance_group/main.tf index 2890d2ac3..da8bc04cf 100644 --- a/cli/internal/terraform/terraform/qemu/modules/instance_group/main.tf +++ b/cli/internal/terraform/terraform/qemu/modules/instance_group/main.tf @@ -9,6 +9,7 @@ terraform { locals { state_disk_size_byte = 1073741824 * var.state_disk_size + ip_range_start = 100 } resource "libvirt_domain" "instance_group" { @@ -44,7 +45,7 @@ resource "libvirt_domain" "instance_group" { network_interface { network_id = var.network_id hostname = "${var.role}-${count.index}" - addresses = [cidrhost(var.cidr, var.ip_range_start + count.index)] + addresses = [cidrhost(var.cidr, local.ip_range_start + count.index)] wait_for_lease = true } console { diff --git a/cli/internal/terraform/terraform/qemu/modules/instance_group/variables.tf b/cli/internal/terraform/terraform/qemu/modules/instance_group/variables.tf index c80f557e7..159496ce5 100644 --- a/cli/internal/terraform/terraform/qemu/modules/instance_group/variables.tf +++ b/cli/internal/terraform/terraform/qemu/modules/instance_group/variables.tf @@ -18,11 +18,6 @@ variable "state_disk_size" { description = "size of state disk (GiB)" } -variable "ip_range_start" { - type = number - description = "first ip address to use within subnet" -} - variable "cidr" { type = string description = "subnet to use for dhcp" diff --git a/cli/internal/terraform/terraform/qemu/variables.tf b/cli/internal/terraform/terraform/qemu/variables.tf index 511e4e27d..9499cf3da 100644 --- a/cli/internal/terraform/terraform/qemu/variables.tf +++ b/cli/internal/terraform/terraform/qemu/variables.tf @@ -34,11 +34,6 @@ variable "state_disk_size" { description = "size of state disk (GiB)" } -variable "ip_range_start" { - type = number - description = "first ip address to use within subnet" -} - variable "machine" { type = string default = "q35" diff --git a/cli/internal/terraform/terraform_test.go b/cli/internal/terraform/terraform_test.go index 381573688..fca377cf2 100644 --- a/cli/internal/terraform/terraform_test.go +++ b/cli/internal/terraform/terraform_test.go @@ -45,7 +45,6 @@ func TestCreateCluster(t *testing.T) { }, CPUCount: 1, MemorySizeMiB: 1024, - IPRangeStart: 100, ImagePath: "path", ImageFormat: "format", MetadataAPIImage: "api", diff --git a/cli/internal/terraform/variables.go b/cli/internal/terraform/variables.go index b910cf90c..acbe75c58 100644 --- a/cli/internal/terraform/variables.go +++ b/cli/internal/terraform/variables.go @@ -88,8 +88,6 @@ type QEMUVariables struct { // MemorySizeMiB is the amount of memory to allocate to each node, in MiB. MemorySizeMiB int // IPRangeStart is the first IP address in the IP range to allocate to the cluster. - IPRangeStart int - // ImagePath is the path to the image to use for the nodes. ImagePath string // ImageFormat is the format of the image from ImagePath. ImageFormat string @@ -105,7 +103,6 @@ func (v *QEMUVariables) String() string { writeLinef(b, "image_format = %q", v.ImageFormat) writeLinef(b, "vcpus = %d", v.CPUCount) writeLinef(b, "memory = %d", v.MemorySizeMiB) - writeLinef(b, "ip_range_start = %d", v.IPRangeStart) writeLinef(b, "metadata_api_image = %q", v.MetadataAPIImage) return b.String() diff --git a/internal/config/config.go b/internal/config/config.go index 8e9db9e72..59da2524d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -189,9 +189,6 @@ type QEMUConfig struct { // Amount of memory per instance (MiB). Memory int `yaml:"memory" validate:"required"` // description: | - // First IP address to use within a node group's subnet. - IPRangeStart int `yaml:"ipRangeStart" validate:"required"` - // description: | // Container image to use for the QEMU metadata server. MetadataAPIImage string `yaml:"metadataAPIServer" validate:"required"` // description: | @@ -239,7 +236,6 @@ func Default() *Config { ImageFormat: "qcow2", VCPUs: 2, Memory: 2048, - IPRangeStart: 100, Measurements: copyPCRMap(qemuPCRs), MetadataAPIImage: "ghcr.io/edgelesssys/constellation/qemu-metadata-api:v2.1.0-pre.0.20220922072347-abb78344bc2a", EnforcedMeasurements: []uint32{11, 12}, diff --git a/internal/config/config_doc.go b/internal/config/config_doc.go index 1dc47af08..21fce8601 100644 --- a/internal/config/config_doc.go +++ b/internal/config/config_doc.go @@ -288,7 +288,7 @@ func init() { FieldName: "qemu", }, } - QEMUConfigDoc.Fields = make([]encoder.Doc, 8) + QEMUConfigDoc.Fields = make([]encoder.Doc, 7) QEMUConfigDoc.Fields[0].Name = "image" QEMUConfigDoc.Fields[0].Type = "string" QEMUConfigDoc.Fields[0].Note = "" @@ -309,26 +309,21 @@ func init() { QEMUConfigDoc.Fields[3].Note = "" QEMUConfigDoc.Fields[3].Description = "Amount of memory per instance (MiB)." QEMUConfigDoc.Fields[3].Comments[encoder.LineComment] = "Amount of memory per instance (MiB)." - QEMUConfigDoc.Fields[4].Name = "ipRangeStart" - QEMUConfigDoc.Fields[4].Type = "int" + QEMUConfigDoc.Fields[4].Name = "metadataAPIServer" + QEMUConfigDoc.Fields[4].Type = "string" QEMUConfigDoc.Fields[4].Note = "" - QEMUConfigDoc.Fields[4].Description = "First IP address to use within a node group's subnet." - QEMUConfigDoc.Fields[4].Comments[encoder.LineComment] = "First IP address to use within a node group's subnet." - QEMUConfigDoc.Fields[5].Name = "metadataAPIServer" - QEMUConfigDoc.Fields[5].Type = "string" + QEMUConfigDoc.Fields[4].Description = "Container image to use for the QEMU metadata server." + QEMUConfigDoc.Fields[4].Comments[encoder.LineComment] = "Container image to use for the QEMU metadata server." + QEMUConfigDoc.Fields[5].Name = "measurements" + QEMUConfigDoc.Fields[5].Type = "Measurements" QEMUConfigDoc.Fields[5].Note = "" - QEMUConfigDoc.Fields[5].Description = "Container image to use for the QEMU metadata server." - QEMUConfigDoc.Fields[5].Comments[encoder.LineComment] = "Container image to use for the QEMU metadata server." - QEMUConfigDoc.Fields[6].Name = "measurements" - QEMUConfigDoc.Fields[6].Type = "Measurements" + QEMUConfigDoc.Fields[5].Description = "Measurement used to enable measured boot." + QEMUConfigDoc.Fields[5].Comments[encoder.LineComment] = "Measurement used to enable measured boot." + QEMUConfigDoc.Fields[6].Name = "enforcedMeasurements" + QEMUConfigDoc.Fields[6].Type = "[]uint32" QEMUConfigDoc.Fields[6].Note = "" - QEMUConfigDoc.Fields[6].Description = "Measurement used to enable measured boot." - QEMUConfigDoc.Fields[6].Comments[encoder.LineComment] = "Measurement used to enable measured boot." - QEMUConfigDoc.Fields[7].Name = "enforcedMeasurements" - QEMUConfigDoc.Fields[7].Type = "[]uint32" - QEMUConfigDoc.Fields[7].Note = "" - QEMUConfigDoc.Fields[7].Description = "List of values that should be enforced to be equal to the ones from the measurement list. Any non-equal values not in this list will only result in a warning." - QEMUConfigDoc.Fields[7].Comments[encoder.LineComment] = "List of values that should be enforced to be equal to the ones from the measurement list. Any non-equal values not in this list will only result in a warning." + QEMUConfigDoc.Fields[6].Description = "List of values that should be enforced to be equal to the ones from the measurement list. Any non-equal values not in this list will only result in a warning." + QEMUConfigDoc.Fields[6].Comments[encoder.LineComment] = "List of values that should be enforced to be equal to the ones from the measurement list. Any non-equal values not in this list will only result in a warning." } func (_ Config) Doc() *encoder.Doc {