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

T6927: adds option to set container name server #4218

Merged
merged 2 commits into from
Dec 9, 2024
Merged

Conversation

nvollmar
Copy link
Contributor

@nvollmar nvollmar commented Dec 3, 2024

Change Summary

Add option to set name server of a container

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)

https://vyos.dev/T6927

Related PR(s)

Component(s) name

container

Proposed changes

New config option to configure dns server.

How to test

Set name server of a container

set container name <name> name-server <address>

Then verify /etc/resolv.conf within the container or sudo podman inspect <name>

Smoketest result

vyos@vyos:~$ /usr/libexec/vyos/tests/smoke/cli/test_container.py
test_api_socket (__main__.TestContainer.test_api_socket) ... ok
test_basic (__main__.TestContainer.test_basic) ... ok
test_cpu_limit (__main__.TestContainer.test_cpu_limit) ... ok
test_dual_stack_network (__main__.TestContainer.test_dual_stack_network) ... ok
test_ipv4_network (__main__.TestContainer.test_ipv4_network) ... ok
test_ipv6_network (__main__.TestContainer.test_ipv6_network) ... ok
test_name_server (__main__.TestContainer.test_name_server) ... ok
test_network_mtu (__main__.TestContainer.test_network_mtu) ... ok
test_no_name_server (__main__.TestContainer.test_no_name_server) ... ok
test_uid_gid (__main__.TestContainer.test_uid_gid) ... 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 3, 2024

👍
No issues in PR Title / Commit Title

@nvollmar nvollmar force-pushed the T6927 branch 2 times, most recently from 09f75eb to a09a769 Compare December 5, 2024 10:58
@sever-sever
Copy link
Member

Smoketest fails

