Public bug reported:

[Impact]

According to netplan doc
https://netplan.readthedocs.io/en/latest/netplan-yaml

gateway4/gateway6 are deprecated and the first version deprecates these fields 
is 0.103,
it should use "routes:" instead.

In scripts/functions:_render_netplan, it still generates the deprecated
fields in /run/netplan/xxx.yaml:

        if [ -n "$gateway4" ]; then
                echo "      gateway4: \"$gateway4\""
        fi
        if [ -n "$gateway6" ]; then
                echo "      gateway6: \"$gateway6\""
        fi

Then casper copies this config to root filesystem and later on used by 
cloud-init:
https://git.launchpad.net/ubuntu/+source/casper/tree/scripts/casper-bottom/58server_network?h=applied/ubuntu/noble-updates#n47

In this case, cloud-init returns 2 (success with recoverable errors)
rather than '0' (success)

We should modify these fields to use "routes:" based on netplan doc:
https://netplan.readthedocs.io/en/latest/netplan-yaml/#default-routes


[Test Case]

To verify if it generates the correct netplan config, we can specify ip
related config in kernel cmdline in grub menu and check the yaml file in
/run/netplan/

Steps to reproduce the netplan config:

1. launch a test VM in lxd
2. go into grub menu
3. pass ip related info to kernel cmdline, e.g.
ip=10.194.146.91::10.194.146.1:255.255.255.0::::10.194.146.1
4. boot into system and check /run/netplan/xxx.yaml

Originally, it generates something like:
cat /run/netplan/enp5s0.yaml 
network:
  version: 2
  ethernets:
    enp5s0:
      addresses:
        - "10.194.146.91/24"
      gateway4: "10.194.146.1"
      nameservers:
        addresses: ["10.194.146.1"]

After the patch, it generates something like:
cat /run/netplan/enp5s0.yaml 
network:
  version: 2
  ethernets:
    enp5s0:
      addresses:
        - "10.194.146.91/24"
      routes:
        - to: default
          via: "10.194.146.1"
      nameservers:
        addresses: ["10.194.146.1"]


[Where problems could occur]

This patch follows the netplan doc to use "routes:" for default gateway,
if the format is correct, it shouldn't cause any issue. 

[Other Info]
https://bugs.launchpad.net/cloud-init/+bug/1992512

** Affects: initramfs-tools (Ubuntu)
     Importance: Undecided
     Assignee: gerald.yang (gerald-yang-tw)
         Status: In Progress

** Affects: initramfs-tools (Ubuntu Focal)
     Importance: Undecided
     Assignee: gerald.yang (gerald-yang-tw)
         Status: In Progress

** Affects: initramfs-tools (Ubuntu Jammy)
     Importance: Undecided
     Assignee: gerald.yang (gerald-yang-tw)
         Status: In Progress

** Affects: initramfs-tools (Ubuntu Noble)
     Importance: Undecided
     Assignee: gerald.yang (gerald-yang-tw)
         Status: In Progress

** Affects: initramfs-tools (Ubuntu Oracular)
     Importance: Undecided
     Assignee: gerald.yang (gerald-yang-tw)
         Status: In Progress

** Affects: initramfs-tools (Ubuntu Plucky)
     Importance: Undecided
     Assignee: gerald.yang (gerald-yang-tw)
         Status: In Progress

** Changed in: initramfs-tools (Ubuntu)
     Assignee: (unassigned) => gerald.yang (gerald-yang-tw)

** Changed in: initramfs-tools (Ubuntu)
       Status: New => In Progress

** Also affects: initramfs-tools (Ubuntu Plucky)
   Importance: Undecided
     Assignee: gerald.yang (gerald-yang-tw)
       Status: In Progress

** Also affects: initramfs-tools (Ubuntu Focal)
   Importance: Undecided
       Status: New

** Also affects: initramfs-tools (Ubuntu Oracular)
   Importance: Undecided
       Status: New

** Also affects: initramfs-tools (Ubuntu Noble)
   Importance: Undecided
       Status: New

