Skip to content

Commit 355ce47

Browse files
committed
fix: skip NetworkUnavailable condition in non-primary CNI mode
When kube-ovn is configured as a non-primary CNI, the daemon should not set the NetworkUnavailable node condition - that's the responsibility of the primary CNI. This commit: - Adds --non-primary-cni-mode flag to daemon configuration - Skips setting NetworkUnavailable condition in configureNodeNic() when running in non-primary CNI mode - Skips loopOvn0Check() entirely in non-primary mode - Updates Helm charts to pass the flag to the daemon Fixes: #6194 Signed-off-by: Damir Nugmanov <damir_nug@mail.ru>
1 parent 6a40d68 commit 355ce47

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

charts/kube-ovn-v2/templates/agent/agent-daemonset.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ spec:
143143
- --ovs-vsctl-concurrency={{ .Values.performance.ovsVsctlConcurrency }}
144144
- --secure-serving={{- .Values.features.enableSecureServing }}
145145
- --enable-ovn-ipsec={{- .Values.features.enableOvnIpsec }}
146+
- --non-primary-cni-mode={{- .Values.cni.nonPrimaryCNI }}
146147
securityContext:
147148
runAsGroup: 0
148149
runAsUser: 0

charts/kube-ovn/templates/ovncni-ds.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ spec:
125125
- --secure-serving={{- .Values.func.SECURE_SERVING }}
126126
- --enable-ovn-ipsec={{- .Values.func.ENABLE_OVN_IPSEC }}
127127
- --set-vxlan-tx-off={{- .Values.func.SET_VXLAN_TX_OFF }}
128+
- --non-primary-cni-mode={{- .Values.cni_conf.NON_PRIMARY_CNI }}
128129
securityContext:
129130
runAsUser: 0
130131
privileged: false

pkg/daemon/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type Configuration struct {
8383
OVSVsctlConcurrency int32
8484
SetVxlanTxOff bool
8585
LogPerm string
86+
EnableNonPrimaryCNI bool
8687

8788
// TLS configuration for secure serving
8889
TLSMinVersion string
@@ -145,6 +146,7 @@ func ParseFlags() *Configuration {
145146
argTLSMinVersion = pflag.String("tls-min-version", "", "The minimum TLS version to use for secure serving. Supported values: TLS10, TLS11, TLS12, TLS13. If not set, the default is used based on the Go version.")
146147
argTLSMaxVersion = pflag.String("tls-max-version", "", "The maximum TLS version to use for secure serving. Supported values: TLS10, TLS11, TLS12, TLS13. If not set, the default is used based on the Go version.")
147148
argTLSCipherSuites = pflag.StringSlice("tls-cipher-suites", nil, "Comma-separated list of TLS cipher suite names to use for secure serving (e.g., 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384'). Names must match Go's crypto/tls package. See Go documentation for available suites. If not set, defaults are used. Users are responsible for selecting secure cipher suites.")
149+
argNonPrimaryCNI = pflag.Bool("non-primary-cni-mode", false, "Use Kube-OVN in non primary cni mode. When true, skip setting NetworkUnavailable node condition")
148150
)
149151

150152
// mute info log for ipset lib
@@ -215,6 +217,7 @@ func ParseFlags() *Configuration {
215217
CertManagerIPSecCert: *argCertManagerIPSecCert,
216218
CertManagerIssuerName: *argCertManagerIssuerName,
217219
IPSecCertDuration: *argOVNIPSecCertDuration,
220+
EnableNonPrimaryCNI: *argNonPrimaryCNI,
218221
}
219222

220223
return config

pkg/daemon/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func InitNodeGateway(config *Configuration) error {
8787
klog.Errorf("failed to get ip %s with mask %s, %v", ip, joinCIDR, err)
8888
return err
8989
}
90-
return configureNodeNic(config.KubeClient, config.NodeName, portName, ipAddr, gw, joinCIDR, mac, config.MTU)
90+
return configureNodeNic(config.KubeClient, config.NodeName, portName, ipAddr, gw, joinCIDR, mac, config.MTU, config.EnableNonPrimaryCNI)
9191
}
9292

9393
func InitMirror(config *Configuration) error {

pkg/daemon/ovs_linux.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ func waitNetworkReady(nic, ipAddr, gateway string, preferARP, verbose bool, maxR
630630
return nil
631631
}
632632

633-
func configureNodeNic(cs kubernetes.Interface, nodeName, portName, ip, gw, joinCIDR string, macAddr net.HardwareAddr, mtu int) error {
633+
func configureNodeNic(cs kubernetes.Interface, nodeName, portName, ip, gw, joinCIDR string, macAddr net.HardwareAddr, mtu int, enableNonPrimaryCNI bool) error {
634634
ipStr := util.GetIPWithoutMask(ip)
635635
raw, err := ovs.Exec(ovs.MayExist, "add-port", "br-int", util.NodeNic, "--",
636636
"set", "interface", util.NodeNic, "type=internal", "--",
@@ -718,17 +718,25 @@ func configureNodeNic(cs kubernetes.Interface, nodeName, portName, ip, gw, joinC
718718

719719
// ping ovn0 gw to activate the flow
720720
klog.Infof("wait %s gw ready", util.NodeNic)
721-
status := corev1.ConditionFalse
722-
reason := "JoinSubnetGatewayReachable"
723-
message := fmt.Sprintf("ping check to gateway ip %s succeeded", gw)
724721
if err = waitNetworkReady(util.NodeNic, ip, gw, false, true, gatewayCheckMaxRetry, nil); err != nil {
725722
klog.Errorf("failed to init %s check: %v", util.NodeNic, err)
726-
status = corev1.ConditionTrue
727-
reason = "JoinSubnetGatewayUnreachable"
728-
message = fmt.Sprintf("ping check to gateway ip %s failed", gw)
729723
}
730-
if err := util.SetNodeNetworkUnavailableCondition(cs, nodeName, status, reason, message); err != nil {
731-
klog.Errorf("failed to set node network unavailable condition: %v", err)
724+
725+
// Only set NetworkUnavailable condition when running as primary CNI
726+
if !enableNonPrimaryCNI {
727+
status := corev1.ConditionFalse
728+
reason := "JoinSubnetGatewayReachable"
729+
message := fmt.Sprintf("ping check to gateway ip %s succeeded", gw)
730+
if err != nil {
731+
status = corev1.ConditionTrue
732+
reason = "JoinSubnetGatewayUnreachable"
733+
message = fmt.Sprintf("ping check to gateway ip %s failed", gw)
734+
}
735+
if setErr := util.SetNodeNetworkUnavailableCondition(cs, nodeName, status, reason, message); setErr != nil {
736+
klog.Errorf("failed to set node network unavailable condition: %v", setErr)
737+
}
738+
} else {
739+
klog.Infof("running in non-primary CNI mode, skipping NetworkUnavailable condition update")
732740
}
733741

734742
return err
@@ -737,6 +745,11 @@ func configureNodeNic(cs kubernetes.Interface, nodeName, portName, ip, gw, joinC
737745
// If OVS restart, the ovn0 port will down and prevent host to pod network,
738746
// Restart the kube-ovn-cni when this happens
739747
func (c *Controller) loopOvn0Check() {
748+
// Skip ovn0 check when running as non-primary CNI
749+
if c.config.EnableNonPrimaryCNI {
750+
return
751+
}
752+
740753
link, err := netlink.LinkByName(util.NodeNic)
741754
if err != nil {
742755
util.LogFatalAndExit(err, "failed to get node nic %s", util.NodeNic)

0 commit comments

Comments
 (0)