Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios_bgp: fixes #57666 #57667

Open
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
4 participants
@hexdump0x0200
Copy link
Contributor

commented Jun 11, 2019

SUMMARY

fixes #57666

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ios_bgp

@ansibot

This comment has been minimized.

@ansible-zuul

This comment has been minimized.

Copy link

commented Jun 11, 2019

Build succeeded (third-party-check pipeline).

@pabelanger
Copy link
Contributor

left a comment

Thanks, we should update our network integration tests to deal with this use case. You likely can just use the example from #57666

@hexdump0x0200 hexdump0x0200 force-pushed the hexdump0x0200:ios_bgp_fix branch from b869ff6 to 32e6296 Jun 11, 2019

@hexdump0x0200
Copy link
Contributor Author

left a comment

I have not fully identified the problem. I thought that the problem was caused by the fact that my device without a configured BGP returns the string "\n" instead of an empty string, which is interpreted in the code as "True". But the error occurred not only because the BGP configuration is missing, but because there was an ACL with the substring "bgp" in my configuration and the operation "section bgp" did not return the BGP configuration, but my ACL. I fixed the regular expression, now it can only match on the BGP configuration. The integration tests themselves already take into account that the BGP configuration may be absent, because the first operation that the integration test performs is the removal of the BGP configuration.

@ansible-zuul

This comment has been minimized.

Copy link

commented Jun 11, 2019

Build succeeded (third-party-check pipeline).

@ansibot ansibot added needs_revision and removed core_review labels Jun 11, 2019

@pabelanger

This comment has been minimized.

Copy link
Contributor

commented Jun 11, 2019

recheck

@ansibot ansibot added core_review and removed needs_revision labels Jun 11, 2019

@ansible-zuul

This comment has been minimized.

Copy link

commented Jun 11, 2019

Build succeeded (third-party-check pipeline).

@pabelanger

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2019

recheck

@pabelanger

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2019

We are still hunting don the ios_bgp failure, we have a theory that is going on, but want to re tests again here to see if we can trigger it. Hopefully won't be much longer before we properly fix it.

@ansible-zuul

This comment has been minimized.

Copy link

commented Jun 18, 2019

Build succeeded (third-party-check pipeline).

@ansibot ansibot added needs_revision and removed core_review labels Jun 18, 2019

@pabelanger

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2019

recheck

@ansibot ansibot added core_review and removed needs_revision labels Jun 19, 2019

@pabelanger

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2019

@hexdump0x0200 okay, thanks for the tip, I in fact reproduced the issue:

ios-15.6-2T#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
ios-15.6-2T(config)#router bgp 64496
ios-15.6-2T(config-router)#address-family ipv4 multicast
ios-15.6-2T(config-router-af)#no redistribute eigrp 233
ios-15.6-2T(config-router-af)#exit-address-family
ios-15.6-2T(config-router)#no address-family ipv4
ios-15.6-2T(config-router)#exit
ios-15.6-2T(config)#exit
ios-15.6-2T#write
Building configuration...

% Topology global::IPv4 Unicast::base is currently being deconfigured.
% BGP context not been initialized properly.[OK]

So, it looks like you are correct in that when we configure bgp, we need to wait an amount of time to properly save the configuration. Doing more testing.

@pabelanger

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2019

I've raised #58032 for the moment, to give us an option to ignore this failure. Until we come up with a good solution to properly fix. Pausing between tasks won't work, as it is the save operation in ios_bgp that will hit the error above.

@ansible-zuul

This comment has been minimized.

Copy link

commented Jun 19, 2019

Build succeeded (third-party-check pipeline).

@ansibot ansibot added needs_revision and removed core_review labels Jun 19, 2019

@hexdump0x0200

This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

Perhaps we were mistaken with the reason for the failure of the tests.

During tests, the following set of commands is executed:

  1. Configure redistribute information under address family mode with operation replace
jsonrpc request: {"params": [[], {"flags": "| section ^router bgp"}], "jsonrpc": "2.0", "method": "get_config", "id": "bc891f74-a4c5-4c7f-8706-fa8c4a6d8eb1"}

it performs

show running-config | section ^router bgp

answer:

jsonrpc response: {"jsonrpc": "2.0", "id": "bc891f74-a4c5-4c7f-8706-fa8c4a6d8eb1", "result": "router bgp 64496\n bgp router-id 192.0.2.2\n bgp log-neighbor-changes\n neighbor 192.0.2.15 remote-as 64496\n neighbor 192.0.2.15 description IBGP_NBR_2\n neighbor 192.0.2.15 ebgp-multihop 150\n neighbor 203.0.113.10 remote-as 64511\n neighbor 203.0.113.10 local-as 64497\n neighbor 203.0.113.10 description EBGP_NBR_1\n !\n address-family ipv4\n  network 198.51.100.64 mask 255.255.255.240\n  neighbor 192.0.2.15 activate\n  neighbor 192.0.2.15 route-reflector-client\n  neighbor 203.0.113.10 activate\n  neighbor 203.0.113.10 advertisement-interval 120\n  neighbor 203.0.113.10 maximum-prefix 250\n exit-address-family\n !\n address-family ipv4 multicast\n  network 192.0.2.64 mask 255.255.255.224\n  network 198.51.100.80 mask 255.255.255.240\n  network 203.0.113.192 mask 255.255.255.224\n  redistribute ospf 112 metric 64\n  redistribute eigrp 233 metric 256\n exit-address-family"}

