Skip to content

Commit

Permalink
feat: support vlan/bond in v1, vlan in v2 for nocloud
Browse files Browse the repository at this point in the history
Fixes siderolabs#9753

Signed-off-by: Andrey Smirnov <[email protected]>
(cherry picked from commit 852baf8)
  • Loading branch information
smira committed Dec 12, 2024
1 parent 3a1727e commit df8fe4c
Show file tree
Hide file tree
Showing 13 changed files with 834 additions and 299 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ package netutils

import (
"context"
"fmt"
"log"
"time"

"github.com/cenkalti/backoff/v4"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/go-retry/retry"

Expand All @@ -28,46 +25,6 @@ func Wait(ctx context.Context, r state.State) error {
return network.NewReadyCondition(r, network.AddressReady).Wait(ctx)
}

// WaitInterfaces for the interfaces to be up to interact with platform metadata services.
func WaitInterfaces(ctx context.Context, r state.State) error {
backoff := backoff.NewExponentialBackOff()
backoff.MaxInterval = 2 * time.Second
backoff.MaxElapsedTime = 30 * time.Second

for ctx.Err() == nil {
hostInterfaces, err := safe.StateListAll[*network.LinkStatus](ctx, r)
if err != nil {
return fmt.Errorf("error listing host interfaces: %w", err)
}

numPhysical := 0

for iter := hostInterfaces.Iterator(); iter.Next(); {
iface := iter.Value()

if iface.TypedSpec().Physical() {
numPhysical++
}
}

if numPhysical > 0 {
return nil
}

log.Printf("waiting for physical network interfaces to appear...")

interval := backoff.NextBackOff()

select {
case <-ctx.Done():
return nil
case <-time.After(interval):
}
}

return nil
}

// WaitForDevicesReady waits for devices to be ready.
func WaitForDevicesReady(ctx context.Context, r state.State) error {
log.Printf("waiting for devices to be ready...")
Expand Down
Loading

0 comments on commit df8fe4c

Please sign in to comment.