Skip to content

Commit 83a344b

Browse files
Merge pull request #490 from elvgarrui/OSPRH-18846
Support bond configuration in NicMappings
2 parents 2237fe8 + 8f64ae0 commit 83a344b

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/
@@ -201,6 +206,22 @@ type OVSExternalIDs struct {
201206
EnableChassisAsGateway *bool `json:"enable-chassis-as-gateway"`
202207
}
203208

209+
// Bond defines the configuration of each bond interface in the deployment
210+
type Bond struct {
211+
// +kubebuilder:validation:Optional
212+
// +kubebuilder:default="active-backup"
213+
Mode string `json:"mode,omitempty"`
214+
215+
// +kubebuilder:validation:Optional
216+
// +kubebuilder:default=1500
217+
Mtu int32 `json:"mtu,omitempty"`
218+
219+
// +kubebuilder:validation:Optional
220+
// +listType=set
221+
// +kubebuilder:default={}
222+
Links []string `json:"links"`
223+
}
224+
204225
// RbacConditionsSet - set the conditions for the rbac object
205226
func (instance OVNController) RbacConditionsSet(c *condition.Condition) {
206227
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"
@@ -497,7 +496,16 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
497496
}
498497

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

512-
// network to attach to
513-
networkAttachmentsNoPhysNet := []string{}
514-
if instance.Spec.NetworkAttachment != "" {
515-
networkAttachments = append(networkAttachments, instance.Spec.NetworkAttachment)
516-
networkAttachmentsNoPhysNet = append(networkAttachmentsNoPhysNet, instance.Spec.NetworkAttachment)
517-
}
518-
sort.Strings(networkAttachments)
519-
520520
nadList := []netattdefv1.NetworkAttachmentDefinition{}
521521
for _, netAtt := range networkAttachments {
522522
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)