Skip to content

Commit

Permalink
Flush ip before setting ip
Browse files Browse the repository at this point in the history
Signed-off-by: Balazs Nemeth <[email protected]>
  • Loading branch information
bn222 committed Jan 20, 2025
1 parent f8c46d8 commit 19da44e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ipu-plugin/pkg/ipuplugin/lifecycleservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type LifeCycleServiceServer struct {
mode string
p4rtbin string
bridgeCtlr types.BridgeController
initialized bool // Currently, can only call initiliaze once
}

const (
Expand Down Expand Up @@ -85,6 +86,7 @@ func NewLifeCycleService(daemonHostIp, daemonIpuIp string, daemonPort int, mode
mode: mode,
p4rtbin: p4rtbin,
bridgeCtlr: brCtlr,
initialized: false,
}
}

Expand Down Expand Up @@ -893,6 +895,11 @@ func (s *FXPHandlerImpl) configureFXP(p4rtbin string, brCtlr types.BridgeControl
}

func (s *LifeCycleServiceServer) Init(ctx context.Context, in *pb.InitRequest) (*pb.IpPort, error) {
if s.initialized {
return nil, fmt.Errorf("Error during init call, already initialized")
}
s.initialized = true

InitHandlers()

if in.DpuMode && s.mode != types.IpuMode || !in.DpuMode && s.mode != types.HostMode {
Expand Down
5 changes: 5 additions & 0 deletions ipu-plugin/pkg/ipuplugin/ovsbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func (b *ovsBridge) EnsureBridgeExists() error {
log.Errorf("EnsureBridgeExists: error->%v from getInfrapodNamespace", err)
return err
}
// Flush any existing IP addresses from the bridge interface from any previous runs
flushIPCmd := []string{"net", "exec", netNs, "ip", "addr", "flush", "dev", b.bridgeName}
if err := utils.ExecOsCommand("ip", flushIPCmd...); err != nil {
return fmt.Errorf("error flushing IP addresses for bridge %s: %v", b.bridgeName, err)
}
//assigning IP for bridge interface.
ipAddr := ACC_VM_PR_IP
cmdParams := []string{"net", "exec", netNs, "ip", "addr", "add", "dev", b.bridgeName, ipAddr}
Expand Down

0 comments on commit 19da44e

Please sign in to comment.