incus/dhcp: Explicitly requesting 51/58/59, derive sane T1, add jitter #2383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The built-in DHCPv4 client used for OCI containers can overwhelm the DHCP server with renewals every 60 seconds. This occurred when the initial DHCPOFFER lacked renewal/rebind timers (Options 58/59). The renewal loop slept using IPAddressRenewalTime(time.Minute), so the fallback value (1 minute) was used repeatedly.
Additionally, the initial request implicitly asked for a fixed lease time (Option 51) and did not include a Parameter Request List for 51/58/59. Many servers respond by honoring the client’s requested lease (e.g., 3600s) and omitting 58/59 in the OFFER/ACK. Together, these two behaviors produced one-minute renewals even when the server was configured for multi-hour leases.
This change fixes the above by:
Not requesting a fixed lease in the client message (WithoutOption(OptionIPAddressLeaseTime)), allowing the server’s default-lease-time to apply.
Explicitly requesting critical options via PRL on both REQUEST and RENEW: 1,3,6,15,51,58,59 (and 121 if present). This makes servers include Lease-Time/T1/T2.
Deriving a sane T1 for the renewal sleep: prefer timers from the ACK, then OFFER; if still absent, use 50% of the offered lease-time (Option 51); finally fall back to 1m.
Adding ±5% jitter to the renewal sleep to avoid herd effects when many containers renew at once.