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

Add container ifName to the dhcp clientID, making the clientID value #217

Merged
merged 2 commits into from
Nov 21, 2018

Conversation

mccv1r0
Copy link
Member

@mccv1r0 mccv1r0 commented Oct 15, 2018

now equal to: ContainerID / Host Network / ifname inside container

Use clientID as a key for the lease

Fixes #214

if !ok {
return nil
}
return l
}

func (d *DHCP) setLease(contID, netName string, l *DHCPLease) {
//func (d *DHCP) setLease(contID, netName string, ifName string, l *DHCPLease) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about to remove it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed that one, thanks

@@ -50,6 +50,12 @@ func newDHCP() *DHCP {
}
}

func generateClientID(containerID string, netName string, ifName string) string {
clientID := containerID + "/" + netName + "/" + ifName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suppose we just make it one line as
return containerID + "/" + netName + "/" + ifName

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@dcbw
Copy link
Member

dcbw commented Oct 17, 2018

On further inspection we figured out that the DHCP client code doesn't actually pass the Client ID in the packet, so even though we've fixed the internal code we have more to do. Related: d2g/dhcp4client#24

now equal to: ContainerID / Host Network / ifname inside container

Use clientID as a key for the lease

/*
//Create Discover Packet
func DhcpDiscoverPacket(c *dhcp4client.Client, options dhcp4.Options) dhcp4.Packet {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just remove all the commented-out code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed those, thanks.

@dcbw
Copy link
Member

dcbw commented Nov 14, 2018

@mccv1r0 thanks for the update; one small nit otherwise LGTM

var br *netlink.Bridge

BeforeEach(func() {
dhcpServerStopCh = make(chan bool)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next 100+ lines look very similar to lines 49 onwards in dhcp2_test.go - if they are different please add some comments indicating what is going on, otherwise pull out the common code to a shared setup function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a shared setup function as suggested

…le CNI

interfaces using dhcp ipam.

Vendor latest dhcp4server, dhcp4client, dhcp4

Added additional tests for new functionality in dhcp2_test.go

Wrap d2g dhcp4client calls with our own which add clientID to packet.
Copy link
Member

@dcbw dcbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@bboreham
Copy link
Contributor

I was wondering what happens if someone was running the previous version, and they upgrade to this version: will the IDs sent to DHCP change? But @squeed worked out that the daemon doesn't persist this information so all the leases are forgotten on every restart so this isn't a new problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants