Skip to content

Commit

Permalink
KO-360: Fix dual-stack network issue (#43)
Browse files Browse the repository at this point in the history
* Fix dual-stack network issue
  • Loading branch information
abhishekdwivedi3060 authored Jan 21, 2025
1 parent c680f56 commit 23cd711
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Aerospike Kubernetes Operator Init Container.
#
# Build the akoinit binary
FROM --platform=$BUILDPLATFORM golang:1.22 as builder
FROM --platform=$BUILDPLATFORM golang:1.22 AS builder

# OS and Arch args
ARG TARGETOS
Expand Down Expand Up @@ -65,7 +65,7 @@ RUN microdnf update -y \
&& microdnf clean all

# Add /workdir/bin to PATH
ENV PATH "/workdir/bin:$PATH"
ENV PATH="/workdir/bin:$PATH"

# For RedHat Openshift, set this to non-root user ID 1001 using
# --build-arg USER=1001 as docker build argument.
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/aerospike/aerospike-kubernetes-init
go 1.22

require (
github.com/aerospike/aerospike-kubernetes-operator v0.0.0-20241016165325-74a853c18a98
github.com/aerospike/aerospike-kubernetes-operator v0.0.0-20250113070037-b07a5f20edcb
github.com/go-logr/logr v1.4.2
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0
github.com/mitchellh/go-ps v1.0.0
Expand All @@ -17,7 +17,7 @@ require (

require (
github.com/aerospike/aerospike-client-go/v7 v7.6.1 // indirect
github.com/aerospike/aerospike-management-lib v1.5.0 // indirect
github.com/aerospike/aerospike-management-lib v1.5.1-0.20250106091653-f0c86baa6cd7 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
github.com/aerospike/aerospike-client-go/v7 v7.6.1 h1:VZK6S9YKq2w6ptTk3kXXjTxG2U9M9Y7Oi3YQ+3T7wQQ=
github.com/aerospike/aerospike-client-go/v7 v7.6.1/go.mod h1:uCbSYMpjlRcH/9f26VSF/luzDDXrcDaV8c6/WIcKtT4=
github.com/aerospike/aerospike-kubernetes-operator v0.0.0-20241016165325-74a853c18a98 h1:bhg99pbh1Z0EALqANZs4EEIjyiYT9IuRuFrq8cmgfwI=
github.com/aerospike/aerospike-kubernetes-operator v0.0.0-20241016165325-74a853c18a98/go.mod h1:51gVMITScFL9O2gFQ263/JaO4GACcVbvyj5aXcHYxL8=
github.com/aerospike/aerospike-management-lib v1.5.0 h1:uAEaBU+PkzbtwsSrPVokLIUeJaDrFSMtwqeCKba3xIs=
github.com/aerospike/aerospike-management-lib v1.5.0/go.mod h1:hsEptY/AmTmHoJnItJNmfJ4yCMG8LIB8YPnIpIyvGXI=
github.com/aerospike/aerospike-kubernetes-operator v0.0.0-20250113070037-b07a5f20edcb h1:9nIPtmP7ErIlYS6CtOoJ/l56VHPdLIpRPcvWd9cp3u4=
github.com/aerospike/aerospike-kubernetes-operator v0.0.0-20250113070037-b07a5f20edcb/go.mod h1:9pPcjruGGrh9lYq8VWeoXM3+exqe93XLTc7RjlGmZIg=
github.com/aerospike/aerospike-management-lib v1.5.1-0.20250106091653-f0c86baa6cd7 h1:lhccxfqnvqdSNnpxdM4xjUnp8AzHsUKKqJPXRKIgfsw=
github.com/aerospike/aerospike-management-lib v1.5.1-0.20250106091653-f0c86baa6cd7/go.mod h1:hsEptY/AmTmHoJnItJNmfJ4yCMG8LIB8YPnIpIyvGXI=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ=
Expand Down
15 changes: 8 additions & 7 deletions pkg/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"net"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -321,9 +322,9 @@ func getHostIPS(ctx context.Context, k8sClient client.Client, hostIP string) (
matchFound = true
}

if add.Type == corev1.NodeInternalIP {
if add.Type == corev1.NodeInternalIP && net.ParseIP(add.Address).To4() != nil {
nodeInternalIP = add.Address
} else if add.Type == corev1.NodeExternalIP {
} else if add.Type == corev1.NodeExternalIP && net.ParseIP(add.Address).To4() != nil {
nodeExternalIP = add.Address
}
}
Expand Down Expand Up @@ -377,14 +378,14 @@ func parseCustomNetworkIP(networkType asdbv1.AerospikeNetworkType,
networkSet := sets.NewString(networks...)

for idx := range netStatuses {
net := &netStatuses[idx]
if networkSet.Has(net.Name) {
if len(net.IPs) == 0 {
network := &netStatuses[idx]
if networkSet.Has(network.Name) {
if len(network.IPs) == 0 {
return networkIPs, fmt.Errorf("ips list empty for network %s in pod annotations key %s",
net.Name, networkStatusAnnotation)
network.Name, networkStatusAnnotation)
}

networkIPs = append(networkIPs, net.IPs...)
networkIPs = append(networkIPs, network.IPs...)
}
}

Expand Down

0 comments on commit 23cd711

Please sign in to comment.