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

Bug 1877065: Fixing wrong DNS-1123 name for some IPv6 addresses #29

Merged
merged 1 commit into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/whereabouts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ var _ = Describe("Whereabouts operations", func() {
expectedAddress = "2001::1/116"

AllocateAndReleaseAddressesTest(ipVersion, ipRange, ipGateway, []string{expectedAddress}, whereaboutstypes.DatastoreETCD)

})

It("allocates and releases addresses on ADD/DEL with a Kubernetes backend", func() {
Expand Down Expand Up @@ -159,6 +160,17 @@ var _ = Describe("Whereabouts operations", func() {
AllocateAndReleaseAddressesTest(ipVersion, ipRange, ipGateway, []string{expectedAddress}, whereaboutstypes.DatastoreKubernetes)
})

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

ipVersion := "6"
ipRange := "fd00:0:0:10:0:0:3:1-fd00:0:0:10:0:0:3:6/64"
ipGateway := "2001::f:1"
expectedAddress := "fd00:0:0:10:0:0:3:1/64"

AllocateAndReleaseAddressesTest(ipVersion, ipRange, ipGateway, []string{expectedAddress}, whereaboutstypes.DatastoreKubernetes)

})

It("excludes a range of addresses", func() {
const ifname string = "eth0"
const nspath string = "/some/where"
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func toAllocationMap(reservelist []whereaboutstypes.IPReservation, firstip net.I
// GetIPPool returns a storage.IPPool for the given range
func (i *KubernetesIPAM) GetIPPool(ctx context.Context, ipRange string) (IPPool, error) {
// v6 filter
normalized := strings.ReplaceAll(ipRange, "::", "-")
normalized := strings.ReplaceAll(ipRange, ":", "-")
// replace subnet cidr slash
normalized = strings.ReplaceAll(normalized, "/", "-")

Expand Down Expand Up @@ -192,7 +192,7 @@ func (p *KubernetesIPPool) Update(ctx context.Context, reservations []whereabout
// add additional tests to the patch
ops := []jsonpatch.Operation{
// ensure patch is applied to appropriate resource version only
jsonpatch.Operation{Operation: "test", Path: "/metadata/resourceVersion", Value: orig.ObjectMeta.ResourceVersion},
{Operation: "test", Path: "/metadata/resourceVersion", Value: orig.ObjectMeta.ResourceVersion},
}
for _, o := range patch {
// safeguard add ops -- "add" will update existing paths, this "test" ensures the path is empty
Expand Down