Skip to content

Commit 8f64ae0

Browse files
committed
Support bond configuration in NicMappings
This patch introduces the possibility of defining a new OVNController API parameter called BondConfiguration which is used together with NicMappings to allow the existence bond type interfaces. The configuration would be structured as follows: spec: ... bondConfiguration: bond0: links: - eth10.10 - eth10.20 mtu: 1500 mode: active-backup nicMappings: datacentre: bond0 ... In this case, the datacentre nic would be the primary bond interface and links eth10.10 and eth10.20 the members of such configuration. Mode and MTU can be optionally changed too, with defaults set as the one seen in the example above. Kuttl test are also added for this case. Jira: OSPRH-18846 Assisted-by: Claude Signed-off-by: Elvira Garcia <[email protected]>
1 parent 69651c4 commit 8f64ae0

File tree

12 files changed

+334
-61
lines changed

12 files changed

+334
-61
lines changed

api/bases/ovn.openstack.org_ovncontrollers.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ spec:
5252
spec:
5353
description: OVNControllerSpec defines the desired state of OVNController
5454
properties:
55+
bondConfiguration:
56+
additionalProperties:
57+
description: Bond defines the configuration of each bond interface
58+
in the deployment
59+
properties:
60+
links:
61+
default: []
62+
items:
63+
type: string
64+
type: array
65+
x-kubernetes-list-type: set
66+
mode:
67+
default: active-backup
68+
type: string
69+
mtu:
70+
default: 1500
71+
format: int32
72+
type: integer
73+
type: object
74+
description: Map of bond names to their configuration
75+
type: object
5576
exporterImage:
5677
description: ExporterImage - Container Image URL for the openstack-network-exporter
5778
metrics daemonset (will be set to environmental default if empty)

api/v1beta1/ovncontroller_types.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ type OVNControllerSpecCore struct {
7575
// +optional
7676
NicMappings map[string]string `json:"nicMappings,omitempty"`
7777

78+
// +kubebuilder:validation:Optional
79+
// +optional
80+
// Map of bond names to their configuration
81+
BondConfiguration map[string]Bond `json:"bondConfiguration,omitempty"`
82+
7883
// +kubebuilder:validation:Optional
7984
// Resources - Compute Resources required by this service (Limits/Requests).
8085
// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
@@ -196,6 +201,22 @@ type OVSExternalIDs struct {
196201
EnableChassisAsGateway *bool `json:"enable-chassis-as-gateway"`
197202
}
198203

204+
// Bond defines the configuration of each bond interface in the deployment
205+
type Bond struct {
206+
// +kubebuilder:validation:Optional
207+
// +kubebuilder:default="active-backup"
208+
Mode string `json:"mode,omitempty"`
209+
210+
// +kubebuilder:validation:Optional
211+
// +kubebuilder:default=1500
212+
Mtu int32 `json:"mtu,omitempty"`
213+
214+
// +kubebuilder:validation:Optional
215+
// +listType=set
216+
// +kubebuilder:default={}
217+
Links []string `json:"links"`
218+
}
219+
199220
// RbacConditionsSet - set the conditions for the rbac object
200221
func (instance OVNController) RbacConditionsSet(c *condition.Condition) {
201222
instance.Status.Conditions.Set(c)

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/ovn.openstack.org_ovncontrollers.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ spec:
5252
spec:
5353
description: OVNControllerSpec defines the desired state of OVNController
5454
properties:
55+
bondConfiguration:
56+
additionalProperties:
57+
description: Bond defines the configuration of each bond interface
58+
in the deployment
59+
properties:
60+
links:
61+
default: []
62+
items:
63+
type: string
64+
type: array
65+
x-kubernetes-list-type: set
66+
mode:
67+
default: active-backup
68+
type: string
69+
mtu:
70+
default: 1500
71+
format: int32
72+
type: integer
73+
type: object
74+
description: Map of bond names to their configuration
75+
type: object
5576
exporterImage:
5677
description: ExporterImage - Container Image URL for the openstack-network-exporter
5778
metrics daemonset (will be set to environmental default if empty)

controllers/ovncontroller_controller.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22-
"sort"
2322
"time"
2423

2524
"github.com/go-logr/logr"
@@ -495,7 +494,16 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
495494
}
496495

497496
// Create or Update additional Physical Network Attachments
498-
networkAttachments, err := ovncontroller.CreateOrUpdateAdditionalNetworks(ctx, helper, instance, ovsServiceLabels)
497+
// network to attach to
498+
networkAttachments := []string{}
499+
networkAttachmentsNoPhysNet := []string{}
500+
if instance.Spec.NetworkAttachment != "" {
501+
networkAttachments = append(networkAttachments, instance.Spec.NetworkAttachment)
502+
networkAttachmentsNoPhysNet = append(networkAttachmentsNoPhysNet, instance.Spec.NetworkAttachment)
503+
}
504+
505+
networkAttachments, err = ovncontroller.CreateOrUpdateAdditionalNetworks(ctx, helper, instance, ovsServiceLabels, networkAttachments)
506+
499507
if err != nil {
500508
Log.Info(fmt.Sprintf("Failed to create additional networks: %s", err))
501509
instance.Status.Conditions.Set(condition.FalseCondition(
@@ -507,14 +515,6 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
507515
return ctrl.Result{}, err
508516
}
509517

510-
// network to attach to
511-
networkAttachmentsNoPhysNet := []string{}
512-
if instance.Spec.NetworkAttachment != "" {
513-
networkAttachments = append(networkAttachments, instance.Spec.NetworkAttachment)
514-
networkAttachmentsNoPhysNet = append(networkAttachmentsNoPhysNet, instance.Spec.NetworkAttachment)
515-
}
516-
sort.Strings(networkAttachments)
517-
518518
nadList := []netattdefv1.NetworkAttachmentDefinition{}
519519
for _, netAtt := range networkAttachments {
520520
nad, err := nad.GetNADWithName(ctx, helper, netAtt, instance.Namespace)

hack/crd-schema-checker.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ for crd in config/crd/bases/*.yaml; do
2828
$CHECKER check-manifests \
2929
$CHECKER_ARGS \
3030
--existing-crd-filename="$TMP_DIR/$crd" \
31-
--new-crd-filename="$crd"
31+
--new-crd-filename="$crd" \
32+
--disabled-validators NoMaps
3233
done

0 commit comments

Comments
 (0)