Skip to content

Conversation

sthaha
Copy link
Collaborator

@sthaha sthaha commented Jun 19, 2025

This change breaks down the Refresh method into smaller functions following Single Responsibility Principle. Changes are ..

  • refreshProcesses: categorizes processes during initial scan
  • refreshContainers/refreshVMs: build workload-specific collections
  • refreshPods: handles container-to-pod mapping (depends on containers)
  • refreshNode: calculates node-level aggregations

Note that this change introduces parallel execution using goroutines for independent workloads (containers+pods, VMs, and node calculations) while maintaining proper dependency ordering.

Also adds test coverage for concurrency testing, missing coverage and error handling scenarios.

…l execution

This change breaks down the Refresh method into smaller functions
following Single Responsibility Principle. Changes are ..

- refreshProcesses: categorizes processes during initial scan
- refreshContainers/refreshVMs: build workload-specific collections
- refreshPods: handles container-to-pod mapping (depends on containers)
- refreshNode: calculates node-level aggregations

Note that this change introduces parallel execution using goroutines for
independent workloads (containers+pods, VMs, and node calculations) while
maintaining proper dependency ordering.

Also adds test coverage for concurrency testing, missing coverage and error handling
scenarios.

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
@github-actions github-actions bot added the refactor Code refactoring without changing functionality label Jun 19, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the Refresh method of the resource informer into focused functions that handle processes, containers, VMs, pods, and node updates independently while using parallel execution to improve performance. Key changes include splitting the refresh logic into granular helper functions and introducing goroutines for concurrent execution, as well as expanding unit test coverage for various refresh scenarios.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/resource/vm_test.go Added tests for VM ID extraction and VM name extraction functions.
internal/resource/procfs_reader_test.go Enhanced and additional tests covering informer initialization and error handling.
internal/resource/pod_test.go Introduced tests for Pod cloning functionality.
internal/resource/informer.go Refactored refresh logic by splitting into multiple functions and using parallel execution.
Comments suppressed due to low confidence (2)

internal/resource/informer.go:297

  • The variable 'pod' is referenced but not defined; it seems likely that 'cntrInfo.PodID' should be used instead. Please update the code to reference the correct pod identifier.
		pod := &Pod{

internal/resource/informer.go:290

  • The 'resetCPUTime' variable is declared inside the if-else blocks, limiting its scope. Declare 'resetCPUTime' before the conditional block so it can be used when updating the pod cache.
		}

Copy link

codecov bot commented Jun 19, 2025

Codecov Report

Attention: Patch coverage is 95.55556% with 6 lines in your changes missing coverage. Please review.

Project coverage is 92.28%. Comparing base (cc8d73c) to head (4934d7e).
Report is 7 commits behind head on reboot.

Files with missing lines Patch % Lines
internal/resource/informer.go 95.55% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           reboot    #2170      +/-   ##
==========================================
+ Coverage   91.40%   92.28%   +0.87%     
==========================================
  Files          36       36              
  Lines        3491     3551      +60     
==========================================
+ Hits         3191     3277      +86     
+ Misses        232      212      -20     
+ Partials       68       62       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sthaha sthaha changed the title refactor(resource): split Refresh into focused functions with parallel execution refactor(resource): split Refresh into smaller functions with parallel execution Jun 19, 2025
@vimalk78 vimalk78 merged commit 63fc7f6 into sustainable-computing-io:reboot Jun 19, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code refactoring without changing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants