Skip to content

Commit 059db68

Browse files
Add session shutdown logic to controller when drained
Resolves: #2485
1 parent 359cc72 commit 059db68

File tree

8 files changed

+663
-5
lines changed

8 files changed

+663
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ All notable changes to this project will be documented in this file.
3434
- Add histogram metric for GetConfig request duration
3535
- Add gRPC middleware for prometheus metrics
3636
- Add device status label to controller_grpc_getconfig_requests_total metric
37+
- Add logic to shutdown user BGP, IBGP sessions, MSDP neighbors, and ISIS when device.status is drained
3738
- Device agents
3839
- Increase default controller request timeout in config agent
3940
- Initial state collect in telemetry agent
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
!
2+
hardware counter feature gre tunnel interface out
3+
hardware counter feature gre tunnel interface in
4+
!
5+
hardware access-list update default-result permit
6+
!
7+
logging buffered 128000
8+
no logging console
9+
logging facility local7
10+
!
11+
ip name-server vrf default 1.1.1.1
12+
ip name-server vrf default 9.9.9.9
13+
clock timezone UTC
14+
!
15+
ip multicast-routing
16+
!
17+
router pim sparse-mode
18+
ipv4
19+
rp address 10.0.0.0 239.0.0.0/24 override
20+
!
21+
vrf instance vrf1
22+
ip routing
23+
ip routing vrf vrf1
24+
!
25+
ntp server 0.pool.ntp.org
26+
ntp server 1.pool.ntp.org
27+
ntp server 2.pool.ntp.org
28+
!
29+
hardware access-list update default-result permit
30+
!
31+
no ip access-list MAIN-CONTROL-PLANE-ACL
32+
ip access-list MAIN-CONTROL-PLANE-ACL
33+
counters per-entry
34+
10 permit icmp any any
35+
20 permit ip any any tracked
36+
30 permit udp any any eq bfd ttl eq 255
37+
40 permit udp any any eq bfd-echo ttl eq 254
38+
50 permit udp any any eq multihop-bfd micro-bfd sbfd
39+
60 permit udp any eq sbfd any eq sbfd-initiator
40+
70 permit ospf any any
41+
80 permit tcp any any eq ssh telnet www snmp bgp https msdp ldp netconf-ssh gnmi
42+
90 permit udp any any eq bootps bootpc snmp rip ntp ldp ptp-event ptp-general
43+
100 permit tcp any any eq mlag ttl eq 255
44+
110 permit udp any any eq mlag ttl eq 255
45+
120 permit vrrp any any
46+
130 permit ahp any any
47+
140 permit pim any any
48+
150 permit igmp any any
49+
160 permit tcp any any range 5900 5910
50+
170 permit tcp any any range 50000 50100
51+
180 permit udp any any range 51000 51100
52+
190 permit tcp any any eq 3333
53+
200 permit tcp any any eq nat ttl eq 255
54+
210 permit tcp any eq bgp any
55+
220 permit rsvp any any
56+
230 permit tcp any any eq 9340
57+
240 permit tcp any any eq 9559
58+
250 permit udp any any eq 8503
59+
260 permit udp any any eq lsp-ping
60+
270 permit udp any eq lsp-ping any
61+
280 remark Permit TWAMP (UDP 862)
62+
290 permit udp any any eq 862
63+
!
64+
system control-plane
65+
ip access-group MAIN-CONTROL-PLANE-ACL in
66+
!
67+
interface Loopback255
68+
ip address 14.14.14.14/32
69+
node-segment ipv4 index 15
70+
isis enable 1
71+
!
72+
interface Ethernet1/1
73+
mtu 2048
74+
no switchport
75+
ip address 172.16.0.2/31
76+
pim ipv4 sparse-mode
77+
isis enable 1
78+
isis circuit-type level-2
79+
isis hello-interval 1
80+
isis metric 40000
81+
no isis passive
82+
isis hello padding
83+
isis network point-to-point
84+
!
85+
interface Ethernet1/2
86+
mtu 2048
87+
no switchport
88+
ip address 172.16.0.4/31
89+
pim ipv4 sparse-mode
90+
!
91+
interface Loopback1000
92+
description RP Address
93+
ip address 10.0.0.0/32
94+
!
95+
mpls ip
96+
!
97+
mpls icmp ttl-exceeded tunneling
98+
mpls icmp ip source-interface Loopback255
99+
!
100+
router bgp 65342
101+
router-id 14.14.14.14
102+
timers bgp 1 3
103+
distance bgp 20 200 200
104+
no neighbor 12.12.12.12
105+
neighbor 12.12.12.12 remote-as 65342
106+
neighbor 12.12.12.12 next-hop-self
107+
neighbor 12.12.12.12 update-source Loopback256
108+
neighbor 12.12.12.12 description remote-dzd-ipv4
109+
neighbor 12.12.12.12 timers 3 9
110+
neighbor 12.12.12.12 send-community
111+
neighbor 12.12.12.12 shutdown
112+
no neighbor 15.15.15.15
113+
neighbor 15.15.15.15 remote-as 65342
114+
neighbor 15.15.15.15 next-hop-self
115+
neighbor 15.15.15.15 update-source Loopback255
116+
neighbor 15.15.15.15 description remote-dzd-vpnv4
117+
neighbor 15.15.15.15 timers 3 9
118+
neighbor 15.15.15.15 send-community
119+
neighbor 15.15.15.15 shutdown
120+
address-family ipv4
121+
neighbor 12.12.12.12 activate
122+
no neighbor 15.15.15.15 activate
123+
!
124+
address-family vpn-ipv4
125+
neighbor 15.15.15.15 activate
126+
!
127+
vrf vrf1
128+
rd 65342:1
129+
route-target import vpn-ipv4 65342:1
130+
route-target export vpn-ipv4 65342:1
131+
router-id 7.7.7.7
132+
!
133+
router isis 1
134+
net 49.0000.0e0e.0e0e.0000.00
135+
router-id ipv4 14.14.14.14
136+
log-adjacency-changes
137+
!
138+
address-family ipv4 unicast
139+
!
140+
segment-routing mpls
141+
no shutdown
142+
set-overload-bit
143+
!
144+
ip community-list COMM-ALL_USERS permit 21682:1200
145+
ip community-list COMM-ALL_MCAST_USERS permit 21682:1300
146+
ip community-list COMM-TST_USERS permit 21682:10050
147+
!
148+
no ip access-list SEC-USER-PUB-MCAST-IN
149+
ip access-list SEC-USER-PUB-MCAST-IN
150+
counters per-entry
151+
permit icmp any any
152+
permit tcp any any eq bgp
153+
permit ip any 224.0.0.13/32
154+
permit ip any 239.0.0.0/24
155+
deny ip any any
156+
!
157+
no ip access-list SEC-USER-SUB-MCAST-IN
158+
ip access-list SEC-USER-SUB-MCAST-IN
159+
counters per-entry
160+
permit icmp any any
161+
permit tcp any any eq bgp
162+
permit ip any 224.0.0.13/32
163+
deny ip any any
164+
!
165+
no router msdp
166+
router msdp
167+
peer 12.12.12.12
168+
mesh-group DZ-1
169+
local-interface Loopback256
170+
description remote-dzd
171+
shutdown