** Also affects: initramfs-tools (Ubuntu Jammy)
   Importance: Undecided
       Status: New

** Changed in: initramfs-tools (Ubuntu Focal)
     Assignee: (unassigned) => gerald.yang (gerald-yang-tw)

** Changed in: initramfs-tools (Ubuntu Jammy)
     Assignee: (unassigned) => gerald.yang (gerald-yang-tw)

** Changed in: initramfs-tools (Ubuntu Noble)
     Assignee: (unassigned) => gerald.yang (gerald-yang-tw)

** Changed in: initramfs-tools (Ubuntu Oracular)
     Assignee: (unassigned) => gerald.yang (gerald-yang-tw)

** Changed in: initramfs-tools (Ubuntu Oracular)
       Status: New => In Progress

** Changed in: initramfs-tools (Ubuntu Noble)
       Status: New => In Progress

** Changed in: initramfs-tools (Ubuntu Focal)
       Status: New => In Progress

** Changed in: initramfs-tools (Ubuntu Jammy)
       Status: New => In Progress

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to initramfs-tools in Ubuntu.
https://bugs.launchpad.net/bugs/2093164

Title:
  initramfs-tools generates deprecated netplan config gateway4 and
  gateway6

Status in initramfs-tools package in Ubuntu:
  In Progress
Status in initramfs-tools source package in Focal:
  In Progress
Status in initramfs-tools source package in Jammy:
  In Progress
Status in initramfs-tools source package in Noble:
  In Progress
Status in initramfs-tools source package in Oracular:
  In Progress
Status in initramfs-tools source package in Plucky:
  In Progress

Bug description:
  [Impact]

  According to netplan doc
  https://netplan.readthedocs.io/en/latest/netplan-yaml

  gateway4/gateway6 are deprecated and the first version deprecates these 
fields is 0.103,
  it should use "routes:" instead.

  In scripts/functions:_render_netplan, it still generates the
  deprecated fields in /run/netplan/xxx.yaml:

        if [ -n "$gateway4" ]; then
                echo "      gateway4: \"$gateway4\""
        fi
        if [ -n "$gateway6" ]; then
                echo "      gateway6: \"$gateway6\""
        fi

  Then casper copies this config to root filesystem and later on used by 
cloud-init:
  
https://git.launchpad.net/ubuntu/+source/casper/tree/scripts/casper-bottom/58server_network?h=applied/ubuntu/noble-updates#n47

  In this case, cloud-init returns 2 (success with recoverable errors)
  rather than '0' (success)

  We should modify these fields to use "routes:" based on netplan doc:
  https://netplan.readthedocs.io/en/latest/netplan-yaml/#default-routes

  
  [Test Case]

  To verify if it generates the correct netplan config, we can specify
  ip related config in kernel cmdline in grub menu and check the yaml
  file in /run/netplan/

  Steps to reproduce the netplan config:

  1. launch a test VM in lxd
  2. go into grub menu
  3. pass ip related info to kernel cmdline, e.g.
  ip=10.194.146.91::10.194.146.1:255.255.255.0::::10.194.146.1
  4. boot into system and check /run/netplan/xxx.yaml

  Originally, it generates something like:
  cat /run/netplan/enp5s0.yaml 
  network:
    version: 2
    ethernets:
      enp5s0:
        addresses:
          - "10.194.146.91/24"
        gateway4: "10.194.146.1"
        nameservers:
          addresses: ["10.194.146.1"]

  After the patch, it generates something like:
  cat /run/netplan/enp5s0.yaml 
  network:
    version: 2
    ethernets:
      enp5s0:
        addresses:
          - "10.194.146.91/24"
        routes:
          - to: default
            via: "10.194.146.1"
        nameservers:
          addresses: ["10.194.146.1"]

  
  [Where problems could occur]

  This patch follows the netplan doc to use "routes:" for default gateway,
  if the format is correct, it shouldn't cause any issue. 

  [Other Info]
  https://bugs.launchpad.net/cloud-init/+bug/1992512

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/2093164/+subscriptions


-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to