From: Casey Bodley Date: Tue, 9 Jun 2026 18:13:23 +0000 (-0400) Subject: qa/dnsmasq: remove unused backup/replace_resolv() X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=591ce1234b4fa646a0c2edadea5a6a245d2e4c44;p=ceph.git qa/dnsmasq: remove unused backup/replace_resolv() Signed-off-by: Casey Bodley --- diff --git a/qa/tasks/dnsmasq.py b/qa/tasks/dnsmasq.py index 13e44bbfe1f..4e44c8aa74d 100644 --- a/qa/tasks/dnsmasq.py +++ b/qa/tasks/dnsmasq.py @@ -3,7 +3,6 @@ Task for dnsmasq configuration """ import contextlib import logging -import re from teuthology import misc from teuthology.exceptions import ConfigError @@ -31,40 +30,6 @@ def install_dnsmasq(remote): if existing is None: packaging.remove_package('dnsmasq', remote) -@contextlib.contextmanager -def backup_resolv(remote, path, table): - """ - Store a backup of resolv.conf in the testdir and restore it after the task. - Reserve 'nameserver' values per remote name in lookup 'table' for future use. - """ - resolv_conf = remote.sh(f"cat /etc/resolv.conf | tee {path}") - nameserver_re = re.compile(r'\s*nameserver\s+([^\s]*)') - for line in resolv_conf.split('\n'): - if m := nameserver_re.match(line): - table.setdefault(remote.name, {}).setdefault('nameserver', []).append(m[1]) - try: - yield - finally: - # restore with 'cp' to avoid overwriting its security context - remote.run(args=['sudo', 'cp', path, '/etc/resolv.conf']) - remote.run(args=['rm', path]) - -@contextlib.contextmanager -def replace_resolv(remote, path, table): - """ - Update resolv.conf to point the nameserver at localhost. - """ - remote.write_file(path, "nameserver 127.0.0.1\n") - try: - # install it - if remote.os.package_type == "rpm": - # for centos ovh resolv.conf has immutable attribute set - remote.run(args=['sudo', 'chattr', '-i', '/etc/resolv.conf'], check_status=False) - remote.run(args=['sudo', 'cp', path, '/etc/resolv.conf']) - yield - finally: - remote.run(args=['rm', path]) - @contextlib.contextmanager def configure_dnsmasq(remote, path, cnames): """