Skip to content

Commit

Permalink
Merge pull request sonic-net#37 from mssonicbld/sonicbld/202205-merge
Browse files Browse the repository at this point in the history
[code sync] Merge code from sonic-net/sonic-buildimage:202205 to 202205
  • Loading branch information
mssonicbld authored Jun 17, 2023
2 parents 95cee7f + 748416d commit 60218a8
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 31 deletions.
16 changes: 4 additions & 12 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,10 @@ function postStartAction()
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
fi

if [ -e /tmp/pending_config_migration ]; then
# this is first boot to a new image, config-setup execution is pending.
# For fast/cold reboot case, DB contains nothing at this point
# Call db_migrator after config-setup loads the config (from old config or minigraph)
echo "Delaying db_migrator until config migration is over"
else
# this is not a first time boot to a new image. Datbase container starts w/ old pre-existing config
if [[ -x /usr/local/bin/db_migrator.py ]]; then
# Migrate the DB to the latest schema version if needed
if [ -z "$DEV" ]; then
/usr/local/bin/db_migrator.py -o migrate
fi
if [[ -x /usr/local/bin/db_migrator.py ]]; then
# Migrate the DB to the latest schema version if needed
if [ -z "$DEV" ]; then
/usr/local/bin/db_migrator.py -o migrate
fi
fi
# Add redis UDS to the redis group and give read/write access to the group
Expand Down
13 changes: 0 additions & 13 deletions files/image_config/config-setup/config-setup
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,6 @@ check_all_config_db_present()
return 0
}

# DB schema is subject to change between two images
# Perform DB schema migration after loading backup config from previous image
do_db_migration()
{
if [[ -x /usr/local/bin/db_migrator.py ]]; then
# Migrate the DB to the latest schema version if needed
/usr/local/bin/db_migrator.py -o migrate
fi
}

# Perform configuration migration from backup copy.
# - This step is performed when a new image is installed and SONiC switch boots into it
do_config_migration()
Expand All @@ -336,19 +326,16 @@ do_config_migration()
if [ x"${WARM_BOOT}" == x"true" ]; then
echo "Warm reboot detected..."
disable_updategraph
do_db_migration
rm -f /tmp/pending_config_migration
exit 0
elif check_all_config_db_present; then
echo "Use config_db.json from old system..."
reload_configdb
do_db_migration
# Disable updategraph
disable_updategraph
elif [ -r ${MINGRAPH_FILE} ]; then
echo "Use minigraph.xml from old system..."
reload_minigraph
do_db_migration
# Disable updategraph
disable_updategraph
else
Expand Down
2 changes: 1 addition & 1 deletion files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ start() {
$SONIC_DB_CLI GB_ASIC_DB FLUSHDB
$SONIC_DB_CLI GB_COUNTERS_DB FLUSHDB
$SONIC_DB_CLI RESTAPI_DB FLUSHDB
clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*', 'FG_ROUTE_TABLE*', 'BUFFER_POOL*', 'BUFFER_PROFILE*', 'MUX_CABLE_TABLE*', 'ADVERTISE_NETWORK_TABLE*', 'VXLAN_TUNNEL_TABLE*', 'MACSEC_PORT_TABLE*', 'MACSEC_INGRESS_SA_TABLE*', 'MACSEC_EGRESS_SA_TABLE*', 'MACSEC_INGRESS_SC_TABLE*', 'MACSEC_EGRESS_SC_TABLE*'"
clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*', 'FG_ROUTE_TABLE*', 'BUFFER_POOL*', 'BUFFER_PROFILE*', 'MUX_CABLE_TABLE*', 'ADVERTISE_NETWORK_TABLE*', 'VXLAN_TUNNEL_TABLE*', 'MACSEC_PORT_TABLE*', 'MACSEC_INGRESS_SA_TABLE*', 'MACSEC_EGRESS_SA_TABLE*', 'MACSEC_INGRESS_SC_TABLE*', 'MACSEC_EGRESS_SC_TABLE*', 'VNET_ROUTE*', 'VNET_MONITOR_TABLE*', 'BFD_SESSION_TABLE*'"
$SONIC_DB_CLI APPL_STATE_DB FLUSHDB
rm -rf /tmp/cache
fi
Expand Down
25 changes: 24 additions & 1 deletion src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,28 @@ def parse_spine_chassis_fe(results, vni, lo_intfs, phyport_intfs, pc_intfs, pc_m
# Enslave the port channel interface to a Vnet
pc_intfs[pc_intf] = {'vnet_name': chassis_vnet}

def parse_default_vxlan_decap(results, vni, lo_intfs):
vnet ='Vnet-default'
vxlan_tunnel = 'tunnel_v4'

# Vxlan tunnel information
lo_addr = '0.0.0.0'
for lo in lo_intfs:
lo_network = ipaddress.ip_network(UNICODE_TYPE(lo[1]), False)
if lo_network.version == 4:
lo_addr = str(lo_network.network_address)
break
results['VXLAN_TUNNEL'] = {vxlan_tunnel: {
'src_ip': lo_addr
}}

# Vnet information
results['VNET'] = {vnet: {
'vxlan_tunnel': vxlan_tunnel,
'scope': "default",
'vni': vni
}}

###############################################################################
#
# Post-processing functions
Expand Down Expand Up @@ -1605,9 +1627,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
for key in voq_inband_intfs:
results['VOQ_INBAND_INTERFACE'][key] = voq_inband_intfs[key]


if resource_type is not None:
results['DEVICE_METADATA']['localhost']['resource_type'] = resource_type
if 'Appliance' in resource_type:
parse_default_vxlan_decap(results, vni_default, lo_intfs)

if downstream_subrole is not None:
results['DEVICE_METADATA']['localhost']['downstream_subrole'] = downstream_subrole
Expand Down
5 changes: 5 additions & 0 deletions src/sonic-config-engine/tests/t0-sample-deployment-id.xml
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,11 @@
<a:Reference i:nil="true"/>
<a:Value>2.2.2.2</a:Value>
</a:DeviceProperty>
<a:DeviceProperty>
<a:Name>ResourceType</a:Name>
<a:Reference i:nil="true"/>
<a:Value>HaAppliance</a:Value>
</a:DeviceProperty>
</a:Properties>
</a:DeviceMetadata>
</Devices>
Expand Down
16 changes: 16 additions & 0 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,22 @@ def test_minigraph_port_rs(self):
utils.to_dict("{'lanes': '101,102,103,104', 'fec': 'rs', 'pfc_asym': 'off', 'mtu': '9100', 'tpid': '0x8100', 'alias': 'fortyGigE0/124', 'admin_status': 'up', 'speed': '100000', 'description': 'ARISTA04T1:Ethernet1/1'}")
)

def test_minigraph_default_vxlan(self):
argument = '-m "' + self.sample_graph_deployment_id + '" -p "' + self.port_config + '" -v "VXLAN_TUNNEL"'
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict("{'tunnel_v4': {'src_ip': '10.1.0.32'}}")
)

def test_minigraph_default_vnet(self):
argument = '-m "' + self.sample_graph_deployment_id + '" -p "' + self.port_config + '" -v "VNET"'
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict("{'Vnet-default': {'vxlan_tunnel': 'tunnel_v4', 'scope': 'default', 'vni': 8000}}")
)

def test_minigraph_bgp(self):
argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v "BGP_NEIGHBOR[\'10.0.0.59\']"'
output = self.run_script(argument)
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-swss

0 comments on commit 60218a8

Please sign in to comment.