Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
Add missing error handler for AddRRStatus method
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmxs committed Jun 5, 2020
1 parent 5657add commit dc2de91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
* Configured Calico `BGPPeer`s one for route reflector mesh and an other for clients. [More info](https://docs.projectcalico.org/getting-started/kubernetes/hardway/configure-bgp-peering)

This Kubernetes operator can monitor and scale Calico route refloctor pods based on node number per zone. The operator owns a few environment variables:
* `DATASTORE_TYPE` Calico datastore [`incluster`, `kubernetes`, `etcd`], default `incluster`
* `K8S_API_ENDPOINT` Kubernetes API endpoint, default `https://kubernetes.default`
* `ROUTE_REFLECTOR_CLUSTER_ID` Route reflector cluster ID, default `224.0.0.%d`
* `ROUTE_REFLECTOR_MIN` Minimum number of route reflector pods per zone, default `3`
* `ROUTE_REFLECTOR_MAX` Maximum number of route reflector pods per zone, default `25`
* `ROUTE_REFLECTOR_RATIO` Node / route reflector pod ratio, default `0.005` (`1000 * 0.005 = 5`)
* `ROUTE_REFLECTOR_NODE_LABEL` Node label of the route reflector nodes, default `calico-route-reflector=`
* `ROUTE_REFLECTOR_ZONE_LABEL` Node label of the zone, default ``
* `ROUTE_REFLECTOR_TOPOLOGY` Selected topology of route reflectors [simple, multi], defaulr: `simple`
* `ROUTE_REFLECTOR_TOPOLOGY` Selected topology of route reflectors [simple, multi], default `simple`

You can edit or add those environment variables at the [manager](config/manager/manager.yaml) manifest. You can add Calico client config related variables, Calico lib will parse it in the background.

During the `api/core/v1/Node` reconcile phases it calculates the right number of route refloctor nodes per zone. It supports linear scaling only and it multiplies the number of nodes with the given ratio and than updates the route reflector replicas to the expected number.

Expand Down
7 changes: 5 additions & 2 deletions controllers/routereflectorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (r *RouteReflectorConfigReconciler) removeRRStatus(req ctrl.Request, node *
routeReflectorsUnderOperation[node.GetUID()] = false

if err := r.Datastore.RemoveRRStatus(node); err != nil {
log.Errorf("Unable to cleanup node status %s because of %s", node.GetName(), err.Error())
log.Errorf("Unable to cleanup RR status %s because of %s", node.GetName(), err.Error())
return err
}

Expand All @@ -186,7 +186,10 @@ func (r *RouteReflectorConfigReconciler) updateRRStatus(node *corev1.Node, diff

routeReflectorsUnderOperation[node.GetUID()] = true

r.Datastore.AddRRStatus(node)
if err := r.Datastore.AddRRStatus(node); err != nil {
log.Errorf("Unable to add RR status %s because of %s", node.GetName(), err.Error())
return false, err
}

log.Infof("Adding route reflector label to %s", node.GetName())
if err := r.Client.Update(context.Background(), node); err != nil {
Expand Down

0 comments on commit dc2de91

Please sign in to comment.