Skip to content

Commit

Permalink
update lease when dhcp hostname changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BeryJu committed May 23, 2024
1 parent 119b14a commit cedcbd6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/roles/dhcp/leases.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ func (l *Lease) createReply(req *Request4) *dhcpv4.DHCPv4 {
rep.UpdateOption(dhcpv4.OptDomainSearch(&rfc1035label.Labels{Labels: l.scope.DNS.Search}))
}
}

// Check if the request has a different hostname, and update the lease
if req.HostName() != l.Hostname {
l.Hostname = req.HostName()
// Update lease with new hostname
go func() {
err := l.Put(req.Context, l.Expiry)
if err != nil {
l.log.Warn("failed to update lease", zap.Error(err))
}
}()
}
if l.Hostname != "" {
hostname := l.Hostname
if l.scope.DNS != nil && l.scope.DNS.AddZoneInHostname {
Expand Down

0 comments on commit cedcbd6

Please sign in to comment.