Skip to content

Commit 4f49c34

Browse files
committed
address review comments
1 parent 3d7f16a commit 4f49c34

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fmt:
8080
.PHONY: test
8181
# we say code is not worth testing unless it's formatted
8282
test: fmt codegen
83-
go test -v -coverpkg=./sentry,./cloud/linode/client,./cloud/linode/firewall,./cloud/linode,.cloud/nodeipam,.cloud/nodeipam/ipam -coverprofile ./coverage.out -cover ./sentry/... ./cloud/... $(TEST_ARGS)
83+
go test -v -coverpkg=./sentry,./cloud/linode/client,./cloud/linode/firewall,./cloud/linode,./cloud/nodeipam,./cloud/nodeipam/ipam -coverprofile ./coverage.out -cover ./sentry/... ./cloud/... $(TEST_ARGS)
8484

8585
.PHONY: build-linux
8686
build-linux: codegen

cloud/nodeipam/ipam/cloud_allocator.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ type cloudAllocator struct {
6565
// queues are where incoming work is placed to de-dup and to allow "easy"
6666
// rate limited requeues on errors
6767
queue workqueue.TypedRateLimitingInterface[any]
68+
69+
// nodeCIDRMaskSizeIPv6 is the mask size for the IPv6 CIDR assigned to nodes.
70+
nodeCIDRMaskSizeIPv6 int
6871
}
6972

7073
const providerIDPrefix = "linode://"
7174

7275
var (
73-
_ CIDRAllocator = &cloudAllocator{}
74-
nodeCIDRMaskSizeIPv6 = 112
76+
_ CIDRAllocator = &cloudAllocator{}
7577
)
7678

7779
// NewLinodeCIDRAllocator returns a CIDRAllocator to allocate CIDRs for node
@@ -95,20 +97,17 @@ func NewLinodeCIDRAllocator(ctx context.Context, linodeClient linode.Client, cli
9597
return nil, err
9698
}
9799

98-
// set nodeCIDRMaskSizeIPv6 to the second mask size
99-
// this is used to assign the nodeCIDR for ipv6 addresses
100-
nodeCIDRMaskSizeIPv6 = allocatorParams.NodeCIDRMaskSizes[1]
101-
102100
ca := &cloudAllocator{
103-
client: client,
104-
linodeClient: linodeClient,
105-
clusterCIDR: allocatorParams.ClusterCIDRs[0],
106-
cidrSet: cidrSet,
107-
nodeLister: nodeInformer.Lister(),
108-
nodesSynced: nodeInformer.Informer().HasSynced,
109-
broadcaster: eventBroadcaster,
110-
recorder: recorder,
111-
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultTypedControllerRateLimiter[any](), "cidrallocator_node"),
101+
client: client,
102+
linodeClient: linodeClient,
103+
clusterCIDR: allocatorParams.ClusterCIDRs[0],
104+
cidrSet: cidrSet,
105+
nodeLister: nodeInformer.Lister(),
106+
nodesSynced: nodeInformer.Informer().HasSynced,
107+
broadcaster: eventBroadcaster,
108+
recorder: recorder,
109+
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultTypedControllerRateLimiter[any](), "cidrallocator_node"),
110+
nodeCIDRMaskSizeIPv6: allocatorParams.NodeCIDRMaskSizes[1],
112111
}
113112

114113
if allocatorParams.ServiceCIDR != nil {
@@ -302,7 +301,7 @@ func (c *cloudAllocator) occupyCIDRs(ctx context.Context, node *v1.Node) error {
302301
for idx, cidr := range node.Spec.PodCIDRs {
303302
_, podCIDR, err := netutils.ParseCIDRSloppy(cidr)
304303
if err != nil {
305-
return fmt.Errorf("failed to parse node %s, CIDR %s", node.Name, node.Spec.PodCIDR)
304+
return fmt.Errorf("failed to parse node %s, CIDR %s", node.Name, cidr)
306305
}
307306
// IPv6 CIDRs are allocated from node specific ranges
308307
// We don't track them in the cidrSet
@@ -366,7 +365,7 @@ func (c *cloudAllocator) allocateIPv6CIDR(ctx context.Context, node *v1.Node) (*
366365
return nil, fmt.Errorf("failed parsing ipv6 range %s: %w", ipv6Range, err)
367366
}
368367

369-
mask := net.CIDRMask(nodeCIDRMaskSizeIPv6, 128)
368+
mask := net.CIDRMask(c.nodeCIDRMaskSizeIPv6, 128)
370369
ipv6Embedded := &net.IPNet{
371370
IP: ip.Mask(mask),
372371
Mask: mask,

go.mod

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ require (
2525
k8s.io/utils v0.0.0-20250502105355-0f33e8f1c979
2626
)
2727

28-
require sigs.k8s.io/randfill v1.0.0 // indirect
28+
require (
29+
github.com/onsi/gomega v1.35.1 // indirect
30+
sigs.k8s.io/randfill v1.0.0 // indirect
31+
)
2932

3033
require (
3134
cel.dev/expr v0.19.1 // indirect
@@ -96,7 +99,6 @@ require (
9699
github.com/modern-go/reflect2 v1.0.2 // indirect
97100
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
98101
github.com/oklog/ulid v1.3.1 // indirect
99-
github.com/onsi/gomega v1.35.1 // indirect
100102
github.com/opencontainers/go-digest v1.0.0 // indirect
101103
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
102104
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
@@ -160,7 +162,7 @@ require (
160162
gopkg.in/yaml.v3 v3.0.1 // indirect
161163
k8s.io/apiextensions-apiserver v0.33.0 // indirect
162164
k8s.io/apiserver v0.33.2 // indirect
163-
k8s.io/component-helpers v0.33.2 // indirect
165+
k8s.io/component-helpers v0.33.2
164166
k8s.io/controller-manager v0.33.2 // indirect
165167
k8s.io/kms v0.33.2 // indirect
166168
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect

0 commit comments

Comments
 (0)