Skip to content

Commit 0f41c6d

Browse files
authored
fix sr shared bigip multiple cis instances (#3941)
1 parent f547fc1 commit 0f41c6d

File tree

6 files changed

+49
-8
lines changed

6 files changed

+49
-8
lines changed

build-tools/Dockerfile.debian

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ COPY . .
1313

1414
RUN $REPOPATH/build-tools/rel-build.sh
1515

16-
FROM python:3.10-slim-buster
16+
FROM python:3.10-slim-bullseye
1717

1818
ENV APPPATH /app
1919

docs/RELEASE-NOTES.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ Added Functionality
1414

1515
Bug Fixes
1616
````````````
17+
* Issue 3719 <https://github.com/F5Networks/k8s-bigip-ctlr/issues/3719>`_: Fix shared static routes override each other with multiple CIS instances writing to Common Partition
1718
* Issue 3852 <https://github.com/F5Networks/k8s-bigip-ctlr/issues/3852>`_: Improve logging when BIG-IP is not reachable during pod initialization
1819

1920
Upgrade notes
2021
``````````````
21-
22+
* Upgrading to CIS 2.21, static routes are deleted and recreated with new description added to fix the issue(`Github#3719`) of static routes overriding each other with multiple CIS instances writing to Common Partition. This may cause a brief disruption in traffic while the routes are being recreated.
2223
2.20.1
2324
-------------
2425

docs/config_examples/StaticRoute/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,7 @@ In case static routes are not added, along with looking at CIS logs you can also
7272
7373
In case static routes are configured with calico CNI, you can check the logs of CIS to see if the blockaffinities are being read properly. If not, you can check the permissions of the CIS service account to read blockaffinities. You can also check and verify that the blockaffinities are being created properly in the calico CNI.
7474
75-
75+
### FAQ
76+
* **Q: How to configure shared static routes with multiple CIS instances in different clusters using the same BIGIP?**
77+
* A: Set `--shared-static-routes=true` and `--local-cluster-name=<clusterName>` in CIS deployment args. This will create static routes in /Common partition and uniquely manage them per cluster without overriding other cluster routes.
7678

pkg/controller/node_poll_handler.go

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,39 @@ func ciliumPodCidr(annotation map[string]string) string {
181181
return ""
182182
}
183183

184+
// setCISIdentifierForRoutes sets the CIS identifier for route section based on cluster configuration
185+
func (ctlr *Controller) setCISIdentifierForRoutes(routes *routeSection) {
186+
var routeClusterName string
187+
// Use local cluster name to create unique CIS identifier across clusters
188+
if ctlr.multiClusterMode == SecondaryCIS {
189+
// For secondary CIS, use the HA pair cluster name
190+
// so that static routes are not overwritten from the HA pair during failover
191+
routeClusterName = ctlr.multiClusterHandler.HAPairClusterName
192+
} else {
193+
routeClusterName = ctlr.multiClusterHandler.LocalClusterName
194+
}
195+
var nodeLabelSelector string
196+
if clusterConfig, ok := ctlr.multiClusterHandler.ClusterConfigs[routeClusterName]; ok {
197+
nodeLabelSelector = clusterConfig.nodeLabelSelector
198+
}
199+
if routeClusterName != "" {
200+
routes.CISIdentifier = strings.TrimPrefix(ctlr.RequestHandler.PrimaryBigIPWorker.getPostManager().BIGIPURL, "https://") + "_" + routeClusterName
201+
if nodeLabelSelector != "" {
202+
routes.CISIdentifier += "_" + nodeLabelSelector
203+
}
204+
log.Infof("Using cluster-specific CIS identifier: %s (cluster: %s, nodeLabelSelector: %s)", routes.CISIdentifier, routeClusterName, nodeLabelSelector)
205+
} else {
206+
if nodeLabelSelector != "" {
207+
routes.CISIdentifier = strings.TrimPrefix(ctlr.RequestHandler.PrimaryBigIPWorker.getPostManager().BIGIPURL, "https://")
208+
routes.CISIdentifier += "_" + nodeLabelSelector
209+
} else {
210+
// Don't set CIS identifier when no cluster name or no nodelabelselctor is configured
211+
routes.CISIdentifier = ""
212+
log.Warningf("Local cluster name not set. Multiple CIS instances across clusters may still cause route conflicts with shared-static-routes writing to same BIGIP instance!")
213+
}
214+
}
215+
}
216+
184217
func (ctlr *Controller) processStaticRouteUpdate(
185218
nodes []interface{},
186219
) {
@@ -193,7 +226,9 @@ func (ctlr *Controller) processStaticRouteUpdate(
193226
}
194227
log.Debugf("Processing Node Updates for static routes")
195228
routes := routeSection{}
196-
routes.CISIdentifier = ctlr.Partition + "_" + strings.TrimPrefix(ctlr.RequestHandler.PrimaryBigIPWorker.getPostManager().BIGIPURL, "https://")
229+
// Set CIS identifier for routes
230+
ctlr.setCISIdentifierForRoutes(&routes)
231+
197232
nodePodCIDRMap := ctlr.GetNodePodCIDRMap()
198233
for _, obj := range nodes {
199234
node := obj.(*v1.Node)
@@ -444,7 +479,9 @@ func (ctlr *Controller) processBlockAffinities(clusterName string) {
444479
var baListInf []interface{}
445480
baListInf = ctlr.getBlockAffinitiesFromAllClusters()
446481
routes := routeSection{}
447-
routes.CISIdentifier = ctlr.Partition + "_" + strings.TrimPrefix(ctlr.RequestHandler.PrimaryBigIPWorker.getPostManager().BIGIPURL, "https://")
482+
// Set CIS identifier for routes
483+
ctlr.setCISIdentifierForRoutes(&routes)
484+
448485
clusterConfig := ctlr.multiClusterHandler.getClusterConfig(clusterName)
449486
for _, obj := range baListInf {
450487
blockAffinity := obj.(*unstructured.Unstructured)

pkg/controller/node_poll_handler_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ var _ = Describe("Node Poller Handler", func() {
9797

9898
It("Nodes Update processing", func() {
9999
mockCtlr.Partition = "test"
100-
cisIdentifier := mockCtlr.Partition + "_127.0.0.1"
100+
mockCtlr.multiClusterHandler.LocalClusterName = "localCluster"
101+
cisIdentifier := "127.0.0.1_" + mockCtlr.multiClusterHandler.LocalClusterName
101102
mockCtlr.setNodeInformer("")
102103
mockCtlr.UseNodeInternal = true
103104
namespace := "default"

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
-e git+https://github.com/f5devcentral/f5-cccl.git@497c325211de2191afe1ffaef673df07f7bb7c26#egg=f5-cccl
2-
-e git+https://github.com/f5devcentral/f5-ctlr-agent.git@a717f8843f4dced916efda1edeebc8675ef0e675#egg=f5-ctlr-agent
1+
-e git+https://github.com/f5devcentral/f5-cccl.git@6dfb9005bb7de35652773db26e1239b84611f8ab#egg=f5-cccl
2+
-e git+https://github.com/f5devcentral/f5-ctlr-agent.git@fee3f82f5948fc45e9bbc980d3d299ae7e5bfa1c#egg=f5-ctlr-agent
33
-e git+https://github.com/F5Networks/f5-icontrol-rest-python.git@3fee4a4599e903cce1abfe232e6ffb74d7085b64#egg=f5-icontrol-rest

0 commit comments

Comments
 (0)