Skip to content

Improve apply link reconciliation - #3260

Merged
hellt merged 10 commits into
mainfrom
fix/improve-apply
Jul 10, 2026
Merged

Improve apply link reconciliation#3260
hellt merged 10 commits into
mainfrom
fix/improve-apply

Conversation

@FloSch62

Copy link
Copy Markdown
Member

Summary

  • move apply runtime endpoint selection onto the links.Link contract with GetRuntimeEndpoints()
  • keep stitched-link capability in the links package and update apply/deploy callers
  • persist apply state and reset resolved links for idempotent apply paths
  • remove short kind aliases from the apply docs table
  • select the VXLAN stitch endpoint by interface name instead of endpoint slice order

Validation

  • go test ./links ./core ./cmd

Split out from #3256 so that PR can stay focused on agent skills only.

@FloSch62
FloSch62 marked this pull request as ready for review July 7, 2026 12:09
@FloSch62
FloSch62 requested a review from steiler July 7, 2026 12:10
@steiler

steiler commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Dead code left behind
Endpoint Deploy() methods on EndpointVeth, EndpointHost, etc. are now unused. Harmless, but could be cleaned up in a follow-up.

Comment thread cmd/tools_veth.go Outdated
}

if err := deployable.Deploy(ctx); err != nil {
if err := clablinks.DeployEndpoint(ctx, ep); err != nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why use a Function instead of the Method that was there?
But im my view you should even just call link.Deploy() ... and the link should figure out what needs to be done...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this func indeed calls link.Deploy(ctx, ep). It is a helper method that adds a couple of nil checks prior to calling link.Deploy(ctx, ep)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see that... but if you have an endpoint, there should by contract be a Link associated... and I don't see why you would have a nil endpoint...
So if you then simply call Deploy on endpoint, the links is implicitely being deployed ...

@steiler steiler Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

by now there is just way to many functions floting around somewhere that magically do things that should be covered as an integrated part of the standards workflow.

// activateEndpoint brings the endpoint's interface up in its current namespace.
func activateEndpoint(ctx context.Context, e Endpoint) error {
	return e.GetNode().ExecFunction(ctx, func(_ ns.NetNS) error {
		link, err := netlink.LinkByName(e.GetIfaceName())
		if err != nil {
			return err
		}
		return netlink.LinkSetUp(link)
	})
}

why is this not implemented as Activate function on the GenericEndpoint... but referenced in every Endpoint and called specifically... things like that... the cohesion of this stuff is quite low and therefore unfortunately the complexity is high.

move endpoint. the same

func moveEndpoint(ctx context.Context, e Endpoint, dst Node) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

removed the deploy helper in 84f3c64

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'll put move and activate on the generic endpoint, good call.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the move func turned to be dependent on the concrete endpoint type, so promoting it to generic endpoint did not work. But I removed the interface MoveTo method that was redundant eb5578f

@hellt hellt changed the title Fix apply link reconciliation Improve apply link reconciliation Jul 10, 2026
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.05882% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.90%. Comparing base (2c2be72) to head (eb5578f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
mocks/mocknodes/node.go 16.66% 40 Missing ⚠️
links/link_vxlan.go 50.00% 11 Missing and 3 partials ⚠️
links/parking_node.go 30.00% 4 Missing and 3 partials ⚠️
core/deploy.go 28.57% 2 Missing and 3 partials ⚠️
links/link_bridge.go 0.00% 4 Missing ⚠️
links/endpoint.go 25.00% 1 Missing and 2 partials ⚠️
core/clab.go 75.00% 1 Missing and 1 partial ⚠️
core/lifecycle.go 0.00% 2 Missing ⚠️
links/apply.go 33.33% 1 Missing and 1 partial ⚠️
cmd/tools_veth.go 0.00% 0 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3260      +/-   ##
==========================================
+ Coverage   56.76%   56.90%   +0.14%     
==========================================
  Files         248      248              
  Lines       25838    25848      +10     
==========================================
+ Hits        14667    14709      +42     
+ Misses       9496     9469      -27     
+ Partials     1675     1670       -5     
Files with missing lines Coverage Δ
cmd/tools_vxlan.go 72.72% <100.00%> (+0.70%) ⬆️
core/apply.go 46.40% <100.00%> (+2.95%) ⬆️
links/endpoint_bridge.go 48.78% <ø> (+1.97%) ⬆️
links/endpoint_dummy.go 100.00% <ø> (+30.76%) ⬆️
links/endpoint_host.go 62.50% <ø> (+7.95%) ⬆️
links/endpoint_macvlan.go 71.42% <ø> (+32.96%) ⬆️
links/endpoint_runtime.go 53.84% <ø> (-10.86%) ⬇️
links/endpoint_veth.go 100.00% <ø> (ø)
links/endpoint_vxlan.go 69.23% <ø> (+21.86%) ⬆️
links/link.go 85.39% <ø> (ø)
... and 17 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hellt

hellt commented Jul 10, 2026

Copy link
Copy Markdown
Member

lets have it in and soak it through user testing

@hellt
hellt merged commit d2e460b into main Jul 10, 2026
66 checks passed
@hellt
hellt deleted the fix/improve-apply branch July 10, 2026 11:15
kaelemc added a commit that referenced this pull request Jul 16, 2026
Re-integrate the veth-stitch link with the new deploy/apply orchestration
(#3274 unify deploy, #3260 apply reconciliation):

- move the tc stitch into LinkVEthStitched.PostDeploy (upstream calls
  link.PostDeploy generically, replacing the old type-cast post-deploy pass);
  node workers deploy the two segments, so the composite Deploy "join" and its
  Remove mutex are retired.
- implement GetRuntimeEndpoints (the two node-side endpoints) in place of the
  removed ApplyRuntimeEndpoints type-switch case, preserving apply park/restore.
- keep the apply-remove veth-stitch netns GC (now after deployLinks).
- drop EndpointOwner (folded into the Node interface upstream); keep NetemTarget.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants