From 1d9329bec9210f0af882f6e9344f5d0f2eef621a Mon Sep 17 00:00:00 2001 From: Brendan Shephard Date: Thu, 7 Sep 2023 14:07:31 +1000 Subject: [PATCH] Remove NetworkConfig override handling This change removes the CRD level override for network config files. Instead, this allows us to use the Ansible variable directly to set any require network config customizations. Depends-On: https://github.com/openstack-k8s-operators/edpm-ansible/pull/243 Signed-off-by: Brendan Shephard --- ...nstack.org_openstackdataplanenodesets.yaml | 10 ---------- api/v1beta1/common.go | 19 ------------------ api/v1beta1/zz_generated.deepcopy.go | 17 ---------------- ...nstack.org_openstackdataplanenodesets.yaml | 10 ---------- docs/openstack_dataplanenodeset.md | 13 ------------ docs/openstack_dataplaneservice.md | 13 ------------ pkg/deployment/inventory.go | 20 ------------------- 7 files changed, 102 deletions(-) diff --git a/api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml b/api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml index ef7179fae..f8e390e91 100644 --- a/api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml +++ b/api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml @@ -1039,11 +1039,6 @@ spec: items: type: string type: array - networkConfig: - properties: - template: - type: string - type: object networkData: properties: name: @@ -1833,11 +1828,6 @@ spec: type: string managementNetwork: type: string - networkConfig: - properties: - template: - type: string - type: object networkData: properties: name: diff --git a/api/v1beta1/common.go b/api/v1beta1/common.go index 7c4a520f2..065e139de 100644 --- a/api/v1beta1/common.go +++ b/api/v1beta1/common.go @@ -53,11 +53,6 @@ type NodeSection struct { // +kubebuilder:validation:Optional HostName string `json:"hostName,omitempty"` - // NetworkConfig - Network configuration details. Contains os-net-config - // related properties. - // +kubebuilder:validation:Optional - NetworkConfig NetworkConfigSection `json:"networkConfig"` - // Networks - Instance networks // +kubebuilder:validation:Optional Networks []infranetworkv1.IPSetNetwork `json:"networks,omitempty"` @@ -103,11 +98,6 @@ type NodeTemplate struct { // +kubebuilder:validation:Optional NetworkAttachments []string `json:"networkAttachments,omitempty"` - // NetworkConfig - Network configuration details. Contains os-net-config - // related properties. - // +kubebuilder:validation:Optional - NetworkConfig NetworkConfigSection `json:"networkConfig,omitempty"` - // Networks - Instance networks // +kubebuilder:validation:Optional Networks []infranetworkv1.IPSetNetwork `json:"networks,omitempty"` @@ -153,15 +143,6 @@ type DeployStrategySection struct { AnsibleSkipTags string `json:"ansibleSkipTags,omitempty"` } -// NetworkConfigSection is a specification of the Network configuration details -type NetworkConfigSection struct { - - // Template - Contains a Ansible j2 nic config template to use when applying node - // network configuration - // +kubebuilder:validation:Optional - Template string `json:"template,omitempty" yaml:"template,omitempty"` -} - // UniqueSpecFields - the array of fields that must be unique between role and nodes var UniqueSpecFields = []string{"NetworkAttachments"} diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 704027de1..eb22d0736 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -129,25 +129,9 @@ func (in *KubeService) DeepCopy() *KubeService { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NetworkConfigSection) DeepCopyInto(out *NetworkConfigSection) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkConfigSection. -func (in *NetworkConfigSection) DeepCopy() *NetworkConfigSection { - if in == nil { - return nil - } - out := new(NetworkConfigSection) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeSection) DeepCopyInto(out *NodeSection) { *out = *in - out.NetworkConfig = in.NetworkConfig if in.Networks != nil { in, out := &in.Networks, &out.Networks *out = make([]networkv1beta1.IPSetNetwork, len(*in)) @@ -200,7 +184,6 @@ func (in *NodeTemplate) DeepCopyInto(out *NodeTemplate) { *out = make([]string, len(*in)) copy(*out, *in) } - out.NetworkConfig = in.NetworkConfig if in.Networks != nil { in, out := &in.Networks, &out.Networks *out = make([]networkv1beta1.IPSetNetwork, len(*in)) diff --git a/config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml b/config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml index ef7179fae..f8e390e91 100644 --- a/config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml +++ b/config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml @@ -1039,11 +1039,6 @@ spec: items: type: string type: array - networkConfig: - properties: - template: - type: string - type: object networkData: properties: name: @@ -1833,11 +1828,6 @@ spec: type: string managementNetwork: type: string - networkConfig: - properties: - template: - type: string - type: object networkData: properties: name: diff --git a/docs/openstack_dataplanenodeset.md b/docs/openstack_dataplanenodeset.md index 859e25815..a253b9174 100644 --- a/docs/openstack_dataplanenodeset.md +++ b/docs/openstack_dataplanenodeset.md @@ -8,7 +8,6 @@ * [AnsibleEESpec](#ansibleeespec) * [AnsibleOpts](#ansibleopts) * [DeployStrategySection](#deploystrategysection) -* [NetworkConfigSection](#networkconfigsection) * [NodeSection](#nodesection) * [NodeTemplate](#nodetemplate) * [OpenStackDataPlaneNodeSetList](#openstackdataplanenodesetlist) @@ -58,16 +57,6 @@ DeployStrategySection for fields controlling the deployment [Back to Custom Resources](#custom-resources) -#### NetworkConfigSection - -NetworkConfigSection is a specification of the Network configuration details - -| Field | Description | Scheme | Required | -| ----- | ----------- | ------ | -------- | -| template | Template - Contains a Ansible j2 nic config template to use when applying node network configuration | string | false | - -[Back to Custom Resources](#custom-resources) - #### NodeSection NodeSection defines the top level attributes inherited by nodes in the CR. @@ -75,7 +64,6 @@ NodeSection defines the top level attributes inherited by nodes in the CR. | Field | Description | Scheme | Required | | ----- | ----------- | ------ | -------- | | hostName | HostName - node name | string | false | -| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | true | | networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false | | managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false | | ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false | @@ -94,7 +82,6 @@ NodeTemplate is a specification of the node attributes that override top level a | ansibleSSHPrivateKeySecret | AnsibleSSHPrivateKeySecret Private SSH Key secret containing private SSH key for connecting to node. Must be of the form: Secret.data.ssh-privatekey: | string | false | | nodes | Nodes - Map of Node Names and node specific data. Values here override defaults in the upper level section. | map[string][NodeSection](#nodesection) | true | | networkAttachments | NetworkAttachments is a list of NetworkAttachment resource names to pass to the ansibleee resource which allows to connect the ansibleee runner to the given network | []string | false | -| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | false | | networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false | | managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false | | ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false | diff --git a/docs/openstack_dataplaneservice.md b/docs/openstack_dataplaneservice.md index 8d7686fdf..f4f7dfde5 100644 --- a/docs/openstack_dataplaneservice.md +++ b/docs/openstack_dataplaneservice.md @@ -8,7 +8,6 @@ * [AnsibleEESpec](#ansibleeespec) * [AnsibleOpts](#ansibleopts) * [DeployStrategySection](#deploystrategysection) -* [NetworkConfigSection](#networkconfigsection) * [NodeSection](#nodesection) * [NodeTemplate](#nodetemplate) * [KubeService](#kubeservice) @@ -59,16 +58,6 @@ DeployStrategySection for fields controlling the deployment [Back to Custom Resources](#custom-resources) -#### NetworkConfigSection - -NetworkConfigSection is a specification of the Network configuration details - -| Field | Description | Scheme | Required | -| ----- | ----------- | ------ | -------- | -| template | Template - Contains a Ansible j2 nic config template to use when applying node network configuration | string | false | - -[Back to Custom Resources](#custom-resources) - #### NodeSection NodeSection defines the top level attributes inherited by nodes in the CR. @@ -76,7 +65,6 @@ NodeSection defines the top level attributes inherited by nodes in the CR. | Field | Description | Scheme | Required | | ----- | ----------- | ------ | -------- | | hostName | HostName - node name | string | false | -| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | true | | networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false | | managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false | | ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false | @@ -95,7 +83,6 @@ NodeTemplate is a specification of the node attributes that override top level a | ansibleSSHPrivateKeySecret | AnsibleSSHPrivateKeySecret Private SSH Key secret containing private SSH key for connecting to node. Must be of the form: Secret.data.ssh-privatekey: | string | false | | nodes | Nodes - Map of Node Names and node specific data. Values here override defaults in the upper level section. | map[string][NodeSection](#nodesection) | true | | networkAttachments | NetworkAttachments is a list of NetworkAttachment resource names to pass to the ansibleee resource which allows to connect the ansibleee runner to the given network | []string | false | -| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | false | | networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false | | managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false | | ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false | diff --git a/pkg/deployment/inventory.go b/pkg/deployment/inventory.go index 7aa9874be..5d217a6cf 100644 --- a/pkg/deployment/inventory.go +++ b/pkg/deployment/inventory.go @@ -93,11 +93,6 @@ func GenerateNodeSetInventory(ctx context.Context, helper *helper.Helper, host.Vars[entry+"_host_routes"] = res.Routes dnsSearchDomains = append(dnsSearchDomains, res.DNSDomain) } - networkConfig := getAnsibleNetworkConfig(instance, nodeName) - - if networkConfig.Template != "" { - host.Vars["edpm_network_config_template"] = NicConfigTemplateFile - } host.Vars["ansible_user"] = getAnsibleUser(instance, nodeName) host.Vars["ansible_port"] = getAnsiblePort(instance, nodeName) @@ -134,7 +129,6 @@ func GenerateNodeSetInventory(ctx context.Context, helper *helper.Helper, } secretData := map[string]string{ "inventory": string(invData), - "network": string(instance.Spec.NodeTemplate.NetworkConfig.Template), } secretName := fmt.Sprintf("dataplanenodeset-%s", instance.Name) template := []utils.Template{ @@ -215,14 +209,6 @@ func getAnsibleManagementNetwork( return instance.Spec.NodeTemplate.ManagementNetwork } -// getAnsibleNetworkConfig returns a JSON string value from the template unless it is set in the node -func getAnsibleNetworkConfig(instance *dataplanev1.OpenStackDataPlaneNodeSet, nodeName string) dataplanev1.NetworkConfigSection { - if instance.Spec.NodeTemplate.Nodes[nodeName].NetworkConfig.Template != "" { - return instance.Spec.NodeTemplate.Nodes[nodeName].NetworkConfig - } - return instance.Spec.NodeTemplate.NetworkConfig -} - // getAnsibleNetworks returns a JSON string mapping fixedIP and/or network name to their valules func getAnsibleNetworks(instance *dataplanev1.OpenStackDataPlaneNodeSet, nodeName string) []infranetworkv1.IPSetNetwork { if len(instance.Spec.NodeTemplate.Nodes[nodeName].Networks) > 0 { @@ -296,9 +282,6 @@ func resolveAnsibleVars(nodeTemplate *dataplanev1.NodeTemplate, host *ansible.Ho if nodeTemplate.ManagementNetwork != "" { ansibleVarsData["management_network"] = nodeTemplate.ManagementNetwork } - if nodeTemplate.NetworkConfig.Template != "" { - ansibleVarsData["edpm_network_config_template"] = NicConfigTemplateFile - } if len(nodeTemplate.Networks) > 0 { ansibleVarsData["networks"] = nodeTemplate.Networks } @@ -340,9 +323,6 @@ func resolveNodeAnsibleVars(node *dataplanev1.NodeSection, host *ansible.Host, g if node.ManagementNetwork != "" { ansibleVarsData["management_network"] = node.ManagementNetwork } - if node.NetworkConfig.Template != "" { - ansibleVarsData["edpm_network_config_template"] = NicConfigTemplateFile - } if len(node.Networks) > 0 { ansibleVarsData["networks"] = node.Networks }