我有代码像
CILIUM_K8S = "cilium-k8s"
CiliumK8sNodeSubnetAnnotation12 = "io.cilium.network.ipv4-pod-cidr"
CiliumK8sNodeSubnetAnnotation13 = "network.cilium.io/ipv4-pod-cidr
315 } else if ctlr.OrchestrationCNI == CILIUM_K8S {
316 if nodesubnet, ok := node.ObjectMeta.Annotations[CiliumK8sNodeSubnetAnnotation12]; !ok {
317 log.Warningf("Node subnet annotation %v not found on node %v static route not added", CiliumK8s NodeSubnetAnnotation, node.Name)
318 continue
319 } else {
320 route.Network = nodesubnet
321 nodeAddrs := node.Status.Addresses
322 for _, addr := range nodeAddrs {
323 if addr.Type == addrType {
324 route.Gateway = addr.Address
325 route.Name = fmt.Sprintf("k8s-%v-%v", node.Name, addr.Address)
326 }
327 }
328
329 }
如何修改316 to 318
行,以便检查是否找到CiliumK8sNodeSubnetAnnotation12
或CiliumK8sNodeSubnetAnnotation13
,如果都没有找到,则继续?我不太熟悉if nodesubnet, ok :=...
的语法。对不起这个蹩脚的问题:)
1条答案
按热度按时间bq9c1y661#
我采用了@zerkms的建议,代码如下: