Skip to content

Commit

Permalink
[#1370] Fixed shared net config update
Browse files Browse the repository at this point in the history
  • Loading branch information
msiodelski committed Jun 4, 2024
1 parent 82ba816 commit ad5c94f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/server/apps/kea/configmodule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,7 @@ func TestCommitSharedNetworkUpdate(t *testing.T) {
// Copy the shared network and modify it. The modifications should be applied in
// the database upon commit.
modifiedSharedNetwork := sharedNetworks[0]
modifiedSharedNetwork.Name = "bar"
modifiedSharedNetwork.CreatedAt = time.Time{}
modifiedSharedNetwork.LocalSharedNetworks = sharedNetworks[0].LocalSharedNetworks[0:1]
modifiedSharedNetwork.LocalSharedNetworks[0].KeaParameters.Allocator = storkutil.Ptr("random")
Expand Down Expand Up @@ -2051,7 +2052,7 @@ func TestCommitSharedNetworkUpdate(t *testing.T) {
"shared-networks": [
{
"allocator": "random",
"name": "foo"
"name": "bar"
}
]
}
Expand All @@ -2071,6 +2072,7 @@ func TestCommitSharedNetworkUpdate(t *testing.T) {
updatedSharedNetwork, err := dbmodel.GetSharedNetwork(db, sharedNetworks[0].ID)
require.NoError(t, err)
require.NotNil(t, updatedSharedNetwork)
require.Equal(t, "bar", updatedSharedNetwork.Name)
require.Len(t, updatedSharedNetwork.LocalSharedNetworks, 1)
require.NotNil(t, updatedSharedNetwork.LocalSharedNetworks[0].KeaParameters)
require.NotNil(t, updatedSharedNetwork.LocalSharedNetworks[0].KeaParameters.Allocator)
Expand Down
7 changes: 7 additions & 0 deletions backend/server/database/model/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,13 @@ func commitNetworksIntoDB(tx *pg.Tx, networks []SharedNetwork, subnets []Subnet)
network.Name)
return nil, err
}
} else {
err = UpdateSharedNetwork(tx, network)
if err != nil {
err = pkgerrors.WithMessagef(err, "unable to update shared network %s in the database",
network.Name)
return nil, err
}
}
if err = AddLocalSharedNetworks(tx, network); err != nil {
return nil, err
Expand Down

0 comments on commit ad5c94f

Please sign in to comment.