Skip to content

Commit

Permalink
Merge pull request #264 from Juniper/handle-subinterface-error
Browse files Browse the repository at this point in the history
Handle 'subinterfaces' link deletion error
  • Loading branch information
chrismarget-j committed Apr 30, 2024
2 parents d29c825 + 9382a20 commit 3b8e9f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apstra/talk_to_apstra.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const (
errResponseStringLimit = 1024
peekSizeForApstraTaskIdResponse = math.MaxUint8

linkHasCtAssignedErrRegexString = "Link with id (.*) can not be deleted since some of its interfaces have connectivity templates assigned"
lagHasCtAssignedErrRegexString = "Deleting all links forming a LAG is not allowed since the LAG has assigned structures: \\[.*'connectivity template'.*]. Link ids: \\[(.*)]"
linkHasVnEndpointErrRegexString = "Link with id (.*) can not be deleted since some of its interfaces have VN endpoints"
//lagHasAssignedStructuresRegexString = "Operation is not permitted because link group (.*) has assigned structures (VN endpoints, subinterfaces, endpoint templates etc.). Either at least one link from this group should preserve original group label, or all its links should change group label to the same new value, keeping aggregation (LAG / NO LAG) and without other link being added to it."
linkHasCtAssignedErrRegexString = "Link with id (.*) can not be deleted since some of its interfaces have connectivity templates assigned"
lagHasCtAssignedErrRegexString = "Deleting all links forming a LAG is not allowed since the LAG has assigned structures: \\[.*'connectivity template'.*]. Link ids: \\[(.*)]"
linkHasVnEndpointErrRegexString = "Link with id (.*) can not be deleted since some of its interfaces have VN endpoints"
linkHasSubinterfacesErrRegexString = "Link with id (.*) can not be deleted since some of its interfaces have subinterfaces"
lagHasAssignedStructuresRegexString = "Operation is not permitted because link group (.*) has assigned structures"
)

Expand All @@ -36,6 +36,7 @@ var (
regexpLinkHasCtAssignedErr = regexp.MustCompile(linkHasCtAssignedErrRegexString)
regexpLagHasCtAssignedErr = regexp.MustCompile(lagHasCtAssignedErrRegexString)
regexpLinkHasVnEndpoint = regexp.MustCompile(linkHasVnEndpointErrRegexString)
regexpLinkHasSubinterfaces = regexp.MustCompile(linkHasSubinterfacesErrRegexString)
regexpLagHasAssignedStructures = regexp.MustCompile(lagHasAssignedStructuresRegexString)
)

Expand Down
2 changes: 2 additions & 0 deletions apstra/two_stage_l3_clos_switch_system_links.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ func (o *TwoStageL3ClosClient) DeleteLinksFromSystem(ctx context.Context, ids []
lagErrs = append(lagErrs, le)
case regexpLinkHasVnEndpoint.MatchString(le):
// do nothing - this condition should trigger the regexpLinkHasCtAssignedErr also
case regexpLinkHasSubinterfaces.MatchString(le):
// do nothing - this condition should trigger the regexpLinkHasCtAssignedErr also
default: // cannot handle error - surface it to the user
return fmt.Errorf("cannot handle link error %q - %w", le, err)
}
Expand Down

0 comments on commit 3b8e9f7

Please sign in to comment.