Skip to content

Commit

Permalink
fix linting for nodeipam controller
Browse files Browse the repository at this point in the history
  • Loading branch information
DockToFuture committed Oct 24, 2023
1 parent 21fc159 commit 93424bc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions pkg/controllers/nodeipam/ipam/cidr_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/nodeipam/ipam/ipv6_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/nodeipam/ipam/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions pkg/controllers/nodeipam/ipam/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/nodeipam/nodeipam_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/options/nodeipam_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down

0 comments on commit 93424bc

Please sign in to comment.