Skip to content

Commit ab66ab3

Browse files
msupinodndn
andauthored
topo: skip creating empty meshnet Topology CR for nodes with no links (#26)
When a node has no Links in its meshnet TopologySpec, kne currently still creates a `Topology` CR with `spec: {}`. meshnetd's `Get(podName)` RPC then reads the CR, fails the `unstructured.NestedSlice(... "spec", "links")` lookup with `!found`, logs `could not find 'Link' array in pod's spec` and returns an empty Pod struct. The CNI plugin sees `NodeIp == ""` and aborts the sandbox with the (misleading) error: plugin type="meshnet" failed (add): meshnetd provided no HOST_IP address: or HOST_INTF: Every pod scheduled on a node with no links is then stuck in FailedCreatePodSandBox loops until kubelet's 4-minute deadline. Skip the CR creation for unconnected nodes. The meshnet CNI plugin already handles "no Topology CR for this pod" gracefully (plugin/meshnet.go cmdAdd treats Get error as `not a topology pod returning`) and chains through to the next plugin, so the result is the same as for any other workload on the cluster. This is a no-op for topologies whose nodes all have links and significantly improves robustness for sparse/scale-test topologies where some nodes are intentionally isolated. Co-authored-by: dn <dn@msupino-dev>
1 parent c39e79c commit ab66ab3

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

topo/topo.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,19 @@ func (m *Manager) topologySpecs(ctx context.Context) ([]*topologyv1.Topology, er
554554
// replace node name with pod name, for peer pod attribute in each link
555555
for nodeName, specs := range nodeSpecs {
556556
for _, spec := range specs {
557+
// Skip Topology CRs with no links: meshnetd's Get RPC
558+
// treats a missing `spec.links` field as an error
559+
// (`could not find 'Link' array in pod's spec`) and the
560+
// CNI plugin then aborts pod sandbox creation with a
561+
// misleading `meshnetd provided no HOST_IP` message.
562+
// For unconnected nodes we simply don't create the CR;
563+
// the meshnet CNI plugin already handles "no Topology
564+
// CR" gracefully and falls through to the next plugin
565+
// in the chain.
566+
if len(spec.Spec.Links) == 0 {
567+
log.V(1).Infof("Skipping empty Topology spec for node %s (no links)", nodeName)
568+
continue
569+
}
557570
for l := range spec.Spec.Links {
558571
link := &spec.Spec.Links[l]
559572
peerSpecs, ok := nodeSpecs[link.PeerPod]

0 commit comments

Comments
 (0)