diff --git a/Dockerfile b/Dockerfile index 45a942c..a863d0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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. diff --git a/go.mod b/go.mod index 5ced1cd..6c67907 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go.sum b/go.sum index 5badb00..95db62d 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/utils.go b/pkg/utils.go index 4728c7b..eb6dd24 100644 --- a/pkg/utils.go +++ b/pkg/utils.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "net" "os" "path/filepath" "strconv" @@ -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 } } @@ -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...) } }