Skip to content

Commit

Permalink
chore: add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
hrak committed Aug 15, 2024
1 parent ba2c502 commit f8d2c27
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/cloud/isolated_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cloud

import (
"fmt"
"k8s.io/klog/v2"
"slices"
"strconv"
"strings"
Expand Down Expand Up @@ -247,20 +248,28 @@ func (c *client) ReconcileLoadBalancerRules(isoNet *infrav1.CloudStackIsolatedNe
ports = append(ports, csCluster.Spec.APIServerLoadBalancer.AdditionalPorts...)
}

logger := klog.Background()
logger.Info("reconciling load balancer rules", "ports", ports, "portsAndIDs", portsAndIDs)

lbRuleIDs := make([]string, 0)
logger.Info("lbRuleIDs", "lbRuleIDs", lbRuleIDs, "length", len(lbRuleIDs))
for _, port := range ports {
// Check if lb rule for port already exists
logger.Info("Checking if rule exists", "port", port)
ruleID, found := portsAndIDs[strconv.Itoa(port)]
if found {
logger.Info("Rule found", "ruleID", ruleID)
lbRuleIDs = append(lbRuleIDs, ruleID)
} else {
// If not found, create the lb rule for port
ruleID, err = c.CreateLoadBalancerRule(isoNet, port)
if err != nil {
return errors.Wrap(err, "creating load balancer rule")
}
logger.Info("Rule not found & created", "ruleID", ruleID)
lbRuleIDs = append(lbRuleIDs, ruleID)
}
logger.Info("lbRuleIDs", "lbRuleIDs", lbRuleIDs, "length", len(lbRuleIDs))

// For backwards compatibility.
if port == int(csCluster.Spec.ControlPlaneEndpoint.Port) {
Expand All @@ -282,12 +291,9 @@ func (c *client) ReconcileLoadBalancerRules(isoNet *infrav1.CloudStackIsolatedNe
}
}
}

if len(lbRuleIDs) > 1 {
capcstrings.Canonicalize(lbRuleIDs)
}

isoNet.Status.LoadBalancerRuleIDs = lbRuleIDs
// Update isoNet status with the current list of loadbalancer rule ID's.
logger.Info("ReconcileLoadBalancerRules done", "lbRuleIDs", lbRuleIDs, "length", len(lbRuleIDs))
isoNet.Status.LoadBalancerRuleIDs = capcstrings.Canonicalize(lbRuleIDs)

return nil
}
Expand Down

0 comments on commit f8d2c27

Please sign in to comment.