Skip to content

Commit

Permalink
Fix regression in config-migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Jan 19, 2022
1 parent 90b07e3 commit 862af2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ local function multiprocess_migration(src, conf_file)

-- We should build up a hybrid schema from parts of v1 and v2.
local v1_schema = yang.load_schema_by_name("snabb-softwire-v1")
local hybridscm = yang.load_schema_by_name("snabb-softwire-v3")
local hybridscm = yang.load_schema_by_name("snabb-softwire-v2")
local v1_external = v1_schema.body["softwire-config"].body["external-interface"]
local v1_internal = v1_schema.body["softwire-config"].body["internal-interface"]
local external = hybridscm.body["softwire-config"].body["external-interface"]
Expand Down Expand Up @@ -521,15 +521,15 @@ local function multiprocess_migration(src, conf_file)
conf.softwire_config.external_interface.next_hop = nil
conf.softwire_config.external_interface.vlan_tag = nil

return config_to_string('snabb-softwire-v3', conf)
return config_to_string('snabb-softwire-v2', conf)
end

local function v2_migration(src, conf_file)
-- Lets create a custom schema programmatically as an intermediary so we can
-- switch over to v2 of snabb-softwire config.
local v1_schema = yang.load_schema_by_name("snabb-softwire-v1")
local v1_binding_table = v1_schema.body["softwire-config"].body["binding-table"]
local hybridscm = yang.load_schema_by_name("snabb-softwire-v3")
local hybridscm = yang.load_schema_by_name("snabb-softwire-v2")
local binding_table = hybridscm.body["softwire-config"].body["binding-table"]

-- Add the schema from v1 that we need to convert them.
Expand All @@ -547,6 +547,9 @@ local function v2_migration(src, conf_file)
-- Remove the mandatory requirement on softwire.br-address for the migration
binding_table.body["softwire"].body["br-address"].mandatory = false

-- Remove the mandatory requirement on softwire.port-set.psid-length for the migration
binding_table.body["softwire"].body["port-set"].body["psid-length"].mandatory = false

local conf = yang.load_config_for_schema(
hybridscm, mem.open_input_string(src, conf_file))

Expand Down Expand Up @@ -596,7 +599,7 @@ local migrations = {
{version='3.0.1', migrator=migrate_3_0_1},
{version='3.0.1.1', migrator=migrate_3_0_1bis},
{version='3.2.0', migrator=migrate_3_2_0},
{version='2017.07.01',migrator=migrate_2017_07_01}
{version='2017.07.01',migrator=migrate_2017_07_01},
}


Expand Down
4 changes: 2 additions & 2 deletions src/program/lwaftr/tests/config-migrations/selftest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

# Attempt to migration from legacy to latest
LEGACY_OUT=`./snabb lwaftr migrate-configuration -f legacy \
Expand All @@ -19,4 +19,4 @@ if [[ "$?" -ne "0" ]]; then
echo "3.2.0 configuration migration failed (status code != 0)"
echo "$V320_OUT"
exit 1
fi
fi

0 comments on commit 862af2c

Please sign in to comment.