Skip to content

Commit

Permalink
Code cleanup in node_reconciler.go
Browse files Browse the repository at this point in the history
Signed-off-by: Patryk Strusiewicz-Surmacki <patryk-pawel.strusiewicz-surmacki@external.telekom.de>
  • Loading branch information
p-strusiewiczsurmacki-mobica committed May 6, 2024
1 parent 5aec635 commit d067a0c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/reconciler/node_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewNodeReconciler(clusterClient client.Client, logger logr.Logger, timeout
}

func (nr *NodeReconciler) reconcileDebounced(ctx context.Context) error {
added, deleted, err := nr.Update(ctx)
added, deleted, err := nr.update(ctx)
if err != nil {
return fmt.Errorf("error updating node reconciler data: %w", err)
}
Expand All @@ -73,14 +73,14 @@ func (nr *NodeReconciler) reconcileDebounced(ctx context.Context) error {
return nil
}

func (nr *NodeReconciler) Update(ctx context.Context) (added, deleted []string, err error) {
func (nr *NodeReconciler) update(ctx context.Context) (added, deleted []string, err error) {
nr.Mutex.Lock()
defer nr.Mutex.Unlock()

timeoutCtx, cancel := context.WithTimeout(ctx, nr.timeout)
defer cancel()

currentNodes, err := nr.listNodes(timeoutCtx)
currentNodes, err := ListNodes(timeoutCtx, nr.client)
if err != nil {
return nil, nil, fmt.Errorf("error listing nodes: %w", err)
}
Expand All @@ -92,10 +92,6 @@ func (nr *NodeReconciler) Update(ctx context.Context) (added, deleted []string,
return added, deleted, nil
}

func (nr *NodeReconciler) listNodes(ctx context.Context) (map[string]*corev1.Node, error) {
return ListNodes(ctx, nr.client)
}

func ListNodes(ctx context.Context, c client.Client) (map[string]*corev1.Node, error) {
// list all nodes
list := &corev1.NodeList{}
Expand Down

0 comments on commit d067a0c

Please sign in to comment.