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

T6948: Keep DHCP server leases in sync with hostd records #4237

Open
wants to merge 4 commits into
base: current
Choose a base branch
from

Conversation

indrajitr
Copy link
Contributor

@indrajitr indrajitr commented Dec 13, 2024

Change Summary

Keep DHCP server leases in sync with vyos-hostd records via helper script invoked with ExecStartPost directive in kea-dhcp4-server.service.

The helper script updates VyOS hostd records from DHCP server leases. This ensures that hostd records with the DHCP server leases are kept in sync with VyOS hostd records right after DHCP server is started.

Currently, this is implemented for DHCPv4 only.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

Component(s) name

dhcp server

Proposed changes

How to test

  1. Enable DHCP server and have active server leases
  2. Ensure that relevant host entries exist in /etc/hosts and/or /run/vyos-hostsd/vyos-hostsd.state
  3. Restart VyOS
  4. Verify DHCP server leases are still active (show dhcp server leases)
  5. Verify that the leases have NOT been applied to /etc/hosts
  6. Restart dhcp server (restart dhcp server)
  7. Verify that the leases have been applied to /etc/hosts

Smoketest result

vyos@test-1216:~$ /usr/libexec/vyos/tests/smoke/cli/test_service_dhcp-server.py
test_dhcp_exclude_in_range (__main__.TestServiceDHCPServer.test_dhcp_exclude_in_range) ... ok
test_dhcp_exclude_not_in_range (__main__.TestServiceDHCPServer.test_dhcp_exclude_not_in_range) ... ok
test_dhcp_high_availability (__main__.TestServiceDHCPServer.test_dhcp_high_availability) ... ok
test_dhcp_high_availability_standby (__main__.TestServiceDHCPServer.test_dhcp_high_availability_standby) ... ok
test_dhcp_hostsd_lease_sync (__main__.TestServiceDHCPServer.test_dhcp_hostsd_lease_sync) ... ok
test_dhcp_multiple_pools (__main__.TestServiceDHCPServer.test_dhcp_multiple_pools) ... ok
test_dhcp_on_interface_with_vrf (__main__.TestServiceDHCPServer.test_dhcp_on_interface_with_vrf) ... ok
test_dhcp_relay_server (__main__.TestServiceDHCPServer.test_dhcp_relay_server) ... ok
test_dhcp_single_pool_options (__main__.TestServiceDHCPServer.test_dhcp_single_pool_options) ... ok
test_dhcp_single_pool_options_scoped (__main__.TestServiceDHCPServer.test_dhcp_single_pool_options_scoped) ... ok
test_dhcp_single_pool_range (__main__.TestServiceDHCPServer.test_dhcp_single_pool_range) ... ok
test_dhcp_single_pool_static_mapping (__main__.TestServiceDHCPServer.test_dhcp_single_pool_static_mapping) ... ok

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

Copy link

github-actions bot commented Dec 13, 2024

👍
No issues in PR Title / Commit Title

@indrajitr
Copy link
Contributor Author

Keeping it as draft till I have a working test environment.

@indrajitr indrajitr marked this pull request as draft December 13, 2024 18:01
@indrajitr indrajitr force-pushed the hostd-update branch 2 times, most recently from 5e444ca to 748310c Compare December 19, 2024 00:24
@indrajitr indrajitr marked this pull request as ready for review December 19, 2024 00:29
- `kea_add_lease` to add a lease to the running kea server
- `kea_get_domain_from_subnet_id` to get the domain name from subnet id
Keep DHCP server leases in sync with vyos-hostd records
via helper script invoked with `ExecStartPost` directive
in kea-dhcp4-server.service.

The helper script updates VyOS hostd records from
DHCP server leases. This ensures that hostd records
with the DHCP server leases are kept in sync with
VyOS hostd records right after DHCP server is started.

Currently, this is implemented for DHCPv4 only.
The helper script updates VyOS hostd records from
DHCP server leases. This ensures that hostd records
with the DHCP server leases are kept in sync with
VyOS hostd records right after DHCP server is started.

Note that `Restart` directive needs to be updated to
`on-failure` so that the service is restarted in case
of failure/timeout in interaction with hostd service.
The test `test_dhcp_hostsd_lease_sync` validates
DHCP server leases in sync with hostd records.

Since the DHCP server running in smoketest environment
might not have actual clients to lease IP addresses,
we simulate the lease creation and deletion using
kea helper functions (kea_add_lease and kea_delete_lease).
Copy link

CI integration ❌ failed!

Details

CI logs

  • CLI Smoketests (no interfaces) ❌ failed
  • CLI Smoketests (interfaces only) ❌ failed
  • Config tests 👍 passed
  • RAID1 tests 👍 passed
  • TPM tests 👍 passed

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

Successfully merging this pull request may close these issues.

1 participant