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

iosxe_route_map / match_source_protocol_bgp behaviour #56

Closed
grotewortel opened this issue Sep 19, 2023 · 7 comments
Closed

iosxe_route_map / match_source_protocol_bgp behaviour #56

grotewortel opened this issue Sep 19, 2023 · 7 comments

Comments

@grotewortel
Copy link

Dear,

We have an issue regarding the iosxe_route_map / match_source_protocol_bgp behaviour statement.
Changes and Deletions do not seem to be handled properly.

Can you please look at this?

IOSXE TF Provider version: self-compiled 0.4.1 unreleased (date Tue Sept 19 2023)
IOS version: Cisco IOS XE Software, Version 17.11.01a

Below is a step-by-step example on howto reproduce and some debug information.

start clean

ROUTER8001#show route-map GITHUB
route-map GITHUB not found

resource source config for creation

resource "iosxe_route_map" "github" {
  provider = iosxe.router8001
  name = "GITHUB"
  entries = [
    {
      seq                                      = 10
      operation                                = "permit"
      description                              = "Entry 10"
      continue                                 = false
      match_source_protocol_bgp                = ["65001"]

    }
  ]
}

Terraform apply output for creation (works fine)

Terraform will perform the following actions:

  # iosxe_route_map.github will be created
  + resource "iosxe_route_map" "github" {
      + entries = [
          + {
              + continue                  = false
              + description               = "Entry 10"
              + match_source_protocol_bgp = [
                  + "65001",
                ]
              + operation                 = "permit"
              + seq                       = 10
            },
        ]
      + id      = (known after apply)
      + name    = "GITHUB"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
iosxe_route_map.github: Creating...
iosxe_route_map.github: Creation complete after 1s [id=Cisco-IOS-XE-native:native/route-map=GITHUB]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

running config after creation (looks ok)

ROUTER8001#show route-map GITHUB
route-map GITHUB, permit, sequence 10
  Match clauses:
    source-protocol  bgp 65001
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes
ROUTER8001#

resource source config modification #1: replace 65001 with 65002

resource "iosxe_route_map" "github" {
  provider = iosxe.router8001
  name = "GITHUB"
  entries = [
    {
      seq                                      = 10
      operation                                = "permit"
      description                              = "Entry 10"
      continue                                 = false
      match_source_protocol_bgp                = ["65002"]

    }
  ]
}

Terraform apply output suggests correct behaviour

Terraform will perform the following actions:

  # iosxe_route_map.github will be updated in-place
  ~ resource "iosxe_route_map" "github" {
      ~ entries = [
          ~ {
              ~ match_source_protocol_bgp = [
                  - "65001",
                  + "65002",
                ]
                # (4 unchanged attributes hidden)
            },
        ]
        id      = "Cisco-IOS-XE-native:native/route-map=GITHUB"
        name    = "GITHUB"
    }

Plan: 0 to add, 1 to change, 0 to destroy.
iosxe_route_map.github: Modifying... [id=Cisco-IOS-XE-native:native/route-map=GITHUB]
iosxe_route_map.github: Modifications complete after 0s [id=Cisco-IOS-XE-native:native/route-map=GITHUB]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

running config after modifcation is unexpected: 65002 has been added instead of replaced

ROUTER8001#show route-map GITHUB
route-map GITHUB, permit, sequence 10
  Match clauses:
    source-protocol  bgp 65001 bgp 65002
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes
ROUTER8001#

running config / partial JSON after modifcation: 65002 has been added instead of replaced

    "route-map": [
      {
        "name": "GITHUB",
        "Cisco-IOS-XE-route-map:route-map-without-order-seq": [
          {
            "seq_no": 10,
            "operation": "permit",
            "descriptions": [
              {
                "description-leaf": "Entry 10"
              }
            ],
            "match": {
              "source-protocol": {
                "bgp": [65001, 65002]
              }
            }
          }
        ]
      },

resource source config modification #2: remove the complete statement

resource "iosxe_route_map" "github" {
  provider = iosxe.router8001
  name = "GITHUB"
  entries = [
    {
      seq                                      = 10
      operation                                = "permit"
      description                              = "Entry 10"
      continue                                 = false
#      match_source_protocol_bgp                = ["65002"]

    }
  ]
}

Terraform apply output suggests correct behaviour ... and fails

Terraform will perform the following actions:

  # iosxe_route_map.github will be updated in-place
  ~ resource "iosxe_route_map" "github" {
      ~ entries = [
          ~ {
              - match_source_protocol_bgp = [
                  - "65001",
                  - "65002",
                ] -> null
                # (4 unchanged attributes hidden)
            },
        ]
        id      = "Cisco-IOS-XE-native:native/route-map=GITHUB"
        name    = "GITHUB"
    }

Plan: 0 to add, 1 to change, 0 to destroy.
iosxe_route_map.github: Modifying... [id=Cisco-IOS-XE-native:native/route-map=GITHUB]
iosxe_route_map.github: Still modifying... [id=Cisco-IOS-XE-native:native/route-map=GITHUB, 10s elapsed]
iosxe_route_map.github: Still modifying... [id=Cisco-IOS-XE-native:native/route-map=GITHUB, 20s elapsed]
╷
│ Error: Client Error
│ 
│   with iosxe_route_map.github,
│   on cisco8001.tf line 237, in resource "iosxe_route_map" "github":
│  237: resource "iosxe_route_map" "github" {
│ 
│ Failed to delete object, got error: HTTP Request failed: StatusCode 400, RESTCONF errors {Error:[{ErrorType:application ErrorTag:invalid-value ErrorAppTag: ErrorPath:
│ ErrorMessage:inconsistent value: Device refused one or more commands ErrorInfo:}]} {PatchId: GlobalStatus:{Ok:false Errors:{Error:[]}} EditStatus:{Edit:[]}
│ Errors:{Error:[]}}

running config after failed attempt

ROUTER8001#show route-map GITHUB
route-map GITHUB, permit, sequence 10
  Match clauses:
    source-protocol  bgp 65002 bgp 65001
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes
@danischm
Copy link
Member

I think removing "match_source_protocol_bgp" fails, because you end up with an incomplete route map. I guess you need at least on "match" statement. I will look into why the list modification does not remove the 65001 entry.

@danischm
Copy link
Member

This should fix the first issue: 1ac6d2a

@grotewortel
Copy link
Author

We actually started out with multiple match statements. We removed them for simplicity :-)

@danischm
Copy link
Member

Ok, but if you configure the route-map via CLI, does it allow you to configure a route-map without any match statements?

@danischm
Copy link
Member

This should fix the first issue: 1ac6d2a

Fixed in v0.5.0 release.

@grotewortel
Copy link
Author

I confirm that it is fixed in 0.5.0.

It looks like the removing of the match_source_protocol_bgp is solved also.
Below is purely informational, so you can see it is possible.

terraform config

# create routemap
resource "iosxe_route_map" "github" {
  provider = iosxe.router8001
  name = "GITHUB"
  entries = [
    {
      seq                                      = 10
      operation                                = "permit"
      description                              = "Entry 10"
      continue                                 = false
      match_source_protocol_bgp                = ["65005"]
      set_tag                                  = 100
    }
  ]
}

terraform output

Terraform will perform the following actions:

  # iosxe_route_map.github will be created
  + resource "iosxe_route_map" "github" {
      + entries = [
          + {
              + continue                  = false
              + description               = "Entry 10"
              + match_source_protocol_bgp = [
                  + "65005",
                ]
              + operation                 = "permit"
              + seq                       = 10
              + set_tag                   = 100
            },
        ]
      + id      = (known after apply)
      + name    = "GITHUB"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
iosxe_route_map.github: Creating...
iosxe_route_map.github: Creation complete after 1s [id=Cisco-IOS-XE-native:native/route-map=GITHUB]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

running config

route-map GITHUB permit 10 
 description Entry 10
 match source-protocol bgp 65005
 set tag 100
!

remove string from tf code

# remove routemap bgp source
resource "iosxe_route_map" "github" {
  provider = iosxe.router8001
  name = "GITHUB"
  entries = [
    {
      seq                                      = 10
      operation                                = "permit"
      description                              = "Entry 10"
      continue                                 = false
     # match_source_protocol_bgp                = ["65005"]
      set_tag                                  = 100
    }
  ]
}

terraform output

Terraform will perform the following actions:

  # iosxe_route_map.github will be updated in-place
  ~ resource "iosxe_route_map" "github" {
      ~ entries = [
          ~ {
              - match_source_protocol_bgp = [
                  - "65005",
                ] -> null
                # (5 unchanged attributes hidden)
            },
        ]
        id      = "Cisco-IOS-XE-native:native/route-map=GITHUB"
        name    = "GITHUB"
    }

Plan: 0 to add, 1 to change, 0 to destroy.
iosxe_route_map.github: Modifying... [id=Cisco-IOS-XE-native:native/route-map=GITHUB]
iosxe_route_map.github: Modifications complete after 1s [id=Cisco-IOS-XE-native:native/route-map=GITHUB]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

running config

route-map GITHUB permit 10 
 description Entry 10
 set tag 100
!

@grotewortel
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants