Przeglądaj źródła

libnet/d/ipvlan: gracefully migrate from older dbs

IPVLAN networks created on Moby v20.10 do not have the IpvlanFlag
configuration value persisted in the libnetwork database as that config
value did not exist before v23.0.0. Gracefully migrate configurations on
unmarshal to prevent type-assertion panics at daemon start after upgrade.

Fixes #44925

Signed-off-by: Cory Snider <csnider@mirantis.com>
(cherry picked from commit 91725ddc920cc5b4f35e9728631777ed3e589c1c)
Signed-off-by: Cory Snider <csnider@mirantis.com>
Cory Snider 2 lat temu
rodzic
commit
427101f656
1 zmienionych plików z 6 dodań i 1 usunięć
  1. 6 1
      libnetwork/drivers/ipvlan/ipvlan_store.go

+ 6 - 1
libnetwork/drivers/ipvlan/ipvlan_store.go

@@ -193,7 +193,12 @@ func (config *configuration) UnmarshalJSON(b []byte) error {
 	config.Mtu = int(nMap["Mtu"].(float64))
 	config.Mtu = int(nMap["Mtu"].(float64))
 	config.Parent = nMap["Parent"].(string)
 	config.Parent = nMap["Parent"].(string)
 	config.IpvlanMode = nMap["IpvlanMode"].(string)
 	config.IpvlanMode = nMap["IpvlanMode"].(string)
-	config.IpvlanFlag = nMap["IpvlanFlag"].(string)
+	if v, ok := nMap["IpvlanFlag"]; ok {
+		config.IpvlanFlag = v.(string)
+	} else {
+		// Migrate config from an older daemon which did not have the flag configurable.
+		config.IpvlanFlag = flagBridge
+	}
 	config.Internal = nMap["Internal"].(bool)
 	config.Internal = nMap["Internal"].(bool)
 	config.CreatedSlaveLink = nMap["CreatedSubIface"].(bool)
 	config.CreatedSlaveLink = nMap["CreatedSubIface"].(bool)
 	if v, ok := nMap["Ipv4Subnets"]; ok {
 	if v, ok := nMap["Ipv4Subnets"]; ok {