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 <andrey.smirnov@siderolabs.com>
(cherry picked from commit 852baf8)
  • Loading branch information
smira committed Dec 9, 2024
1 parent 1c87017 commit 24f9875
Show file tree
Hide file tree
Showing 13 changed files with 833 additions and 297 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,44 +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 iface := range hostInterfaces.All() {
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 24f9875

Please sign in to comment.