Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix metadata Update for Linux interfaces #1777

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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