Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix lb default for disable IPv6 #21

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion internal/hcops/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,17 @@ func (l *LoadBalancerOps) togglePublicInterface(ctx context.Context, lb *hcloud.
return true, nil
}

func (l *LoadBalancerOps) getDisableIPv6(svc *corev1.Service) (bool, error) {
disable, err := annotation.LBIPv6Disabled.BoolFromService(svc)
if err == nil {
return disable, nil
}
if errors.Is(err, annotation.ErrNotSet) {
return l.Defaults.DisableIPv6, nil
}
return false, err
}

// ReconcileHCLBTargets adds or removes target nodes from the Hetzner Cloud
// Load Balancer when nodes are added or removed to the K8S cluster.
func (l *LoadBalancerOps) ReconcileHCLBTargets(
Expand Down Expand Up @@ -598,6 +609,11 @@ func (l *LoadBalancerOps) ReconcileHCLBTargets(
changed bool
)

disableIPv6, err := l.getDisableIPv6(svc)
if err != nil {
return changed, fmt.Errorf("%s: %w", op, err)
}

usePrivateIP, err := l.getUsePrivateIP(svc)
if err != nil {
return changed, fmt.Errorf("%s: %w", op, err)
Expand Down Expand Up @@ -725,7 +741,7 @@ func (l *LoadBalancerOps) ReconcileHCLBTargets(
// to the K8S Load Balancer as IP targets to the HC Load Balancer.
for id := range k8sNodeIDsRobot {
var arr []string
if l.Defaults.DisableIPv6 {
if disableIPv6 {
arr = []string{
robotIDToIPv4[id],
}
Expand Down