Copilot commented on code in PR #88:
URL:
https://github.com/apache/cloudstack-kubernetes-provider/pull/88#discussion_r4044299920
##########
cloudstack_loadbalancer.go:
##########
@@ -186,12 +190,36 @@ func (cs *CSCloud) EnsureLoadBalancer(ctx
context.Context, clusterName string, s
// Delete the rule from the map, to prevent it
being deleted.
delete(lb.rules, lbRuleName)
}
+
+ stickinessPolicy, stickinessPolicyNeedsUpdate, err :=
lb.checkStickinessPolicy(lbRule, service)
+ if err != nil {
+ return nil, err
+ }
+ if stickinessPolicyNeedsUpdate {
+ if stickinessPolicy != nil {
+ klog.V(4).Infof("Recreate stickiness
policy: %v", lbRuleName)
+ if err :=
lb.deleteStickinessPolicy(stickinessPolicy.Id); err != nil {
+ return nil, err
+ }
+ delete(lb.stickinessPolicies, lbRule.Id)
+ } else {
+ klog.V(4).Infof("Creating stickiness
policy: %v", lbRuleName)
+ }
+ if _, err :=
lb.createStickinessPolicy(lbRuleName, lbRule.Id, service); err != nil {
+ return nil, err
+ }
+ // Remove from map to mark as handled (map
tracks initial state for comparison)
+ delete(lb.stickinessPolicies, lbRule.Id)
+ }
} else {
klog.V(4).Infof("Creating load balancer rule: %v",
lbRuleName)
lbRule, err = lb.createLoadBalancerRule(lbRuleName,
port, protocol, service)
if err != nil {
return nil, err
}
+ if _, err := lb.createStickinessPolicy(lbRuleName,
lbRule.Id, service); err != nil {
+ return nil, err
+ }
Review Comment:
If policy creation fails (for example, because CloudStack rejects an
unsupported method or parameter), this returns without deleting the
load-balancer rule that was just created. The service then remains in a
failed-sync state with an active rule despite no successfully configured
stickiness policy. Clean up `lbRule` before returning the creation error (and
preserve any cleanup error).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]