Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Other values are ignored. If you wish to use use a third-party network provider


### Configuring OVNKubernetes
OVNKubernetes supports the following configuration options, all of which are optional and once set at cluster creation, they can't be changed except for `gatewayConfig` and `IPsec` which can be changed at runtime:
OVNKubernetes supports the following configuration options, all of which are optional and once set at cluster creation, they can't be changed except for `gatewayConfig`, `IPsec` and `reachabilityTotalTimeoutSeconds` which can be changed at runtime:
* `MTU`: The MTU to use for the geneve overlay. The default is the MTU of the node that the cluster-network-operator is first run on, minus 100 bytes for geneve overhead. If the nodes in your cluster don't all have the same MTU then you may need to set this explicitly.
* `genevePort`: The UDP port to use for the Geneve overlay. The default is 6081.
* `hybridOverlayConfig`: hybrid linux/windows cluster (see below).
Expand Down
8 changes: 7 additions & 1 deletion bindata/network/ovn-kubernetes/common/008-script-lib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@ data:

echo "I$(date "+%m%d %H:%M:%S.%N") - starting ovnkube-node"

ovn_eip_reachability_timeout_opt=
{{- if .ReachabilityTotalTimeoutSeconds }}
ovn_eip_reachability_timeout_opt="--egressip-reachability-total-timeout {{.ReachabilityTotalTimeoutSeconds}}"
{{ end }}

init_ovnkube_controller="--init-ovnkube-controller ${K8S_NODE}"
gateway_interface="br-ex"
OVN_NODE_MODE=${OVN_NODE_MODE:-full}
Expand Down Expand Up @@ -746,5 +751,6 @@ data:
${ovn_v4_masquerade_subnet_opt} \
${ovn_v6_masquerade_subnet_opt} \
${ovn_v4_transit_switch_subnet_opt} \
${ovn_v6_transit_switch_subnet_opt}
${ovn_v6_transit_switch_subnet_opt} \
${ovn_eip_reachability_timeout_opt}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only conflict resolved was the removal of dpu_lease_flags as it's not present in release-4.22.
https://github.com/openshift/cluster-network-operator/blob/master/bindata/network/ovn-kubernetes/common/008-script-lib.yaml#L732

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arghosh93 sure, see here the conflict resolved.

}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ spec:
fi
done

ovn_eip_reachability_timeout_opt=
{{- if .ReachabilityTotalTimeoutSeconds }}
ovn_eip_reachability_timeout_opt="--egressip-reachability-total-timeout {{.ReachabilityTotalTimeoutSeconds}}"
{{ end }}

ovn_v4_join_subnet_opt=
if [[ "{{.V4JoinSubnet}}" != "" ]]; then
ovn_v4_join_subnet_opt="--gateway-v4-join-subnet {{.V4JoinSubnet}}"
Expand Down Expand Up @@ -222,7 +227,8 @@ spec:
${ovn_v6_masquerade_subnet_opt} \
${persistent_ips_enabled_flag} \
${route_advertisements_enable_flag} \
${evpn_enable_flag}
${evpn_enable_flag} \
${ovn_eip_reachability_timeout_opt}
volumeMounts:
- mountPath: /run/ovnkube-config/
name: ovnkube-config
Expand Down
3 changes: 0 additions & 3 deletions bindata/network/ovn-kubernetes/self-hosted/004-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ data:
enable-egress-firewall=true
enable-egress-qos=true
enable-egress-service=true
{{- if .ReachabilityTotalTimeoutSeconds }}
egressip-reachability-total-timeout={{.ReachabilityTotalTimeoutSeconds}}
{{- end }}
{{- if .ReachabilityNodePort }}
egressip-node-healthcheck-port={{.ReachabilityNodePort}}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ spec:
source "/env/_master"
set +o allexport
fi

ovn_eip_reachability_timeout_opt=
{{- if .ReachabilityTotalTimeoutSeconds }}
ovn_eip_reachability_timeout_opt="--egressip-reachability-total-timeout {{.ReachabilityTotalTimeoutSeconds}}"
{{ end }}

ovn_v4_join_subnet_opt=
if [[ "{{.V4JoinSubnet}}" != "" ]]; then
Expand Down Expand Up @@ -176,7 +181,8 @@ spec:
${persistent_ips_enabled_flag} \
${gateway_mode_flags} \
${route_advertisements_enable_flag} \
${evpn_enable_flag}
${evpn_enable_flag} \
${ovn_eip_reachability_timeout_opt}
volumeMounts:
- mountPath: /run/ovnkube-config/
name: ovnkube-config
Expand Down
147 changes: 145 additions & 2 deletions pkg/network/ovn_kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ enable-egress-ip=true
enable-egress-firewall=true
enable-egress-qos=true
enable-egress-service=true
egressip-reachability-total-timeout=3
egressip-node-healthcheck-port=9107
enable-multi-network=true
enable-network-segmentation=true
Expand Down Expand Up @@ -467,7 +466,6 @@ enable-egress-ip=true
enable-egress-firewall=true
enable-egress-qos=true
enable-egress-service=true
egressip-reachability-total-timeout=0
egressip-node-healthcheck-port=9107
enable-multi-network=true
enable-network-segmentation=true
Expand Down Expand Up @@ -4001,6 +3999,151 @@ func TestRenderOVNKubernetesEnablePersistentIPs(t *testing.T) {
g.Expect(objs).To(ContainElement(HaveKubernetesID("CustomResourceDefinition", "", "ipamclaims.k8s.cni.cncf.io")))
}

