Skip to content

Commit

Permalink
Merge pull request #297 from nicklesimba/invalid-ipv6-bz
Browse files Browse the repository at this point in the history
Added trailing 0 to ipv6 ranges that end in ":"
  • Loading branch information
dougbtv authored Feb 8, 2023
2 parents 955f49c + f5469ae commit fd77235
Show file tree
Hide file tree
Showing 39 changed files with 99 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.17.x, 1.18.x]
go-version: [1.19.x]
#goarch: [386, amd64, arm, ppc64le, arm64]
goarch: [amd64, arm64]
os: [ubuntu-latest] #, macos-latest, windows-latest]
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ jobs:
test:
strategy:
matrix:
#go-version: [1.15.x, 1.16.x]
go-version: [1.17.x]
go-version: [1.19.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -18,7 +17,7 @@ jobs:
uses: actions/checkout@v2

- name: Run Revive Action by building from repository
uses: morphy2k/revive-action@v1.4.1
uses: morphy2k/revive-action@v2.4.1
with:
exclude: "./vendor/..."
name: "Revive"
Expand Down Expand Up @@ -69,7 +68,7 @@ jobs:
- name: Set up Go version
uses: actions/setup-go@v1
with:
go-version: 1.17
go-version: 1.19.x

- name: Checkout code into the Go module directory
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17
FROM golang:1.19
ADD . /usr/src/whereabouts
RUN mkdir -p $GOPATH/src/github.com/k8snetworkplumbingwg/whereabouts
WORKDIR $GOPATH/src/github.com/k8snetworkplumbingwg/whereabouts
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17
FROM golang:1.19
ADD . /usr/src/whereabouts

ENV GOARCH "arm64"
Expand Down
27 changes: 25 additions & 2 deletions cmd/whereabouts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io/fs"
"io/ioutil"
"net"
"os"
"strings"
Expand Down Expand Up @@ -145,7 +144,7 @@ var _ = Describe("Whereabouts operations", func() {

BeforeEach(func() {
var err error
tmpDir, err = ioutil.TempDir("/tmp", "whereabouts")
tmpDir, err = os.MkdirTemp("/tmp", "whereabouts")
Expect(err).ToNot(HaveOccurred())
kubeConfigPath = fmt.Sprintf("%s/%s", tmpDir, whereaboutsConfigFile)
Expect(os.WriteFile(kubeConfigPath, kubeconfig(), fs.ModePerm)).To(Succeed())
Expand Down Expand Up @@ -234,6 +233,30 @@ var _ = Describe("Whereabouts operations", func() {
)
})

It("allocates and releases an IPv6 range that ends with zeroes with a Kubernetes backend", func() {

ipVersion := "6"
ipRange := "2001:db8:480:603d:0304:0403:000:0000-2001:db8:480:603d:0304:0403:0000:0004/64"
ipGateway := "2001:db8:480:603d::1"
expectedAddress := "2001:db8:480:603d:0304:0403:000:0000/64"

AllocateAndReleaseAddressesTest(
ipVersion,
ipamConfig(podName, podNamespace, ipRange, ipGateway, kubeConfigPath),
[]string{expectedAddress},
)

ipRange = "2001:db8:5422:0005::-2001:db8:5422:0005:7fff:ffff:ffff:ffff/64"
ipGateway = "2001:db8:5422:0005::1"
expectedAddress = "2001:db8:5422:0005::/64"

AllocateAndReleaseAddressesTest(
ipVersion,
ipamConfig(podName, podNamespace, ipRange, ipGateway, kubeConfigPath),
[]string{expectedAddress},
)
})

It("allocates IPv6 addresses with DNS-1123 conformant naming with a Kubernetes backend", func() {

ipVersion := "6"
Expand Down
2 changes: 1 addition & 1 deletion e2e/client/ippool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func isIPPoolAllocationsEmpty(k8sIPAM *kubeClient.KubernetesIPAM, ipPoolName str
return func() (bool, error) {
ipPool, err := k8sIPAM.GetIPPool(context.Background(), ipPoolName)
noPoolError := fmt.Errorf("k8s pool initialized")
if errors.As(err, &noPoolError) {
if errors.Is(err, noPoolError) {
return true, nil
} else if err != nil {
return false, err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/k8snetworkplumbingwg/whereabouts

go 1.17
go 1.19

require (
github.com/blang/semver v3.5.1+incompatible
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ k8s.io/gengo v0.0.0-20211129171323-c02415ce4185 h1:TT1WdmqqXareKxZ/oNXEUSwKlLiHz
k8s.io/gengo v0.0.0-20211129171323-c02415ce4185/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/fake/clientset_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/fake/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions pkg/client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/clientset/versioned/scheme/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions pkg/client/clientset/versioned/scheme/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/informers/externalversions/factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/client/informers/externalversions/generic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net"
"os"
"strings"
Expand Down Expand Up @@ -246,9 +246,9 @@ func GetFlatIPAM(isControlLoop bool, IPAM *types.IPAMConfig, extraConfigPaths ..

defer jsonFile.Close()

jsonBytes, err := ioutil.ReadAll(jsonFile)
jsonBytes, err := io.ReadAll(jsonFile)
if err != nil {
return flatipam, foundflatfile, fmt.Errorf("LoadIPAMConfig Flatfile (%s) - ioutil.ReadAll error: %s", confpath, err)
return flatipam, foundflatfile, fmt.Errorf("LoadIPAMConfig Flatfile (%s) - io.ReadAll error: %s", confpath, err)
}

if err := json.Unmarshal(jsonBytes, &flatipam.IPAM); err != nil {
Expand Down
Loading

0 comments on commit fd77235

Please sign in to comment.