Page MenuHomeVyOS Platform

Migration Error for Dynamic DNS "Service dns dynamic address" doesn't exist
In progress, NormalPublicBUG

Description

Hello,

Trying to configure a new VyOS instance using my ansible process that templates out config chunks and merges them in. When attempting to merge in the following config section:

service {
    conntrack-sync {
        accept-protocol tcp
        accept-protocol udp
        accept-protocol icmp
        failover-mechanism {
            vrrp {
                sync-group MAIN
            }
        }
        interface eth0 {
        }
        mcast-group 225.0.0.50
    }
    dhcp-relay {
        listen-interface eth0.40
        listen-interface eth0.50
        listen-interface eth0
        listen-interface eth0.20
        listen-interface eth0.30
        listen-interface eth0.110
        listen-interface eth0.200
        relay-options {
            relay-agents-packets discard
        }
        server 10.0.10.10
        server 10.0.10.11
        server 10.0.10.12
        server 10.0.10.13
        upstream-interface eth0.10
    }
    dns {
        dynamic {
            name namecheap {
                address {
                    interface peth0
                }
                host-name @
                host-name meep
                password asdf
                protocol namecheap
                username meep.com
            }
        }
    }
    ntp {
        allow-client {
            address 10.0.0.0/8
            address ::/0
        }
        listen-address 0.0.0.0
        server time1.vyos.net {
        }
        server time2.vyos.net {
        }
        server time3.vyos.net {
        }
    }
    router-advert {
        interface eth0.40 {
            link-mtu 1500
            name-server fdf0:ff1e::10:a
            name-server fdf0:ff1e::10:b
            prefix ::/64 {
            }
        }
        interface eth0.200 {
            link-mtu 1500
            name-server fdf0:ff1e::10:a
            name-server fdf0:ff1e::10:b
            prefix ::/64 {
            }
        }
    }
    ssh {
        listen-address 10.0.0.2
        port 22
    }
}
interfaces {
}

I get the following migration error:

vyos.migrate - ERROR - Error in /opt/vyatta/etc/config-migrate/migrate/dns-dynamic/1-to-2: Path [b'service dns dynamic address'] doesn't exist
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/vyos/compose_config.py", line 56, in apply_func
    func(self.config_tree)
  File "/opt/vyatta/etc/config-migrate/migrate/dns-dynamic/1-to-2", line 40, in migrate
    for address in config.list_nodes(address_path):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configtree.py", line 322, in list_nodes
    raise ConfigTreeError("Path [{}] doesn't exist".format(path_str))
vyos.configtree.ConfigTreeError: Path [b'service dns dynamic address'] doesn't exist

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/vyos/compose_config.py", line 73, in apply_file
    self.apply_func(func)
  File "/usr/lib/python3/dist-packages/vyos/compose_config.py", line 60, in apply_func
    raise ComposeConfigError(e) from e
vyos.compose_config.ComposeConfigError: Path [b'service dns dynamic address'] doesn't exist

incomplete migration: check /opt/vyatta/etc/config/vyos-migrate.log for error
[edit]

vyos-migrate.log just shows that it's failing in the dns-dynamic/1-to-2 script located in the repository here: https://github.com/vyos/vyos-1x/blob/current/src/migration-scripts/dns-dynamic/1-to-2 . Can likely be solved by checking if address is configured before running through the for loops. If I can get some guidance I'd love to try to contribute.

Details

Version
1.5-rolling-202412060007
Is it a breaking change?
Behavior change
Issue type
Bug (incorrect behavior)

Event Timeline

Viacheslav triaged this task as Normal priority.Dec 16 2024, 9:15 AM

Seems the following fixed it in the code. At the very least it didn't error anymore. I'll happily try to make a merge request for it but I've never done that on a project of this scale before so I'd like some guidance.

# Copyright 2023-2024 VyOS maintainers and contributors <maintainers@vyos.io>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library.  If not, see <http://www.gnu.org/licenses/>.

# T5708:
# - migrate "service dns dynamic timeout ..."
#        to "service dns dynamic interval ..."
# - remove "service dns dynamic address <interface> web-options ..." when <interface> != "web"
# - migrate "service dns dynamic address <interface> service <service> protocol dnsexit"
#        to "service dns dynamic address <interface> service <service> protocol dnsexit2"

from vyos.configtree import ConfigTree

base_path = ['service', 'dns', 'dynamic']
timeout_path = base_path + ['timeout']
address_path = base_path + ['address']

def migrate(config: ConfigTree) -> None:
    if not config.exists(base_path):
        # Nothing to do
        return

    # Migrate "service dns dynamic timeout ..."
    #      to "service dns dynamic interval ..."
    if config.exists(timeout_path):
        config.rename(timeout_path, 'interval')

    # Remove "service dns dynamic address <interface> web-options ..." when <interface> != "web"
    if config.exists(address_path):
        for address in config.list_nodes(address_path):
            if config.exists(address_path + [address, 'web-options']) and address != 'web':
                config.delete(address_path + [address, 'web-options'])

    # Migrate "service dns dynamic address <interface> service <service> protocol dnsexit"
    #      to "service dns dynamic address <interface> service <service> protocol dnsexit2"
        for address in config.list_nodes(address_path):
            for svc_cfg in config.list_nodes(address_path + [address, 'service']):
                if config.exists(address_path + [address, 'service', svc_cfg, 'protocol']):
                    protocol = config.return_value(address_path + [address, 'service', svc_cfg, 'protocol'])
                    if protocol == 'dnsexit':
                        config.set(address_path + [address, 'service', svc_cfg, 'protocol'], 'dnsexit2')
Viacheslav changed the task status from Open to In progress.Dec 17 2024, 8:08 AM
Viacheslav assigned this task to gsggage.