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

[v1.14] bgpv1: Remove disruptive error handling from BGPRouterManager #30765

Merged
merged 4 commits into from Feb 16, 2024

Conversation

YutaroHayakawa
Copy link
Member

Backport of #30382. Many conflicts were observed.

bgpv1: Remove disruptive error handling from BGPRouterManager

[ upstream commit 1676530 ]

[ backporter's note: v1.14 is missing various refactoring commits on
  upstream. Needed to adjust some variable names, field names, and so
  on. ]

Currently, when the BGP Control Plane meet the error during
reconciliation, it stops and unregisters the server. This comes at a
risk when we accidentally introduce a situation where reconcilers
repeatedly return error for a long time. In such a situation, BGP
Control Plane repeatedly create/destroy server which may cause a BGP
session flapping or frequent route update/withdraw.

We have this problem in two places. The first one is in
BGPRouterManager.register(). When the initial reconciliation fails, BGP
Control Plane stop the server it just creates. In this case, we don't
need to stop server. We can register the server to the RouterManager
before reconciliation and don't have to unregister it even if the
initial reconciliation fails. This is because we have a retry logic now.
The reconciliation failure triggers the retry and in the next cycle, the
reconciliation will be handled in the BGPRouterManager.reconcile()
because the server is already registered.

The second problem is in BGPRouterManager.reconcile(). When the
reconciliation fails, BGP Control Plane stops the BGP server in failure
and unregisters it. Since we have a retry logic, we don't need to stop
BGP servers. We can return error and retry later until we recover from
the failure state.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
[ upstream commit 7275198 ]

[ backporter's comment: All reconcilers are separated into file in
  upstream. In v1.14, they are still in the same file. Needed to
  move test code. ]

Extend existing reconciler test cases to always execute Reconcile()
twice. This simulates the behavior that BGPRouterManager doesn't clear
the BGP server on reconciliation failure and the next event occurs and
ensures the reconcilers are not relying on that behavior.

As a result, existing reconcilers except NeighborReconciler passed the
test. The fix for the neighbor reconciler will be followed.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
[ upstream commit 7684f35 ]

[ backporter's note: Moved neighbor reconciler's logic from individual
file to reconciler.go and consolidate neighborReconciler function into
NeighborReconciler.Reconcile. ]

There are a lot of repetition of the same fmt.Sprintf in
NeighborReconciler that constructs the same neighbor ID. Introduce a
helper method to construct neighbor ID.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
[ upstream commit 192f37c ]

[ backporter's note: NeighborReconciler doesn't have any metadata
  infrastructure because we don't have MD5 password feature, so we
  needed to introduce it in this commit. ]

Currenly, NeighborReconciler only reconciles on old vs new configuration
differences and doesn't take the actual GoBGP's running state into
account. As a result, when the reconciliation of another reconciler
fails and CurrentServer.Config is not updated, it tries to repeat the
previous reconciliation again. However, when it involves adding the
neighbor, it fails, because adding neighbor is not idempotent in GoBGP.

To solve this issue, we track the neighbor state in metadata and
compare the diff between new config and the state instead of old config.
This makes NeighborReconciler idempotent.

Signed-off-by: Yutaro Hayakawa <yutaro.hayakawa@isovalent.com>
@maintainer-s-little-helper maintainer-s-little-helper bot added backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. kind/backports This PR provides functionality previously merged into master. labels Feb 14, 2024
@YutaroHayakawa YutaroHayakawa requested review from a team and rastislavs and removed request for a team February 14, 2024 13:01
@YutaroHayakawa YutaroHayakawa added area/bgp release-note/misc This PR makes changes that have no direct user impact. labels Feb 14, 2024
@YutaroHayakawa YutaroHayakawa marked this pull request as ready for review February 15, 2024 04:10
@YutaroHayakawa YutaroHayakawa requested a review from a team as a code owner February 15, 2024 04:10
@YutaroHayakawa
Copy link
Member Author

/test-backport-1.14

@YutaroHayakawa
Copy link
Member Author

YutaroHayakawa commented Feb 15, 2024

Cilium Cluster Mesh upgrade, Conformance Cluster Mesh: Image pull timeout

Copy link
Contributor

@rastislavs rastislavs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Feb 15, 2024
@YutaroHayakawa YutaroHayakawa merged commit 1b33c9b into cilium:v1.14 Feb 16, 2024
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bgp backport/1.14 This PR represents a backport for Cilium 1.14.x of a PR that was merged to main. kind/backports This PR provides functionality previously merged into master. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants