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

Support OS9 -> SONiC fast-reboot migration #1414

Merged
merged 4 commits into from
Mar 9, 2018
Merged

Support OS9 -> SONiC fast-reboot migration #1414

merged 4 commits into from
Mar 9, 2018

Conversation

padmanarayana
Copy link
Contributor

- What I did

Add support for OS9 to SONiC migration in fast-reboot mode

- How I did it

  1. Disable dhcp during migration for mgmt. interface – so the initial /etc/network/interfaces will set eth0 to static (note that this is early init before the rc.local). This saves 1 minute of DHCPDISCOVERY retries..
  2. In rc.local, if this is the case of migration:
    a. Extract the NOS (OS9) partition from the cmdline (that stores the migration artifacts)
    b. Set the mac for eth0 based on OS9 setting
    c. Save the arp and fdb.jsons for use by swss
    d. Initializes the migration.xml to generate config_db
    e. On a non-migration reboot, clean up the jsons.
  3. Swssconfig: Import the migration arp and fdb.jsons if these files exist.

- How to verify it

Perform a customised version of the PTF ftos-fastreboot test (for OS9 -> SONiC migration)

- Description for the changelog
Add support for OS9 to SONiC migration in fast-reboot mode

- A picture of a cute animal (not mandatory but encouraged)

mkdir -p /etc/sonic/migration

# Copy relevant files
nos_migration_import /mnt/nos_migration/minigraph.xml /etc/sonic/migration
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could import the entire bunch of files 1 shot - but this is just to ensure we know what we are importing.

migration="TRUE"
umount /mnt/onie-boot
else
# this is a reboot post NOS migration : remove stale imported files that were used during migration.
rm -fr /etc/sonic/migration
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could remove the arp.json & fdb.json after checking that orchagent initialized but removing here localizes the migration changes to rc.local.

build_debian.sh Outdated
@@ -315,7 +315,7 @@ sudo tee -a $FILESYSTEM_ROOT/etc/network/interfaces > /dev/null <<EOF

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
iface eth0 inet static
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we are not going to disable dhcp globally? the dhcp is disabled only from ftos to sonic fast-boot migration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the earlier thought. But I could not disable this during migration since squashfs is readonly... So, changed the approach. Note that with this change, though we disable dhcp globally during the build, if there is no IP configured in the minigraph, the interfaces-config.sh would override the startup /etc/network/interfaces with a config that is set to dhcp.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you do not need to change squash fs, you can change the entry after you have mounted the union fs.

@lguohan
Copy link
Collaborator

lguohan commented Feb 23, 2018

@pavel-shirshov , can you code-review this?

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented.

nos_migration_import /mnt/nos_migration/arp.json /etc/sonic/migration
nos_migration_import /mnt/nos_migration/fdb.json /etc/sonic/migration
nos_migration_import /mnt/nos_migration/mgmt_interface.mac /etc/sonic/migration

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please put your files into /host/fast-reboot directory?
See following changes in fast-reboot script: sonic-net/sonic-utilities@461470b

In this case you don't need any changes in swssconfig.sh

@@ -29,6 +41,9 @@ function fast_reboot {
esac
}

# If we are migrating, import the dumps from the previous NOS
fast_migration

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to change this file. See my comments below

@@ -11,6 +11,16 @@
#
# By default this script does nothing.

# In case the unit is migrating from another NOS, save the logs
log_migration() {
echo $1 >> /etc/migration.log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to save it to /var/log?
Any other place, not /etc?

if [ `echo $eth0_mac | egrep "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"` ]; then
ifconfig eth0 down
ip link set eth0 address $eth0_mac
ifconfig eth0 up
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use iptools2 commands

# Copy relevant files
nos_migration_import /mnt/nos_migration/minigraph.xml /etc/sonic/migration
nos_migration_import /mnt/nos_migration/arp.json /etc/sonic/migration
nos_migration_import /mnt/nos_migration/fdb.json /etc/sonic/migration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add support for default routes in default_routes.json.
See here: sonic-net/sonic-utilities@461470b#diff-fcb2d524807024c9b0cd2e2850088f64R258

Copy link
Contributor Author

@padmanarayana padmanarayana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Create /host/migration which will contain:
    a. migration logs
    b. mgmt_interfaces.cfg (previously mgmt_interfaces.mac)
    c. minigraph.
  2. Revert changes to swssconfig.sh. the jsons are copied into /host/fast-reboot.
  3. In order to make the eth0 (and switchport MACs) persistent after the migration reboot, write the NOS's mac into the GbE EEPROM so that igb driver can use it post the migration reboot. Added ethtool for writing MAC to EEPROM.
  4. Also, update the 70-persistent-net.rules to fix the eth0 mac after migration.

@padmanarayana
Copy link
Contributor Author

Please review changes.

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks ok for me

[ -f $1 ] && cp $1 $2 || log_migration "ERROR: $1 not found!"
}

# While migrating form another NOS, we need to preserve the MAC addresses
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

form -> from

ethtool_magic=$(grep "ethtool_magic" $mgmt_config | awk -F'=' '{print $2}')
ethtool_offset=$(grep "ethtool_offset" $mgmt_config | awk -F'=' '{print $2}')
if [ -z "$ethtool_magic" ] || [ -z "$ethtool_offset" ]; then
log_migration "Unable to retrieve ethtool params ($ethtool_magic,ethtool_offset)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed $ in the error message?

rmdir /mnt/nos_migration
fi

update_mgmt_interface_macaddr /host/migration/mgmt_interface.cfg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this will work for any platform?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an assumption that the platform supports ethtool to modify the eth (GbE in S6100/Z9100) case using igb. If the platform does not support ethtool to change the EEPROM, the alternative (workaround) is to note that the unit has migrated and apply the previous NOS' mac to eth0 (using ip link set) everytime the unit reboots...

@padmanarayana
Copy link
Contributor Author

  1. Takes care of review comments in rc.local & fix a script error (missing fi)
  2. Revert the static change back to dhcp in build_debian.sh : and introduce a initramfs-tools/mgmt-intf-dhcp that will change the setting in /etc/network/interfaces iff the linux boot line has mgmt.-intf-dhcp=off
  3. Update sonic-platform-modules-dell

Copy link
Contributor Author

@padmanarayana padmanarayana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review !

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you use mgmt-intf-dhcp?

Also I suggest to use
https://www.shellcheck.net/ sometime this utility shows hidden issues

@@ -0,0 +1,36 @@
#!/bin/sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use /bin/bash here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the shellcheck! I want to use sh as is the convention with other initramfs scripts..

fi

if [ -e "${rootmnt}/etc/network/interfaces" ]; then
if [ "$val" == "off" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== is undefined in /bin/sh
Better use =

if [ -e "${rootmnt}/etc/network/interfaces" ]; then
if [ "$val" == "off" ]; then
sed -i 's/iface eth0 inet dhcp/iface eth0 inet static/g' ${rootmnt}/etc/network/interfaces
elif [ "$val" == "on" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

==
The same as previous

Copy link
Contributor Author

@padmanarayana padmanarayana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review changes!

elif [ -n "$migration" ] && [ -f /host/migration/minigraph.xml ]; then
# Use the minigraph that was imported from the NOS
mv /host/migration/minigraph.xml /etc/sonic/
sonic-cfggen -m -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-H -m -j

# Update the 70-persistent-net.rules with the new mac for eth0
log_migration "/etc/udev/rules.d/70-persistent-net.rules : replacing $old_mac with $new_mac for eth0"
sed -i "/eth0/ s/ATTR{address}==\"$old_mac\"/ATTR{address}==\"$new_mac\"/g" /etc/udev/rules.d/70-persistent-net.rules
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sonic, we are using the same mac for management interface and vlan interface. are you using the same mac for you management interface and vlan interface? The goal here is to make sure your vlan interface has the same mac as our vlan interface.

Copy link
Collaborator

@lguohan lguohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as comments

Copy link
Collaborator

@lguohan lguohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as comments

@lguohan lguohan merged commit 02b62ac into sonic-net:master Mar 9, 2018
abdosi added a commit that referenced this pull request Sep 3, 2020
[portsorch] add buffer drop FC group 
[bitmap_vnet] Fix VNET route priority issue (#1421)
[vnet] Maintain the reference count of the nexthop when creating a
vn… (#1414)
[intfsorch] Retrieve Port object before setting NAT zone on router
interfaces. (#1372)
raphaelt-nvidia pushed a commit to raphaelt-nvidia/sonic-buildimage that referenced this pull request Jan 14, 2021
sonic-net#1414)

* [vnet] Maintain the reference count of the nexthop when creating a vnet route
lguohan pushed a commit that referenced this pull request Jun 17, 2021
19615e3 Fixing db_migrator for Feature table (#1674)
d1c1c61 [tests]: skip some dynamic port breakout unit tests (#1677)
25669c3 [CI] sonic-config-engine now depends on SONiC YANG packages (#1675)
3ff68c4 [neighbor-advertiser] delete the tunnel maps appropriately (#1663)
a425ca2 [config] support for configuring muxcable to manual mode of operation  (#1642)
25e17de [show platform summary] Add chassis hardware info to platform summary and version (#1624)
f5f2a00 [db_migrator] fix old 1911 feature config migration to a new one. (#1635)
56db162 [config] Fix config int add incorrect ip (#1414)
1da879c [db_migrator][Mellanox] Update Mellanox buffer migrator with 2km-cable supported (#1564)
c2b760f [sonic_package_manager] flush once finished saving docker image into temporary file (#1638)
cd69473 Replace swsssdk.ConfigDBConnector and SonicDBConfig with swsscommon implementation (#1620)
5f20365 Change to use rvtysh when calling the show commands (#1572)
51d6bf5 Fix Aboot breakage in sonic package manager in sonic-installer (#1625)
18bed46 [console][show] Force refresh all lines status during show line (#1641)
b616cd9 [TPID CONFIG] Added TPID configuration CLI support (#1618)
01eb4b1 [show] support for show muxcable firmware version of only active banks (#1629)
7744c8d [fdb]cli: fdb entries are cleared according to vlan or port or vlan&&port (#657)
e23c5ee Add psu hardware revision to psushow table (#1601)
f1726fe Make advance_version_for_expected_database available for other db migrator test cases as well (#1614)
5d1ad05 [show] add support for muxcable metrics (#1615)
feeab29 [config] Sort Config Db When Saving (#1623)
liat-grozovik pushed a commit that referenced this pull request Jun 26, 2021
Update submodule for sonic-utilities to include the following PRs:

Make the soft-reboot available in the SONiC image on master (#1681)
[config]: Update environment file during config reload (#1673)
Enable pr checker form 202012 (#1649)
[config] support for configuring muxcable to manual mode of operation (#1642)
[config] Fix config int add incorrect ip (#1414)

Signed-off-by: Dror Prital <[email protected]>
carl-nokia pushed a commit to carl-nokia/sonic-buildimage that referenced this pull request Aug 7, 2021
19615e3 Fixing db_migrator for Feature table (sonic-net#1674)
d1c1c61 [tests]: skip some dynamic port breakout unit tests (sonic-net#1677)
25669c3 [CI] sonic-config-engine now depends on SONiC YANG packages (sonic-net#1675)
3ff68c4 [neighbor-advertiser] delete the tunnel maps appropriately (sonic-net#1663)
a425ca2 [config] support for configuring muxcable to manual mode of operation  (sonic-net#1642)
25e17de [show platform summary] Add chassis hardware info to platform summary and version (sonic-net#1624)
f5f2a00 [db_migrator] fix old 1911 feature config migration to a new one. (sonic-net#1635)
56db162 [config] Fix config int add incorrect ip (sonic-net#1414)
1da879c [db_migrator][Mellanox] Update Mellanox buffer migrator with 2km-cable supported (sonic-net#1564)
c2b760f [sonic_package_manager] flush once finished saving docker image into temporary file (sonic-net#1638)
cd69473 Replace swsssdk.ConfigDBConnector and SonicDBConfig with swsscommon implementation (sonic-net#1620)
5f20365 Change to use rvtysh when calling the show commands (sonic-net#1572)
51d6bf5 Fix Aboot breakage in sonic package manager in sonic-installer (sonic-net#1625)
18bed46 [console][show] Force refresh all lines status during show line (sonic-net#1641)
b616cd9 [TPID CONFIG] Added TPID configuration CLI support (sonic-net#1618)
01eb4b1 [show] support for show muxcable firmware version of only active banks (sonic-net#1629)
7744c8d [fdb]cli: fdb entries are cleared according to vlan or port or vlan&&port (sonic-net#657)
e23c5ee Add psu hardware revision to psushow table (sonic-net#1601)
f1726fe Make advance_version_for_expected_database available for other db migrator test cases as well (sonic-net#1614)
5d1ad05 [show] add support for muxcable metrics (sonic-net#1615)
feeab29 [config] Sort Config Db When Saving (sonic-net#1623)
theasianpianist pushed a commit to theasianpianist/sonic-buildimage that referenced this pull request Feb 5, 2022
sonic-net#1414)

* [vnet] Maintain the reference count of the nexthop when creating a vnet route
taras-keryk pushed a commit to taras-keryk/sonic-buildimage that referenced this pull request Apr 28, 2022
* Added ip and mask check to config int
Signed-off-by: d-dashkov <[email protected]>
taras-keryk pushed a commit to taras-keryk/sonic-buildimage that referenced this pull request Jul 22, 2022
Update SAI submodule v1.9 with the following fixes

7594e53 (HEAD, origin/v1.9) Skip brcm teardown assertion (sonic-net#1423) (sonic-net#1428)
0c33f4a [FIX]Fix the circular reference issue when build sai header py (sonic-net#1427)
7e0fc24 Add support for building under Doxygen 1.9.1 (sonic-net#1414) (sonic-net#1424)
8ecf3ef [Fix]Correct enum check on branch 1.9 (sonic-net#1418)
e2b2f39 Add Thrift 0.14.1 compatibility (sonic-net#1403) (sonic-net#1416)
mssonicbld added a commit that referenced this pull request Aug 15, 2024
…tically (#19911)

#### Why I did it
src/sonic-sairedis
```
* 45ff42c3 - (HEAD -> master, origin/master, origin/HEAD) run VS tests in parallel (#1414) (3 hours ago) [Lawrence Lee]
```
#### How I did it
#### How to verify it
#### Description for the changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants