Skip to content

Commit 4d8d180

Browse files
controlplane/controller: fix flex-algo node-segment not removed on rollback
When flex-algo is disabled after being enabled, the controller was not emitting 'no node-segment ipv4 index X flex-algo TOPOLOGY' cleanup lines on Loopback255. Root cause: FlexAlgoNodeSegments was only populated when flex-algo was enabled, so the template had nothing to iterate over during rollback. Fix: populate FlexAlgoNodeSegments whenever a features config is loaded (not just when enabled), so the template can emit cleanup lines even when flex-algo is being disabled.
1 parent 9ed036d commit 4d8d180

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

controlplane/controller/internal/controller/fixtures/base.config.flex-algo-disabled.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ interface Ethernet1/1
7979
no traffic-engineering administrative-group
8080
no traffic-engineering
8181
!
82+
interface Loopback255
83+
ip address 14.14.14.14/32
84+
node-segment ipv4 index 100
85+
no node-segment ipv4 index 200 flex-algo unicast-default
86+
isis enable 1
87+
!
8288
interface Loopback1000
8389
description RP Address
8490
ip address 10.0.0.0/32

controlplane/controller/internal/controller/render_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,16 @@ func TestRenderConfig(t *testing.T) {
907907
LinkStatus: serviceability.LinkStatusActivated,
908908
LinkTopologies: []string{"unicast-default"},
909909
},
910+
{
911+
Name: "Loopback255",
912+
Ip: netip.MustParsePrefix("14.14.14.14/32"),
913+
NodeSegmentIdx: 100,
914+
InterfaceType: InterfaceTypeLoopback,
915+
LoopbackType: LoopbackTypeVpnv4,
916+
FlexAlgoNodeSegments: []FlexAlgoNodeSegmentModel{
917+
{NodeSegmentIdx: 200, TopologyName: "unicast-default"},
918+
},
919+
},
910920
},
911921
Tunnels: []*Tunnel{
912922
{

controlplane/controller/internal/controller/server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,10 @@ func (c *Controller) updateStateCache(ctx context.Context) error {
426426
linkMetrics.WithLabelValues(device.Code, iface.Name, d.PubKey).Set(float64(d.Interfaces[i].Metric))
427427
}
428428

429-
// Populate flex-algo node-segment data for VPNv4 loopback interfaces
430-
if c.featuresConfig != nil && c.featuresConfig.Features.FlexAlgo.Enabled {
429+
// Populate flex-algo node-segment data for VPNv4 loopback interfaces.
430+
// Populated whenever a features config is loaded (not just when enabled) so that
431+
// the template can emit cleanup ("no node-segment") lines on rollback.
432+
if c.featuresConfig != nil {
431433
for i, intf := range d.Interfaces {
432434
if !intf.IsVpnv4Loopback() {
433435
continue

0 commit comments

Comments
 (0)