controlplane/controller/internal/controller/render_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,61 @@ func TestRenderConfig(t *testing.T) {
548548
},
549549
Want: "fixtures/base.config.txt",
550550
},
551+
{
552+
Name: "render_drained_device_config_successfully",
553+
Description: "render config for a drained device with BGP, MSDP, and ISIS shutdown",
554+
Data: templateData{
555+
Strings: StringsHelper{},
556+
MulticastGroupBlock: "239.0.0.0/24",
557+
TelemetryTWAMPListenPort: 862,
558+
LocalASN: 65342,
559+
Device: &Device{
560+
PublicIP: net.IP{7, 7, 7, 7},
561+
Vpn4vLoopbackIP: net.IP{14, 14, 14, 14},
562+
IsisNet: "49.0000.0e0e.0e0e.0000.00",
563+
Ipv4LoopbackIP: net.IP{13, 13, 13, 13},
564+
ExchangeCode: "tst",
565+
BgpCommunity: 10050,
566+
Status: serviceability.DeviceStatusHardDrained,
567+
Interfaces: []Interface{
568+
{
569+
Name: "Loopback255",
570+
InterfaceType: InterfaceTypeLoopback,
571+
LoopbackType: LoopbackTypeVpnv4,
572+
Ip: netip.MustParsePrefix("14.14.14.14/32"),
573+
NodeSegmentIdx: 15,
574+
},
575+
{
576+
Name: "Ethernet1/1",
577+
InterfaceType: InterfaceTypePhysical,
578+
Ip: netip.MustParsePrefix("172.16.0.2/31"),
579+
Metric: 40000,
580+
IsLink: true,
581+
},
582+
{
583+
Name: "Ethernet1/2",
584+
InterfaceType: InterfaceTypePhysical,
585+
Ip: netip.MustParsePrefix("172.16.0.4/31"),
586+
},
587+
},
588+
Vpn4vLoopbackIntfName: "Loopback255",
589+
Ipv4LoopbackIntfName: "Loopback256",
590+
},
591+
Vpnv4BgpPeers: []BgpPeer{
592+
{
593+
PeerIP: net.IP{15, 15, 15, 15},
594+
PeerName: "remote-dzd",
595+
},
596+
},
597+
Ipv4BgpPeers: []BgpPeer{
598+
{
599+
PeerIP: net.IP{12, 12, 12, 12},
600+
PeerName: "remote-dzd",
601+
},
602+
},
603+
},
604+
Want: "fixtures/base.config.drained.txt",
605+
},
551606
}
552607