DEBUG - Running Testcase: /usr/libexec/vyos/tests/smoke/cli/test_container.py
DEBUG - test_api_socket (__main__.TestContainer.test_api_socket) ... ok
DEBUG - test_basic (__main__.TestContainer.test_basic) ... ok
DEBUG - test_cpu_limit (__main__.TestContainer.test_cpu_limit) ... ok
DEBUG - test_dual_stack_network (__main__.TestContainer.test_dual_stack_network) ... ok
DEBUG - test_ipv4_network (__main__.TestContainer.test_ipv4_network) ... ok
DEBUG - test_ipv6_network (__main__.TestContainer.test_ipv6_network) ... ok
DEBUG - test_name_server (__main__.TestContainer.test_name_server) ... ERROR
DEBUG - test_name_server (__main__.TestContainer.test_name_server) ... FAIL
DEBUG - test_network_mtu (__main__.TestContainer.test_network_mtu) ... FAIL
DEBUG - test_no_name_server (__main__.TestContainer.test_no_name_server) ... FAIL
DEBUG - test_uid_gid (__main__.TestContainer.test_uid_gid) ... FAIL
DEBUG - 
DEBUG - ======================================================================
DEBUG - ERROR: test_name_server (__main__.TestContainer.test_name_server)
DEBUG - ----------------------------------------------------------------------
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/test_container.py", line 106, in test_name_server
DEBUG -     self.cli_commit()
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/base_vyostest_shim.py", line 86, in cli_commit
DEBUG -     self._session.commit()
DEBUG -   File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 264, in commit
DEBUG -     out = self.__run_command([COMMIT])
DEBUG -           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DEBUG -   File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 201, in __run_command
DEBUG -     raise ConfigSessionError(output)
DEBUG - vyos.configsession.ConfigSessionError: [ container ]
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/services/vyos-configd", line 137, in run_script
DEBUG -     script.apply(c)
DEBUG -   File "/usr/libexec/vyos//conf_mode/container.py", line 505, in apply
DEBUG -     cmd(f'systemctl restart vyos-container-{name}.service')
DEBUG -   File "/usr/lib/python3/dist-packages/vyos/utils/process.py", line 155, in cmd
DEBUG -     raise OSError(code, feedback)
DEBUG - PermissionError: [Errno 1] failed to run command: systemctl restart vyos-container-dns-test.service
DEBUG - returned:
DEBUG - exit code: 1
DEBUG - 
DEBUG - [[container]] failed
DEBUG - Commit failed
DEBUG - 
DEBUG - 
DEBUG - ======================================================================
DEBUG - FAIL: test_name_server (__main__.TestContainer.test_name_server)
DEBUG - ----------------------------------------------------------------------
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/test_container.py", line 71, in tearDown
DEBUG -     self.assertEqual(units, [])
DEBUG - AssertionError: Lists differ: ['/run/systemd/system/vyos-container-dns-test.service'] != []
DEBUG - 
DEBUG - First list contains 1 additional elements.
DEBUG - First extra element 0:
DEBUG - '/run/systemd/system/vyos-container-dns-test.service'
DEBUG - 
DEBUG - - ['/run/systemd/system/vyos-container-dns-test.service']
DEBUG - + []
DEBUG - 
DEBUG - ======================================================================
DEBUG - FAIL: test_network_mtu (__main__.TestContainer.test_network_mtu)
DEBUG - ----------------------------------------------------------------------
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/test_container.py", line 71, in tearDown
DEBUG -     self.assertEqual(units, [])
DEBUG - AssertionError: Lists differ: ['/run/systemd/system/vyos-container-dns-test.service'] != []
DEBUG - 
DEBUG - First list contains 1 additional elements.
DEBUG - First extra element 0:
DEBUG - '/run/systemd/system/vyos-container-dns-test.service'
DEBUG - 
DEBUG - - ['/run/systemd/system/vyos-container-dns-test.service']
DEBUG - + []
DEBUG - 
DEBUG - ======================================================================
DEBUG - FAIL: test_no_name_server (__main__.TestContainer.test_no_name_server)
DEBUG - ----------------------------------------------------------------------
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/test_container.py", line 71, in tearDown
DEBUG -     self.assertEqual(units, [])
DEBUG - AssertionError: Lists differ: ['/run/systemd/system/vyos-container-dns-test.service'] != []
DEBUG - 
DEBUG - First list contains 1 additional elements.
DEBUG - First extra element 0:
DEBUG - '/run/systemd/system/vyos-container-dns-test.service'
DEBUG - 
DEBUG - - ['/run/systemd/system/vyos-container-dns-test.service']
DEBUG - + []
DEBUG - 
DEBUG - ======================================================================
DEBUG - FAIL: test_uid_gid (__main__.TestContainer.test_uid_gid)
DEBUG - ----------------------------------------------------------------------
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/test_container.py", line 71, in tearDown
DEBUG -     self.assertEqual(units, [])
DEBUG - AssertionError: Lists differ: ['/run/systemd/system/vyos-container-dns-test.service'] != []
DEBUG - 
DEBUG - First list contains 1 additional elements.
DEBUG - First extra element 0:
DEBUG - '/run/systemd/system/vyos-container-dns-test.service'
DEBUG - 
DEBUG - - ['/run/systemd/system/vyos-container-dns-test.service']
DEBUG - + []
DEBUG - 
DEBUG - ----------------------------------------------------------------------
DEBUG - Ran 10 tests in 149.984s

@sever-sever sever-sever self-requested a review December 5, 2024 11:00
@nvollmar
Copy link
Contributor Author

nvollmar commented Dec 5, 2024

Yes, as noted in the PR I'm currently having issues building an image to debug/test. So I created this PR as draft until I can get things final

@nvollmar nvollmar force-pushed the T6927 branch 2 times, most recently from 8ac2a25 to f4abf78 Compare December 8, 2024 09:41
@nvollmar nvollmar requested a review from c-po December 9, 2024 06:27
Copy link

github-actions bot commented Dec 9, 2024

CI integration 👍 passed!

Details

CI logs

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

@c-po c-po merged commit 3ed6f02 into vyos:current Dec 9, 2024
14 of 15 checks passed
@nvollmar nvollmar deleted the T6927 branch December 9, 2024 21:34
@nvollmar
Copy link
Contributor Author

nvollmar commented Dec 9, 2024

I need to add a validation, just discovered --dns won't have an effect if it is attached to a container network with dns enabled. If container network is used it needs to have --disable-dns for it to work.

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.

3 participants