for humans:

router bgp 64496
 bgp router-id 192.0.2.2
 bgp log-neighbor-changes
 neighbor 192.0.2.15 remote-as 64496
 neighbor 192.0.2.15 description IBGP_NBR_2
 neighbor 192.0.2.15 ebgp-multihop 150
 neighbor 203.0.113.10 remote-as 64511
 neighbor 203.0.113.10 local-as 64497
 neighbor 203.0.113.10 description EBGP_NBR_1
 !
 address-family ipv4
  network 198.51.100.64 mask 255.255.255.240
  neighbor 192.0.2.15 activate
  neighbor 192.0.2.15 route-reflector-client
  neighbor 203.0.113.10 activate
  neighbor 203.0.113.10 advertisement-interval 120
  neighbor 203.0.113.10 maximum-prefix 250
 exit-address-family
 !
 address-family ipv4 multicast
  network 192.0.2.64 mask 255.255.255.224
  network 198.51.100.80 mask 255.255.255.240
  network 203.0.113.192 mask 255.255.255.224
  redistribute ospf 112 metric 64
  redistribute eigrp 233 metric 256
 exit-address-family

module work:

jsonrpc request: {"params": [[["router bgp 64496", "address-family ipv4 multicast", "no redistribute eigrp 233", "exit-address-family", "no address-family ipv4", "exit"]], {}], "jsonrpc": "2.0", "method": "edit_config", "id": "e0ffb06c-0d38-4be4-bcc5-dc383920549c"}

answer:

jsonrpc response: {"jsonrpc": "2.0", "id": "e0ffb06c-0d38-4be4-bcc5-dc383920549c", "result": {"request": ["router bgp 64496", "address-family ipv4 multicast", "no redistribute eigrp 233", "exit-address-family", "no address-family ipv4", "exit"], "response": ["", "", "", "", "", ""]}}
  1. Configure redistribute information under address family mode with operation replace (idempotent)
jsonrpc request: {"params": [[], {"flags": "| section ^router bgp"}], "jsonrpc": "2.0", "method": "get_config", "id": "da4f410f-935d-4acc-96b7-c891d1ce07de"}

it performs

show running-config | section ^router bgp

answer:

jsonrpc response: {"jsonrpc": "2.0", "id": "da4f410f-935d-4acc-96b7-c891d1ce07de", "result": "router bgp 64496\n bgp router-id 192.0.2.2\n bgp log-neighbor-changes\n !\n address-family ipv4 multicast\n  network 192.0.2.64 mask 255.255.255.224\n  network 198.51.100.80 mask 255.255.255.240\n  network 203.0.113.192 mask 255.255.255.224\n  redistribute ospf 112 metric 64\n exit-address-family"}

for humans:

router bgp 64496
 bgp router-id 192.0.2.2
 bgp log-neighbor-changes
 !
 address-family ipv4 multicast
  network 192.0.2.64 mask 255.255.255.224
  network 198.51.100.80 mask 255.255.255.240
  network 203.0.113.192 mask 255.255.255.224
  redistribute ospf 112 metric 64
 exit-address-family

After that, nothing happens on my equipment, the asserts are successful. In your integration tests, the module considers that there is an "address-family ipv4" in the configuration, and tries to delete it.

Thus, the write command is not invoked, and therefore should not result in an error message. In addition, when I perform actions that result in the message "Topology global :: IPv4 Unicast :: base is currently being deconfigured," the configuration is still displayed and edited correctly.

On my hardware, it'll do something like this:

R-21#sh run | sec bgp
R-21#
R-21#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R-21(config)#router bgp 64496
R-21(config-router)#address-family ipv4 multicast
R-21(config-router-af)#no redistribute eigrp 233
R-21(config-router-af)#exit-address-family
R-21(config-router)#no address-family ipv4
R-21(config-router)#exit
R-21(config)#exit
R-21#show running-config | section ^router bgp
router bgp 64496
 bgp log-neighbor-changes
R-21#write terminal
Building configuration...

% Topology global::IPv4 Unicast::base is currently being deconfigured.
% BGP context not been initialized properly.
...config...

All tests pass successfully, so the problem is probably not in this warning message.

For your test, it is more representative to check the following sequence of commands:

