Fix kea-dhcp4 startup failure after trixie upgrade#26878
Open
yxieca wants to merge 1 commit intosonic-net:masterfrom
Open
Fix kea-dhcp4 startup failure after trixie upgrade#26878yxieca wants to merge 1 commit intosonic-net:masterfrom
yxieca wants to merge 1 commit intosonic-net:masterfrom
Conversation
Kea 2.6 (trixie) enforces strict path restrictions: - Logs must be under /var/log/kea (not /var/log) - Control socket dir /run/kea must exist with mode 750 - Lease files must be under /var/lib/kea (not /tmp) Update all kea config files, Dockerfile, docker_init.sh, and dhcp utilities code to use Kea 2.6 compliant paths. Fixes: sonic-net#26845 Signed-off-by: Ying Xie <ying.xie@microsoft.com>
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Kea DHCPv4 startup failures in the dhcp_server container after the Debian trixie upgrade by aligning Kea config/runtime paths with Kea 2.6+ strict path validation rules (log/lease/control socket directories).
Changes:
- Create required Kea directories at build time and runtime, including enforcing
/run/keapermissions (750). - Update Kea DHCPv4 config/templates and DHCP utilities code to use
/var/log/kea/…,/var/lib/kea/…, and/run/kea/…paths. - Update unit tests and test data templates to match the new paths.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dockers/docker-dhcp-server/Dockerfile.j2 | Creates /run/kea, /var/log/kea, /var/lib/kea and applies required /run/kea mode. |
| dockers/docker-dhcp-server/docker_init.sh | Ensures required Kea directories exist at container start and enforces /run/kea mode 750. |
| dockers/docker-dhcp-server/kea-dhcp4-init.conf | Updates default (initial) Kea config to compliant log/lease/control-socket paths. |
| dockers/docker-dhcp-server/kea-dhcp4.conf.j2 | Updates rendered Kea config log output path to /var/log/kea/… and uses /run/kea control socket. |
| src/sonic-dhcp-utilities/dhcp_utilities/dhcpservd/dhcp_cfggen.py | Updates default lease file path used by the Kea config generator. |
| src/sonic-dhcp-utilities/dhcp_utilities/dhcpservd/dhcp_lease.py | Updates default lease file path used by the lease reader/handler. |
| src/sonic-dhcp-utilities/dhcp_utilities/dhcpservd/dhcpservd.py | Updates lease file path used by dhcpservd’s LeaseManager. |
| src/sonic-dhcp-utilities/tests/conftest.py | Updates mocked lease_path to match new default lease location. |
| src/sonic-dhcp-utilities/tests/test_data/kea-dhcp4.conf.j2 | Updates test template log path to /var/log/kea/…. |
| src/sonic-dhcp-utilities/tests/test_dhcp_cfggen.py | Updates expected rendered Kea config dict and expected lease_path. |
| src/sonic-dhcp-utilities/tests/test_smart_switch.py | Updates expected rendered Kea config dict paths for smart switch scenario. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why I did it
Fixes #26845
After the trixie upgrade, kea-dhcp4 (version 2.6.3) fails to start in the dhcp_server container. Kea 2.6 enforces strict path validation that was not present in earlier versions:
/var/log/kea/(not/var/log/)/var/lib/kea/(not/tmp/)/run/kea/with mode 750Without this fix, kea-dhcp4 exits with:
Work item tracking
How I did it
Created required directories with correct permissions in both
Dockerfile.j2(build time) anddocker_init.sh(runtime):/run/kea(mode 750)/var/log/kea/var/lib/keaUpdated all path references across config files, templates, and Python code:
/var/log/kea-dhcp.log→/var/log/kea/kea-dhcp4.log/tmp/kea-lease.csv→/var/lib/kea/kea-lease.csv/var/run/kea/kea4-ctrl-socket→/run/kea/kea4-ctrl-socketUpdated unit tests (
test_dhcp_cfggen.py,test_smart_switch.py,conftest.py) to match new paths.Files changed (11):
dockers/docker-dhcp-server/Dockerfile.j2dockers/docker-dhcp-server/docker_init.shdockers/docker-dhcp-server/kea-dhcp4-init.confdockers/docker-dhcp-server/kea-dhcp4.conf.j2src/sonic-dhcp-utilities/dhcp_utilities/dhcpservd/dhcp_cfggen.pysrc/sonic-dhcp-utilities/dhcp_utilities/dhcpservd/dhcp_lease.pysrc/sonic-dhcp-utilities/dhcp_utilities/dhcpservd/dhcpservd.pysrc/sonic-dhcp-utilities/tests/conftest.pysrc/sonic-dhcp-utilities/tests/test_data/kea-dhcp4.conf.j2src/sonic-dhcp-utilities/tests/test_dhcp_cfggen.pysrc/sonic-dhcp-utilities/tests/test_smart_switch.pyHow to verify it
Manual verification on KVM testbed (VS image):
Reproduced the failure — reverted paths to old values inside the container, started kea-dhcp4:
Verified the fix — with corrected paths, kea-dhcp4 starts successfully:
End-to-end DHCP handshake — sent DHCP Discover from PTF container via scapy:
192.168.0.2/var/lib/kea/kea-lease.csv/run/kea/kea4-ctrl-socketKea status via control socket confirmed healthy operation:
{"result": 0, "arguments": {"pid": 38, "uptime": 1212, "sockets": {"status": "ready"}}}Which release branch to backport (provide reason below if selected)
Tested branch
9a40754bd, manual KVM testbed verification)Description for the changelog
Fix kea-dhcp4 startup failure in dhcp_server container after trixie upgrade by updating log, lease, and socket paths to comply with Kea 2.6 strict path validation.