Skip to content

Commit

Permalink
fix: Fix metadata Update for Linux interfaces (#1777)
Browse files Browse the repository at this point in the history
Signed-off-by: Milan Lenco <[email protected]>
  • Loading branch information
Milan Lenčo authored Jan 15, 2021
1 parent a04d009 commit 23ac3a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
21 changes: 12 additions & 9 deletions plugins/linux/ifplugin/descriptor/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,17 +494,16 @@ func (d *InterfaceDescriptor) Update(key string, oldLinuxIf, newLinuxIf *interfa
oldHostName := getHostIfName(oldLinuxIf)
newHostName := getHostIfName(newLinuxIf)

// update metadata
link, err := d.ifHandler.GetLinkByName(newHostName)
if err != nil {
d.log.Error(err)
return nil, err
}
oldMetadata.LinuxIfIndex = link.Attrs().Index
oldMetadata.HostIfName = newHostName
oldMetadata.VrfMasterIf = newLinuxIf.VrfMasterInterface
if oldLinuxIf.Type == interfaces.Interface_EXISTING {
// with existing interface only metadata needs to be updated
link, err := d.ifHandler.GetLinkByName(newHostName)
if err != nil {
d.log.Error(err)
return nil, err
}
oldMetadata.LinuxIfIndex = link.Attrs().Index
oldMetadata.HostIfName = newHostName
oldMetadata.VrfMasterIf = newLinuxIf.VrfMasterInterface
return oldMetadata, nil
}

Expand Down Expand Up @@ -583,6 +582,10 @@ func (d *InterfaceDescriptor) Update(key string, oldLinuxIf, newLinuxIf *interfa
}
}
}

// update metadata
oldMetadata.HostIfName = newHostName
oldMetadata.VrfMasterIf = newLinuxIf.VrfMasterInterface
return oldMetadata, nil
}

Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/012_linux_interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ func TestDummyInterface(t *testing.T) {
Expect(ctx.PingFromMs(msName, ipAddr1)).To(Succeed())
Expect(ctx.PingFromMs(msName, ipAddr2)).To(Succeed())
Expect(ctx.AgentInSync()).To(BeTrue())

// Disable dummy1
dummyIf1.Enabled = false
req = ctx.GenericClient().ChangeRequest()
err = req.Update(
dummyIf1,
).Send(context.Background())
Expect(err).ToNot(HaveOccurred())
}

// Test interfaces created externally but with IP addresses assigned by the agent.
Expand Down

0 comments on commit 23ac3a6

Please sign in to comment.