553608
for _, test := range tests {

controlplane/controller/internal/controller/templates/tunnel.tmpl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ router bgp 65342
181181
neighbor {{ .PeerIP }} description {{ .PeerName }}-ipv4
182182
neighbor {{ .PeerIP }} timers 3 9
183183
neighbor {{ .PeerIP }} send-community
184+
{{- if eq $.Device.Status.String "hard-drained" }}
185+
neighbor {{ .PeerIP }} shutdown
186+
{{- end }}
184187
{{- end }}
185188
{{- end }}
186189
{{- range .Vpnv4BgpPeers }}
@@ -192,6 +195,9 @@ router bgp 65342
192195
neighbor {{ .PeerIP }} description {{ .PeerName }}-vpnv4
193196
neighbor {{ .PeerIP }} timers 3 9
194197
neighbor {{ .PeerIP }} send-community
198+
{{- if eq $.Device.Status.String "hard-drained" }}
199+
neighbor {{ .PeerIP }} shutdown
200+
{{- end }}
195201
{{- end }}
196202
{{- end }}
197203
{{- range .Device.Tunnels }}
@@ -205,6 +211,9 @@ router bgp 65342
205211
neighbor {{ .OverlayDstIP }} route-map RM-USER-{{ .Id }}-OUT out
206212
neighbor {{ .OverlayDstIP }} maximum-routes 1
207213
neighbor {{ .OverlayDstIP }} maximum-accepted-routes 1
214+
{{- if eq $.Device.Status.String "hard-drained" }}
215+
neighbor {{ .OverlayDstIP }} shutdown
216+
{{- end }}
208217
{{- end }}
209218
{{- end }}
210219
address-family ipv4
@@ -254,6 +263,9 @@ router bgp 65342
254263
neighbor {{ .OverlayDstIP }} route-map RM-USER-{{ .Id }}-OUT out
255264
neighbor {{ .OverlayDstIP }} maximum-routes 1
256265
neighbor {{ .OverlayDstIP }} maximum-accepted-routes 1
266+
{{- if eq $.Device.Status.String "hard-drained" }}
267+
neighbor {{ .OverlayDstIP }} shutdown
268+
{{- end }}
257269
{{- end }}
258270
{{- end }}
259271
{{- end }}
@@ -270,7 +282,8 @@ router isis 1
270282
!
271283
segment-routing mpls
272284
no shutdown
273-
!
285+
{{ if eq $.Device.Status.String "hard-drained" }} set-overload-bit
286+
{{ end }}!
274287
ip community-list COMM-ALL_USERS permit 21682:1200
275288
ip community-list COMM-ALL_MCAST_USERS permit 21682:1300
276289
ip community-list COMM-{{ .Strings.ToUpper .Device.ExchangeCode }}_USERS permit 21682:{{ .Device.BgpCommunity }}
@@ -363,6 +376,9 @@ router msdp
363376
mesh-group DZ-1
364377
local-interface {{ $.Device.Ipv4LoopbackIntfName }}
365378
description {{ .PeerName }}
379+
{{- if eq $.Device.Status.String "hard-drained" }}
380+
shutdown
381+
{{- end }}
366382
{{- end }}
367383
{{- end }}
368384
{{- end }}

0 commit comments

Comments
 (0)