diff --git a/pkg/controllers/nodeipam/ipam/cidr_allocator.go b/pkg/controllers/nodeipam/ipam/cidr_allocator.go index f825b67ba0d..22f55ee739c 100644 --- a/pkg/controllers/nodeipam/ipam/cidr_allocator.go +++ b/pkg/controllers/nodeipam/ipam/cidr_allocator.go @@ -49,6 +49,8 @@ import ( // cidrs are reserved, then node resource is patched with them // this type holds the reservation info for a node + +// NodeReservedCIDRs holds the allocated CIDRs type NodeReservedCIDRs struct { allocatedCIDRs []*net.IPNet nodeName string diff --git a/pkg/controllers/nodeipam/ipam/ipv6_allocator.go b/pkg/controllers/nodeipam/ipam/ipv6_allocator.go index 29abda40f8f..f5e43ec893b 100644 --- a/pkg/controllers/nodeipam/ipam/ipv6_allocator.go +++ b/pkg/controllers/nodeipam/ipam/ipv6_allocator.go @@ -51,11 +51,12 @@ const ( ) // IPv6CIDRAllocator is an interface implemented by things that know how -// to allocate CIDR for nodes. +// to allocate IPv6 CIDRs. type IPv6CIDRAllocator interface { Run(stopCh <-chan struct{}) } +// IPv6RangeAllocator allocates IPv6 CIDRs type IPv6RangeAllocator struct { nodeInformer coreinformers.NodeInformer kubeClient clientset.Interface @@ -83,6 +84,7 @@ func (w workItem) String() string { return fmt.Sprintf("[Node: %s, RequeuingCount: %d, EnqueueTime: %s]", w.node.GetName(), w.requeuingCount, w.enqueueTime) } +// NewIPv6RangeAllocator returns an IPv6CIDRAllocator func NewIPv6RangeAllocator(kubeClient clientset.Interface, nodeInformer informers.NodeInformer, awsCloud *awsv1.Cloud, rateLimiter workqueue.RateLimiter, rateLimitEnabled bool, nodeMonitorPeriod time.Duration) (IPv6CIDRAllocator, error) { ra6 := &IPv6RangeAllocator{ nodeInformer: nodeInformer, diff --git a/pkg/controllers/nodeipam/ipam/metrics.go b/pkg/controllers/nodeipam/ipam/metrics.go index bd3a9d8e918..96842837624 100644 --- a/pkg/controllers/nodeipam/ipam/metrics.go +++ b/pkg/controllers/nodeipam/ipam/metrics.go @@ -44,7 +44,7 @@ var ( []string{"error_type", "instance_id"}) ) -// registerMetrics registers nodeipam-controller metrics. +// RegisterMetrics registers nodeipam-controller metrics. func RegisterMetrics() { register.Do(func() { legacyregistry.MustRegister(workItemDuration) diff --git a/pkg/controllers/nodeipam/ipam/util.go b/pkg/controllers/nodeipam/ipam/util.go index 3cc4c0277f4..3fc7f90e6f9 100644 --- a/pkg/controllers/nodeipam/ipam/util.go +++ b/pkg/controllers/nodeipam/ipam/util.go @@ -28,16 +28,19 @@ import ( "k8s.io/klog/v2" ) +// NodePatch holds the fields to patch type NodePatch struct { Spec *NodePatchSpec `json:"spec,omitempty"` Metadata *NodePatchMetadata `json:"metadata,omitempty"` } +// NodePatchSpec holds the spec for the node patch operation type NodePatchSpec struct { PodCIDR string `json:"podCIDR,omitempty"` PodCIDRs []string `json:"podCIDRs,omitempty"` } +// NodePatchMetadata holds the metadata for the node patch operation type NodePatchMetadata struct { Labels map[string]*string `json:"labels,omitempty"` } @@ -52,14 +55,14 @@ func PatchNodePodCIDRs(kubeClient clientset.Interface, node *v1.Node, cidr []str nodePatch := &NodePatch{ Spec: nodePatchSpec, } - nodePatchJson, err := json.Marshal(nodePatch) + nodePatchJSON, err := json.Marshal(nodePatch) if err != nil { return fmt.Errorf("error building node patch: %v", err) } - klog.V(2).Infof("sending patch for node %q: %q", node.Name, string(nodePatchJson)) + klog.V(2).Infof("sending patch for node %q: %q", node.Name, string(nodePatchJSON)) - _, err = kubeClient.CoreV1().Nodes().Patch(context.TODO(), node.Name, types.StrategicMergePatchType, nodePatchJson, metav1.PatchOptions{}) + _, err = kubeClient.CoreV1().Nodes().Patch(context.TODO(), node.Name, types.StrategicMergePatchType, nodePatchJSON, metav1.PatchOptions{}) if err != nil { return fmt.Errorf("error applying patch to node: %v", err) } diff --git a/pkg/controllers/nodeipam/nodeipam_controller.go b/pkg/controllers/nodeipam/nodeipam_controller.go index e1c10186bc8..67c0a22d270 100644 --- a/pkg/controllers/nodeipam/nodeipam_controller.go +++ b/pkg/controllers/nodeipam/nodeipam_controller.go @@ -58,6 +58,7 @@ const ( // This is a variable instead of a const to enable testing. var nodePollInterval = 10 * time.Second +// Controller is the controller that manages node ipam state. type Controller struct { nodeInformer coreinformers.NodeInformer kubeClient clientset.Interface diff --git a/pkg/controllers/options/nodeipam_controller.go b/pkg/controllers/options/nodeipam_controller.go index 17cbed8ee3c..34bfd32dbb0 100644 --- a/pkg/controllers/options/nodeipam_controller.go +++ b/pkg/controllers/options/nodeipam_controller.go @@ -25,7 +25,7 @@ import ( const ( - // DefaultNodeMaskCIDRIPv4 is default mask size for IPv4 node cidr + // DefaultNodeMaskCIDR is default mask size for IPv4 node cidr DefaultNodeMaskCIDR = int32(24) )