ios-15.6-2T#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
ios-15.6-2T(config)#router bgp 64496
ios-15.6-2T(config-router)#address-family ipv4 multicast
ios-15.6-2T(config-router-af)#no redistribute eigrp 233
ios-15.6-2T(config-router-af)#exit-address-family
ios-15.6-2T(config-router)#no address-family ipv4
ios-15.6-2T(config-router)#exit
ios-15.6-2T(config)#exit
ios-15.6-2T#show running-config | section ^router bgp
... command output...
ios-15.6-2T#write
Building configuration...
...

And also run ansible with debugging:

ANSIBLE_DEBUG=yes ANSIBLE_PERSISTENT_LOG_MESSAGES=yes ANSIBLE_LOG_PATH=log.log ansible-playbook -vvvvv ...parameters...

and see what exactly is sent to the device and returns from it.

@NilashishC

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2019

@hexdump0x0200 This task goes ahead and configures an ipv4 unicast address family on the device, which is not removed until we reach Configure redistribute information under address family mode with operation replace. Since it is a replace operation and module params doesn't specify an ipv4 unicast address family, the module correctly attempts to remove it. However, we missed adding a no address-family ipv4 command in assertion.

Now coming back to why the next task is not idempotent. I noticed the following behaviour on our CI IOS instance:

ios-15.6-2T(config-router)#no address-family ipv4
ios-15.6-2T(config-router)#exit
ios-15.6-2T(config)#exit
ios-15.6-2T#show running-config | section bgp
router bgp 64496
 bgp router-id 192.0.2.2
 bgp log-neighbor-changes
 neighbor 192.0.2.15 remote-as 64496
 neighbor 192.0.2.15 description IBGP_NBR_2
 neighbor 192.0.2.15 ebgp-multihop 150
 neighbor 203.0.113.10 remote-as 64511
 neighbor 203.0.113.10 local-as 64497
 neighbor 203.0.113.10 description EBGP_NBR_1
 !
 address-family ipv4
  no neighbor 192.0.2.15 activate
  no neighbor 203.0.113.10 activate
 exit-address-family
 !
 address-family ipv4 multicast
  network 192.0.2.64 mask 255.255.255.224
  network 198.51.100.80 mask 255.255.255.240
  network 203.0.113.192 mask 255.255.255.224
  redistribute ospf 112 metric 64

First execution of no address-family ipv4 doesn't remove the address family from the device.

ios-15.6-2T(config)#router bgp 64496
ios-15.6-2T(config-router)#no address-family ipv4
ios-15.6-2T(config-router)#exit
ios-15.6-2T(config)#do show run | section bgp
router bgp 64496
 bgp router-id 192.0.2.2
 bgp log-neighbor-changes
 !
 address-family ipv4 multicast
  network 192.0.2.64 mask 255.255.255.224
  network 198.51.100.80 mask 255.255.255.240
  network 203.0.113.192 mask 255.255.255.224
  redistribute ospf 112 metric 64
  redistribute eigrp 233 metric 256
 exit-address-family

A subsequent second execution of the negate command does it. This behaviour is causing the idempotence assertion to fail and is probably an issue with the IOS version we're running.

@hexdump0x0200

This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

@NilashishC , @pabelanger
IOS XE 16.03.08:
After executing no address-family ipv4, the address-family configuration is removed.
The output of the sh bgp all command becomes completely empty (usually a bgp table is displayed for all address-family). After some time, the output of sh bgp all becomes normal, with routes, and the lines appear in the configuration:

 address-family ipv4
  no neighbor *** activate
 exit-address-family

Repeated execution of no address-family ipv4 leads to the repetition of these events: the configuration address-family ipv4 disappears, the output of the sh bgp all command is empty, after a while everything is restored, the lines appear again in the configuration

address-family ipv4
 no neighbor *** activate
exit-address-family

if you run no neighbor *** with a higher level, in the context of the router bgp (and then delete address-family ipv4 again), then almost the same thing happens, it appears in the configuration:

 address-family ipv4
 exit-address-family

old IOS 12.4:

after performing no address-family ipv4 in configuration remains

  address-family ipv4
   no neighbor *** activate
  exit-address-family

after performing no neighbor *** in the context of the router bgp, the address-family ipv4 configuration disappears without additional actions.

I do not have the opportunity to test ios 15.

@hexdump0x0200

This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

In addition, before configuring neighbors in the context of address-family ipv4 multicast, it must be defined in the context of router bgp, after which it automatically appears and is activated in the context of address-family ipv4

@ganeshrn ganeshrn requested a review from NilashishC Jun 19, 2019

@hexdump0x0200 hexdump0x0200 force-pushed the hexdump0x0200:ios_bgp_fix branch from 94c4b8c to 4e90876 Jun 24, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2019

@ansible-zuul

This comment has been minimized.

Copy link

commented Jun 24, 2019

Build succeeded (third-party-check pipeline).

@ansibot ansibot added needs_revision and removed core_review labels Jun 24, 2019

@hexdump0x0200

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2019

bot_status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.