Skip to content

Commit

Permalink
typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Conforti committed Aug 23, 2024
1 parent ed424c4 commit 07b4ce7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
40 changes: 24 additions & 16 deletions controllers/haegressgatewaypolicies_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,23 @@ func (r *HAEgressGatewayPolicyReconciler) Reconcile(ctx context.Context, req ctr
return ctrl.Result{}, err
}

serviceNamespace := r.EgressNamespace
if haEgressGatewayPolicy.Annotations[haegressip.HAEgressGatewayPolicyNamespace] != "" {
serviceNamespace = haEgressGatewayPolicy.Annotations[haegressip.HAEgressGatewayPolicyNamespace]
}
leaseExpectedName := fmt.Sprintf("cilium-l2announce-%s-%s",
serviceNamespace, haEgressGatewayPolicy.Name)

if haEgressGatewayPolicy.Labels[haegressip.HAEgressGatewayPolicyExpectedLeaseName] != leaseExpectedName {
haEgressGatewayPolicy.Labels[haegressip.HAEgressGatewayPolicyExpectedLeaseName] = leaseExpectedName
/*
serviceNamespace := r.EgressNamespace
if haEgressGatewayPolicy.Annotations[haegressip.HAEgressGatewayPolicyNamespace] != "" {
serviceNamespace = haEgressGatewayPolicy.Annotations[haegressip.HAEgressGatewayPolicyNamespace]
}
leaseExpectedName := fmt.Sprintf("cilium-l2announce-%s-%s",
serviceNamespace, haEgressGatewayPolicy.Name)
if haEgressGatewayPolicy.Labels[haegressip.HAEgressGatewayPolicyExpectedLeaseName] != leaseExpectedName {
haEgressGatewayPolicy.Labels[haegressip.HAEgressGatewayPolicyExpectedLeaseName] = leaseExpectedName
if err := r.Update(ctx, &haEgressGatewayPolicy); err != nil {
log.Error(err, "unable to update HAEgressGatewayPolicy, please check RBAC permissions")
return ctrl.Result{RequeueAfter: haegressip.HAEgressGatewayPolicyChcekRequeueAfter}, err
if err := r.Update(ctx, &haEgressGatewayPolicy); err != nil {
log.Error(err, "unable to update HAEgressGatewayPolicy, please check RBAC permissions")
return ctrl.Result{RequeueAfter: haegressip.HAEgressGatewayPolicyChcekRequeueAfter}, err
}
}
}
*/
if err := r.UpdateOrCreateCiliumEgressGatewayPolicy(ctx, &haEgressGatewayPolicy); err != nil {
log.Error(err, "unable to create or update CiliumEgressGatewayPolicy, please check RBAC permissions")
return ctrl.Result{RequeueAfter: haegressip.HAEgressGatewayPolicyChcekRequeueAfter}, err
Expand Down Expand Up @@ -135,8 +137,8 @@ func (r *HAEgressGatewayPolicyReconciler) UpdateOrCreateCiliumEgressGatewayPolic

ciliumEgressGatewayPolicyExist := &ciliumv2.CiliumEgressGatewayPolicy{}
err := r.Get(ctx, types.NamespacedName{
Name: ciliumEgressGatewayPolicyNew.Name,
Namespace: ciliumEgressGatewayPolicyNew.Namespace}, ciliumEgressGatewayPolicyExist)
Name: ciliumEgressGatewayPolicyNew.Name,
}, ciliumEgressGatewayPolicyExist)

if err != nil && apierrors.IsNotFound(err) {
logger.Info("Creating a new CiliumEgressGatewayPolicy for HAEgressGatewayPolicy",
Expand Down Expand Up @@ -189,6 +191,8 @@ func (r *HAEgressGatewayPolicyReconciler) UpdateOrCreateService(ctx context.Cont
serviceNamespace = haEgressGatewayPolicy.Annotations[haegressip.HAEgressGatewayPolicyNamespace]
}

// @TODO: check if target namespace exists

// Define the service and copy all annotations from the HAEgressGatewayPolicy instance
service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -207,13 +211,17 @@ func (r *HAEgressGatewayPolicyReconciler) UpdateOrCreateService(ctx context.Cont
},
},
Type: corev1.ServiceTypeLoadBalancer,
// Points nowhere, is a serviceless service used to craete the IP object
// Points nowhere, is a serviceless service used to create the IP object
Selector: map[string]string{
haegressip.HAEgressGatewayPolicyNamespace: serviceNamespace,
haegressip.HAEgressGatewayPolicyName: haEgressGatewayPolicy.Name,
},
},
}

if service.Labels == nil {
service.Labels = make(map[string]string)
}
service.Labels[haegressip.HAEgressGatewayPolicyNamespace] = serviceNamespace
service.Labels[haegressip.HAEgressGatewayPolicyName] = haEgressGatewayPolicy.Name

Expand Down
2 changes: 1 addition & 1 deletion controllers/services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (r *ServicesController) Reconcile(ctx context.Context, req ctrl.Request) (c
// Update CiliumEgressGatewayPolicy with the LoadBalancerIP
ciliumEgressGatewayPolicy := &ciliumv2.CiliumEgressGatewayPolicy{}
err := r.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("%s-%s",
service.Labels[haegressip.HAEgressGatewayPolicyNamespace], service.Labels[haegressip.HAEgressGatewayPolicyName])}, ciliumEgressGatewayPolicy)
service.Namespace, service.Name)}, ciliumEgressGatewayPolicy)

if err != nil {
if apierrors.IsNotFound(err) {
Expand Down

0 comments on commit 07b4ce7

Please sign in to comment.