Skip to content

Commit 466ee14

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

23 files changed

+340
-53
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
@@ -180,6 +180,14 @@ spec:
180180
type: array
181181
system:
182182
properties:
183+
ovsConfig:
184+
additionalProperties:
185+
type: string
186+
default:
187+
hw-offload: "true"
188+
description: OVS config. It will be provided for ovs-vswitchd
189+
service as other_config option
190+
type: object
183191
rdmaMode:
184192
description: RDMA subsystem. Allowed value "shared", "exclusive".
185193
enum:
@@ -354,6 +362,14 @@ spec:
354362
type: string
355363
system:
356364
properties:
365+
ovsConfig:
366+
additionalProperties:
367+
type: string
368+
default:
369+
hw-offload: "true"
370+
description: OVS config. It will be provided for ovs-vswitchd
371+
service as other_config option
372+
type: object
357373
rdmaMode:
358374
description: RDMA subsystem. Allowed value "shared", "exclusive".
359375
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/platforms"
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

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

161162
data := render.MakeRenderData()
163+
externalIds, otherOvsConfig := utils.RenderOtherOvsConfigOption(nc.Spec.OvsHardwareOffloadConfig.OvsConfig)
164+
data.Data["OtherOvsConfig"] = otherOvsConfig
165+
data.Data["ExternalIds"] = externalIds
162166
mc, err := render.GenerateMachineConfig("bindata/manifests/switchdev-config", mcName, mcpName, true, &data)
163167
if err != nil {
164168
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
@@ -180,6 +180,14 @@ spec:
180180
type: array
181181
system:
182182
properties:
183+
ovsConfig:
184+
additionalProperties:
185+
type: string
186+
default:
187+
hw-offload: "true"
188+
description: OVS config. It will be provided for ovs-vswitchd
189+
service as other_config option
190+
type: object
183191
rdmaMode:
184192
description: RDMA subsystem. Allowed value "shared", "exclusive".
185193
enum:
@@ -354,6 +362,14 @@ spec:
354362
type: string
355363
system:
356364
properties:
365+
ovsConfig:
366+
additionalProperties:
367+
type: string
368+
default:
369+
hw-offload: "true"
370+
description: OVS config. It will be provided for ovs-vswitchd
371+
service as other_config option
372+
type: object
357373
rdmaMode:
358374
description: RDMA subsystem. Allowed value "shared", "exclusive".
359375
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)