From f345ef9dda5971769aac3c5f661b8d6025067086 Mon Sep 17 00:00:00 2001 From: Gregory Thiemonge Date: Thu, 31 Oct 2024 08:36:54 +0000 Subject: [PATCH] Fix default values for nested structs Setting the default values following the guidelines [0] It fixes an issue that happens when setting a field in the struct, it also resets the other settings regardless of their default values. [0] https://github.com/openstack-k8s-operators/dev-docs/blob/417ed0a8ce8ee48de370aa3c6a964fcbdf802d3d/developer.md#defaulting-structs Note: the backport doesn't update tests/kuttl/tests/octavia_scale/00-test-resources.yaml which doesn't exist in 18.0-fr1 JIRA: OSPRH-11092 --- api/bases/octavia.openstack.org_octavias.yaml | 2 ++ api/v1beta1/octavia_types.go | 2 ++ config/crd/bases/octavia.openstack.org_octavias.yaml | 2 ++ config/samples/octavia_v1beta1_octavia.yaml | 3 +++ tests/kuttl/common/assert_sample_deployment.yaml | 5 +++++ 5 files changed, 14 insertions(+) diff --git a/api/bases/octavia.openstack.org_octavias.yaml b/api/bases/octavia.openstack.org_octavias.yaml index 359d8fdc..c1510f4a 100644 --- a/api/bases/octavia.openstack.org_octavias.yaml +++ b/api/bases/octavia.openstack.org_octavias.yaml @@ -124,6 +124,7 @@ spec: type: string type: array createDefaultLbMgmtNetwork: + default: true description: CreateDefaultLbMgmtNetwork - when True, octavia-operator creates a Management Network for the default Availability Zone of the control plane. Can be set to false when deploying OpenStack @@ -136,6 +137,7 @@ spec: Attachment Definition type: string manageLbMgmtNetworks: + default: true description: ManageLbMgmtNetworks - when True, octavia-operator creates the Neutron resources needed for its Management Network type: boolean diff --git a/api/v1beta1/octavia_types.go b/api/v1beta1/octavia_types.go index b3d46ebe..da3c26fe 100644 --- a/api/v1beta1/octavia_types.go +++ b/api/v1beta1/octavia_types.go @@ -230,10 +230,12 @@ type PasswordSelector struct { // OctaviaLbMgmtNetworks Settings for Octavia management networks type OctaviaLbMgmtNetworks struct { // +kubebuilder:validation:Optional + // +kubebuilder:default=true // ManageLbMgmtNetworks - when True, octavia-operator creates the Neutron resources needed for its Management Network ManageLbMgmtNetworks bool `json:"manageLbMgmtNetworks"` // +kubebuilder:validation:Optional + // +kubebuilder:default=true // CreateDefaultLbMgmtNetwork - when True, octavia-operator creates a // Management Network for the default Availability Zone of the control // plane. Can be set to false when deploying OpenStack in DCN mode. diff --git a/config/crd/bases/octavia.openstack.org_octavias.yaml b/config/crd/bases/octavia.openstack.org_octavias.yaml index 359d8fdc..c1510f4a 100644 --- a/config/crd/bases/octavia.openstack.org_octavias.yaml +++ b/config/crd/bases/octavia.openstack.org_octavias.yaml @@ -124,6 +124,7 @@ spec: type: string type: array createDefaultLbMgmtNetwork: + default: true description: CreateDefaultLbMgmtNetwork - when True, octavia-operator creates a Management Network for the default Availability Zone of the control plane. Can be set to false when deploying OpenStack @@ -136,6 +137,7 @@ spec: Attachment Definition type: string manageLbMgmtNetworks: + default: true description: ManageLbMgmtNetworks - when True, octavia-operator creates the Neutron resources needed for its Management Network type: boolean diff --git a/config/samples/octavia_v1beta1_octavia.yaml b/config/samples/octavia_v1beta1_octavia.yaml index 93155e4c..4680e6eb 100644 --- a/config/samples/octavia_v1beta1_octavia.yaml +++ b/config/samples/octavia_v1beta1_octavia.yaml @@ -10,6 +10,9 @@ spec: rabbitMqClusterName: rabbitmq secret: osp-secret preserveJobs: false + lbMgmtNetwork: + availabilityZones: + - zone-1 customServiceConfig: | [DEFAULT] debug = true diff --git a/tests/kuttl/common/assert_sample_deployment.yaml b/tests/kuttl/common/assert_sample_deployment.yaml index c073bdaf..bc3b2a29 100644 --- a/tests/kuttl/common/assert_sample_deployment.yaml +++ b/tests/kuttl/common/assert_sample_deployment.yaml @@ -23,6 +23,11 @@ spec: preserveJobs: false secret: osp-secret serviceUser: octavia + lbMgmtNetwork: + availabilityZones: + - zone-1 + manageLbMgmtNetworks: true + createDefaultLbMgmtNetwork: true octaviaAPI: customServiceConfig: | [DEFAULT]