Skip to content

Try fixing flaky network test - #304

Draft
majst01 wants to merge 1 commit into
mainfrom
fix-flaky-network-test
Draft

Try fixing flaky network test#304
majst01 wants to merge 1 commit into
mainfrom
fix-flaky-network-test

Conversation

@majst01

@majst01 majst01 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

test-network often fails with the same error, asking deepseek for potential fix came up with this one.

TBH i do not yet fully understand the fix :-(

Explanation:

What changed: The "ensure parent prefix exists in ipam" loop was hoisted out of the if namespace != nil block so it now runs for both namespaced and non-namespaced super networks. CreateNamespace still only runs for the namespaced case; then, for every parent prefix of the requested family, it does a GetPrefix and, if missing (NotFound), a CreatePrefix in the target namespace (the default root namespace for non-namespaced supers).

Why this fixes the flake: Previously, for a non-namespaced super, createChildPrefix called AcquireChildPrefix directly and relied on the parent prefix having been created earlier. go-ipam's AcquireChildPrefix maps a missing parent to InvalidArgument, not NotFound, so the errorutil.IsNotFound(err) { continue } guard never caught it — a transiently missing parent (e.g. from DeleteNetworks resetting ipam state between the sequential subtests) surfaced as the reported internal: NotFound prefix not found. Now the parent is deterministically materialized before allocation, independent of prior ipam state.

Used AI-Tools ✨

  • Deepseek V4 flash used for generation

@metal-robot metal-robot Bot added this to Development Sep 3, 2026
@metal-robot metal-robot Bot added the area: control-plane Affects the metal-stack control-plane area. label Sep 3, 2026
@majst01
majst01 force-pushed the fix-flaky-network-test branch from 032b381 to 8086de3 Compare September 3, 2026 05:54
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.90%. Comparing base (bb7c6ce) to head (8086de3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/repository/network.go 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #304      +/-   ##
==========================================
- Coverage   79.93%   79.90%   -0.03%     
==========================================
  Files         199      199              
  Lines       14800    14800              
==========================================
- Hits        11830    11826       -4     
- Misses       2969     2973       +4     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: control-plane Affects the metal-stack control-plane area.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant