[Bug 2070318] Re: netplan does not quote values passed to ovs-vsctl when needed

Lukas Märdian 2070318 at bugs.launchpad.net
Mon Jan 13 12:03:37 UTC 2025


** Changed in: netplan.io (Ubuntu Oracular)
       Status: In Progress => Fix Released

** Changed in: netplan.io (Ubuntu Noble)
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to netplan.io in Ubuntu.
Matching subscriptions: foundations-bugs
https://bugs.launchpad.net/bugs/2070318

Title:
  netplan does not quote values passed to ovs-vsctl when needed

Status in Netplan:
  Fix Released
Status in netplan.io package in Ubuntu:
  Fix Released
Status in netplan.io source package in Jammy:
  New
Status in netplan.io source package in Noble:
  Fix Released
Status in netplan.io source package in Oracular:
  Fix Released

Bug description:
  TL;DR: some values need to be quoted when passing them to ovs-vsctl
  during `netplan apply` handling, otherwise OVSDB will error out.

  When running `netplan apply` after setting a complex option like

  ```
    openvswitch:
      external-ids:
        ovn-cms-options: "card-serial-number=MT42424242N8,enable-chassis-as-gw"
  ```

  the first time everything works well. But any follow-up invocations
  will break with an error like this when netplan tries to clean the
  options it remembers about up:

  ['/usr/bin/ovs-vsctl', 'remove', 'Open_vSwitch', '.', 'external-ids',
  'ovn-cms-options', 'card-serial-number=MT42424242N8,enable-chassis-as-
  gw']' returned non-zero exit status 1.

  Properly quoted values are passed in correctly without an error:

  sudo ovs-vsctl remove Open_vSwitch . external-ids ovn-cms-
  options='"card-serial-number=MT42424242N8,enable-chassis-as-gw"'

  --
  OVSDB does not limit string value contents so long as they are properly escaped:

  https://man7.org/linux/man-pages/man5/ovs-vswitchd.conf.db.5.html
  "external_ids: map of string-string pairs"

  https://man7.org/linux/man-pages/man8/ovn-controller.8.html
  "external_ids:ovn-cms-options A list of options that will be consumed by the CMS Plugin and which specific to this particular chassis. An example would be: cms_option1,cms_option2:foo."

  
  Complex usages of external_ids:ovn-cms-options (including the ones containing the equal sign) are well-documented in different projects, e.g.: https://docs.openstack.org/neutron/latest/admin/ovn/availability_zones.html
  ```
  ovs-vsctl set Open_vSwitch . external-ids:ovn-cms-options="enable-chassis-as-gw,availability-zones=az-0:az-1:az-2"
  ```

  --
  Detailed info:

  $ apt policy netplan.io 
  netplan.io:
    Installed: 0.106.1-7ubuntu0.22.04.2
    Candidate: 0.106.1-7ubuntu0.22.04.2
    Version table:
   *** 0.106.1-7ubuntu0.22.04.2 500
          500 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 Packages
          100 /var/lib/dpkg/status
       0.104-0ubuntu2 500
          500 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 Packages

  
  $ cat /etc/netplan/60-mlnx.yaml 
  network:
    ethernets:
  # ...
  bridges:
      br-provider:
        openvswitch: {}
    openvswitch:
      external-ids:
  # ...
        ovn-cms-options: "card-serial-number=MT42424242N8,enable-chassis-as-gw"
  # ...
    renderer: networkd
    version: 2

  
  $ sudo ovs-vsctl list open
  # ...
  external_ids        : {hostname=bf3, "netplan/external-ids/hostname"=bf3, "netplan/external-ids/ovn-cms-options"="card-serial-number=MT42424242N8,enable-chassis-as-gw", ovn-cms-options="card-serial-number=MT42424242N8,enable-chassis-as-gw", rundir="/var/run/openvswitch", system-id="bf3"}
  # ...
  ovs_version         : "3.3.0"
  # ...
  system_type         : ubuntu
  system_version      : "22.04"

  $ sudo netplan apply 
  ovs-vsctl: card-serial-number=MT42424242N8,enable-chassis-as-gw: unexpected "=" parsing set of 1 or more strings
  Traceback (most recent call last):
    File "/usr/sbin/netplan", line 23, in <module>
      netplan.main()
    File "/usr/share/netplan/netplan/cli/core.py", line 56, in main
      self.run_command()
    File "/usr/share/netplan/netplan/cli/utils.py", line 243, in run_command
      self.func()
    File "/usr/share/netplan/netplan/cli/commands/apply.py", line 63, in run
      self.run_command()
    File "/usr/share/netplan/netplan/cli/utils.py", line 243, in run_command
      self.func()
    File "/usr/share/netplan/netplan/cli/commands/apply.py", line 169, in command_apply
      NetplanApply.process_ovs_cleanup(config_manager, old_files_ovs, restart_ovs, exit_on_error)
    File "/usr/share/netplan/netplan/cli/commands/apply.py", line 411, in process_ovs_cleanup
      apply_ovs_cleanup(config_manager, ovs_old, ovs_current)
    File "/usr/share/netplan/netplan/cli/ovs.py", line 179, in apply_ovs_cleanup
      clear_setting(t, iface, setting, val)
    File "/usr/share/netplan/netplan/cli/ovs.py", line 107, in clear_setting
      _del_dict(type, iface, split[1], split[2], value)
    File "/usr/share/netplan/netplan/cli/ovs.py", line 60, in _del_dict
      subprocess.check_call([OPENVSWITCH_OVS_VSCTL, 'remove', type, iface, column, key, _escape_colon(value)])
    File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/usr/bin/ovs-vsctl', 'remove', 'Open_vSwitch', '.', 'external-ids', 'ovn-cms-options', 'card-serial-number=MT42424242N8,enable-chassis-as-gw']' returned non-zero exit status 1.

  
  The OVS code that errors out during parsing:

  https://github.com/openvswitch/ovs/blob/2f196c80e7165150d956fc50de0db58b8964ee2e/lib/ovsdb-data.c#L1623-L1633
  https://github.com/openvswitch/ovs/blob/2f196c80e7165150d956fc50de0db58b8964ee2e/lib/ovsdb-data.c#L2561-L2567

  
  To make netplan forget about the option and remove the values set:

  sudo ovs-vsctl remove open . external-ids netplan/external-ids/ovn-cms-options
  # after the command above ^ netplan apply works again
  sudo ovs-vsctl remove Open_vSwitch . external-ids ovn-cms-options='"card-serial-number=MT42424242N8,enable-chassis-as-gw"'

To manage notifications about this bug go to:
https://bugs.launchpad.net/netplan/+bug/2070318/+subscriptions




More information about the foundations-bugs mailing list