// TestRenderOVNKubernetesReachability tests egress IP reachability timeout rendering
func TestRenderOVNKubernetesReachability(t *testing.T) {
g := NewGomegaWithT(t)

testCases := []struct {
name string
reachabilityTimeout *uint32
expectKubernetesFeatureReachability bool
expectErr bool
}{
{
name: "No reachability timeout (nil)",
reachabilityTimeout: nil,
expectKubernetesFeatureReachability: false,
expectErr: false,
},
{
name: "Reachability timeout set to 0",
reachabilityTimeout: ptrToUint32(0),
expectKubernetesFeatureReachability: true,
expectErr: false,
},
{
name: "Reachability timeout changed to 10",
reachabilityTimeout: ptrToUint32(10),
expectKubernetesFeatureReachability: true,
expectErr: false,
},
{
name: "Reachability timeout unchanged to 10",
reachabilityTimeout: ptrToUint32(10),
expectKubernetesFeatureReachability: true,
expectErr: false,
},
{
name: "Reachability timeout changed to 5",
reachabilityTimeout: ptrToUint32(5),
expectKubernetesFeatureReachability: true,
expectErr: false,
},
{
name: "Reachability timeout disabled",
reachabilityTimeout: nil,
expectKubernetesFeatureReachability: false,
expectErr: false,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
crd := OVNKubernetesConfig.DeepCopy()
config := &crd.Spec
config.DefaultNetwork.OVNKubernetesConfig.EgressIPConfig.ReachabilityTotalTimeoutSeconds = tc.reachabilityTimeout

errs := validateOVNKubernetes(config)
g.Expect(errs).To(HaveLen(0))
fillDefaults(config, nil)

// at the same time we have an upgrade
t.Setenv("RELEASE_VERSION", "2.0.0")

bootstrapResult := fakeBootstrapResult()
bootstrapResult.OVN = bootstrap.OVNBootstrapResult{
ControlPlaneReplicaCount: 3,
OVNKubernetesConfig: &bootstrap.OVNConfigBoostrapResult{
DpuHostModeLabel: OVN_NODE_SELECTOR_DEFAULT_DPU_HOST,
DpuModeLabel: OVN_NODE_SELECTOR_DEFAULT_DPU,
SmartNicModeLabel: OVN_NODE_SELECTOR_DEFAULT_SMART_NIC,
MgmtPortResourceName: "",
HyperShiftConfig: &bootstrap.OVNHyperShiftBootstrapResult{
Enabled: false,
},
},
}

featureGatesCNO := getDefaultFeatureGates()
fakeClient := cnofake.NewFakeClient()
// Set is as Hypershift hosted control plane.
bootstrapResult.Infra = bootstrap.InfraStatus{}
bootstrapResult.Infra.HostedControlPlane = &hypershift.HostedControlPlane{}
objs, _, err := renderOVNKubernetes(config, bootstrapResult, manifestDirOvn, fakeClient, featureGatesCNO)
if tc.expectErr {
g.Expect(err).To(HaveOccurred())
return
}
g.Expect(err).NotTo(HaveOccurred())

var configMap *uns.Unstructured
var scriptCP string
var scriptNode string
for _, obj := range objs {
// Gets script that starts ovnkube-control-plane pod, ovnkube-cluster-manager container
if obj.GetKind() == "Deployment" && obj.GetName() == "ovnkube-control-plane" && obj.GetNamespace() == "openshift-ovn-kubernetes" {
containers, found, err := uns.NestedSlice(obj.Object, "spec", "template", "spec", "containers")
g.Expect(err).NotTo(HaveOccurred())
g.Expect(found).To(BeTrue())
for _, c := range containers {
cm := c.(map[string]interface{})
if name, ok := cm["name"]; ok && name == "ovnkube-cluster-manager" {
command, found, err := uns.NestedSlice(cm, "command")
g.Expect(err).NotTo(HaveOccurred())
g.Expect(found).To(BeTrue())
g.Expect(len(command)).To(BeNumerically(">", 2)) // Command options are set in the 3rd slice
scriptCP = command[2].(string)
break
}
}
}

// Gets script that starts ovnkube-node pod, ovnkube-controller container
if obj.GetKind() == "ConfigMap" && obj.GetName() == "ovnkube-script-lib" {
configMap = obj
configMapData, found, err := uns.NestedStringMap(configMap.Object, "data")
g.Expect(err).NotTo(HaveOccurred())
g.Expect(found).To(BeTrue(), "ovnkube-script-lib ConfigMap should have data field")
scriptNode = configMapData["ovnkube-lib.sh"]
}
}
g.Expect(scriptCP).NotTo(BeEmpty())
g.Expect(scriptNode).NotTo(BeEmpty())

if tc.expectKubernetesFeatureReachability {
g.Expect(scriptCP).To(
ContainSubstring(fmt.Sprintf("--egressip-reachability-total-timeout %d", *tc.reachabilityTimeout)),
"ovnkube-control-plane pod template should contain the configured reachability timeout value",
)
g.Expect(scriptNode).To(
ContainSubstring(fmt.Sprintf("--egressip-reachability-total-timeout %d", *tc.reachabilityTimeout)),
"ovnkube-node pod template should contain the configured reachability timeout value",
)

} else {
g.Expect(scriptCP).NotTo(
ContainSubstring("--egressip-reachability-total-timeout"),
"ovnkube-control-plane pod template should not contain the configured reachability timeout value",
)
g.Expect(scriptNode).NotTo(
ContainSubstring("--egressip-reachability-total-timeout"),
"ovnkube-node pod template should not contain the configured reachability timeout value",
)
}
})
}
}

type fakeClientReader struct {
configMap *v1.ConfigMap
}
Expand Down