Skip to content

Commit

Permalink
Fix malformatted labels for IPv6 VirtualIPs (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
ushabelgur authored Sep 13, 2024
1 parent e79bffe commit 4fd6c8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/registry/ip/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package ip
import (
"context"
"fmt"
"strings"

"github.com/ironcore-dev/ironcore-net/api/core/v1alpha1"
"github.com/ironcore-dev/ironcore-net/apimachinery/api/net"
Expand Down Expand Up @@ -64,7 +65,7 @@ func (r *REST) beginCreate(ctx context.Context, obj runtime.Object, opts *metav1
ip.Spec.IP = addr
}
metav1.SetMetaDataLabel(&ip.ObjectMeta, v1alpha1.IPFamilyLabel, string(alloc.IPFamily()))
metav1.SetMetaDataLabel(&ip.ObjectMeta, v1alpha1.IPIPLabel, addr.String())
metav1.SetMetaDataLabel(&ip.ObjectMeta, v1alpha1.IPIPLabel, strings.ReplaceAll(addr.String(), ":", "-"))

return func(ctx context.Context, success bool) {
if success {
Expand Down
3 changes: 2 additions & 1 deletion internal/registry/ipallocator/ipallocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"net/netip"
"strings"
"time"

"github.com/ironcore-dev/ironcore-net/api/core/v1alpha1"
Expand Down Expand Up @@ -89,7 +90,7 @@ func (a *Allocator) allocate(namespace string, claimRef v1alpha1.IPClaimRef, ip
func (a *Allocator) getIPFromLister(namespace string, addr netip.Addr) (*v1alpha1.IP, error) {
ips, err := a.ipLister.IPs(namespace).List(labels.SelectorFromSet(labels.Set{
v1alpha1.IPFamilyLabel: string(a.ipFamily),
v1alpha1.IPIPLabel: addr.String(),
v1alpha1.IPIPLabel: strings.ReplaceAll(addr.String(), ":", "-"),
}))
if err != nil {
return nil, err
Expand Down

0 comments on commit 4fd6c8b

Please sign in to comment.