Skip to content

Commit bc30990

Browse files
committed
Make ovs-vswitchd service 'other_config' option configurable
Signed-off-by: Ivan Kolodiazhnyi <[email protected]>
1 parent bad98b1 commit bc30990

22 files changed

+338
-46
lines changed

api/v1/sriovnetworknodestate_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ type System struct {
119119
// +kubebuilder:validation:Enum=shared;exclusive
120120
//RDMA subsystem. Allowed value "shared", "exclusive".
121121
RdmaMode string `json:"rdmaMode,omitempty"`
122+
// OVS config. It will be provided for ovs-vswitchd service as other_config option
123+
// +kubebuilder:default:={hw-offload: "true"}
124+
OvsConfig map[string]string `json:"ovsConfig,omitempty"`
122125
}
123126

124127
// SriovNetworkNodeStateStatus defines the observed state of SriovNetworkNodeState

api/v1/sriovnetworkpoolconfig_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ type OvsHardwareOffloadConfig struct {
3434
// On OpenShift:
3535
// Name is the name of MachineConfigPool to be enabled with OVS hardware offload
3636
Name string `json:"name,omitempty"`
37+
// OVS config. It will be provided for ovs-vswitchd service as other_config option
38+
// +kubebuilder:default:={hw-offload: "true"}
39+
OvsConfig map[string]string `json:"otherConfig,omitempty"`
3740
}
3841

3942
// SriovNetworkPoolConfigStatus defines the observed state of SriovNetworkPoolConfig

api/v1/zz_generated.deepcopy.go

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

bindata/manifests/switchdev-config/ovs-units/ovs-vswitchd.service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dropins:
33
- name: 10-hw-offload.conf
44
contents: |
55
[Service]
6-
ExecStartPre=/bin/ovs-vsctl --no-wait set Open_vSwitch . other_config:hw-offload=true
6+
ExecStartPre=/bin/ovs-vsctl -t 5 set Open_vSwitch . external_ids:sriov-operator-owned-keys='{{ .ExternalIds }}' && /bin/ovs-vsctl/ovs-vsctl -t 5 get Open_vSwitch . external_ids:sriov-operator-owned-keys | xargs /bin/ovs-vsctl --no-wait remove Open_vSwitch . other_config && /bin/ovs-vsctl --no-wait set Open_vSwitch . {{ .OtherOvsConfig }}

config/crd/bases/sriovnetwork.openshift.io_sriovnetworknodestates.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ spec:
187187
type: array
188188
system:
189189
properties:
190+
ovsConfig:
191+
additionalProperties:
192+
type: string
193+
default:
194+
hw-offload: "true"
195+
description: OVS config. It will be provided for ovs-vswitchd
196+
service as other_config option
197+
type: object
190198
rdmaMode:
191199
description: RDMA subsystem. Allowed value "shared", "exclusive".
192200
enum:
@@ -368,6 +376,14 @@ spec:
368376
type: string
369377
system:
370378
properties:
379+
ovsConfig:
380+
additionalProperties:
381+
type: string
382+
default:
383+
hw-offload: "true"
384+
description: OVS config. It will be provided for ovs-vswitchd
385+
service as other_config option
386+
type: object
371387
rdmaMode:
372388
description: RDMA subsystem. Allowed value "shared", "exclusive".
373389
enum:

config/crd/bases/sriovnetwork.openshift.io_sriovnetworkpoolconfigs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ spec:
112112
On OpenShift:
113113
Name is the name of MachineConfigPool to be enabled with OVS hardware offload
114114
type: string
115+
otherConfig:
116+
additionalProperties:
117+
type: string
118+
default:
119+
hw-offload: "true"
120+
description: OVS config. It will be provided for ovs-vswitchd
121+
service as other_config option
122+
type: object
115123
type: object
116124
rdmaMode:
117125
description: RDMA subsystem. Allowed value "shared", "exclusive".

controllers/sriovnetworknodepolicy_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ func (r *SriovNetworkNodePolicyReconciler) syncAllSriovNetworkNodeStates(ctx con
308308
}
309309
if netPoolConfig != nil {
310310
ns.Spec.System.RdmaMode = netPoolConfig.Spec.RdmaMode
311+
if netPoolConfig.Spec.OvsHardwareOffloadConfig.OvsConfig != nil {
312+
ns.Spec.System.OvsConfig = make(map[string]string, len(netPoolConfig.Spec.OvsHardwareOffloadConfig.OvsConfig))
313+
for k, v := range netPoolConfig.Spec.OvsHardwareOffloadConfig.OvsConfig {
314+
ns.Spec.System.OvsConfig[k] = v
315+
}
316+
}
311317
}
312318
j, _ := json.Marshal(ns)
313319
logger.V(2).Info("SriovNetworkNodeState CR", "content", j)

controllers/sriovnetworkpoolconfig_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
constants "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts"
2121
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/orchestrator"
2222
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/render"
23+
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
2324
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
2425
)
2526

@@ -160,6 +161,9 @@ func (r *SriovNetworkPoolConfigReconciler) syncOvsHardwareOffloadMachineConfigs(
160161
}
161162

162163
data := render.MakeRenderData()
164+
externalIds, otherOvsConfig := utils.RenderOtherOvsConfigOption(nc.Spec.OvsHardwareOffloadConfig.OvsConfig)
165+
data.Data["OtherOvsConfig"] = otherOvsConfig
166+
data.Data["ExternalIds"] = externalIds
163167
mc, err := render.GenerateMachineConfig("bindata/manifests/switchdev-config", mcName, mcpName, true, &data)
164168
if err != nil {
165169
return err

deployment/sriov-network-operator-chart/crds/sriovnetwork.openshift.io_sriovnetworknodestates.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ spec:
187187
type: array
188188
system:
189189
properties:
190+
ovsConfig:
191+
additionalProperties:
192+
type: string
193+
default:
194+
hw-offload: "true"
195+
description: OVS config. It will be provided for ovs-vswitchd
196+
service as other_config option
197+
type: object
190198
rdmaMode:
191199
description: RDMA subsystem. Allowed value "shared", "exclusive".
192200
enum:
@@ -368,6 +376,14 @@ spec:
368376
type: string
369377
system:
370378
properties:
379+
ovsConfig:
380+
additionalProperties:
381+
type: string
382+
default:
383+
hw-offload: "true"
384+
description: OVS config. It will be provided for ovs-vswitchd
385+
service as other_config option
386+
type: object
371387
rdmaMode:
372388
description: RDMA subsystem. Allowed value "shared", "exclusive".
373389
enum:

deployment/sriov-network-operator-chart/crds/sriovnetwork.openshift.io_sriovnetworkpoolconfigs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ spec:
112112
On OpenShift:
113113
Name is the name of MachineConfigPool to be enabled with OVS hardware offload
114114
type: string
115+
otherConfig:
116+
additionalProperties:
117+
type: string
118+
default:
119+
hw-offload: "true"
120+
description: OVS config. It will be provided for ovs-vswitchd
121+
service as other_config option
122+
type: object
115123
type: object
116124
rdmaMode:
117125
description: RDMA subsystem. Allowed value "shared", "exclusive".

0 commit comments

Comments
 (0)