Skip to content

fix: address linting alerts#2393

Open
kristina-solovyova wants to merge 1 commit intomainfrom
03-24-fix_address_linting_alerts
Open

fix: address linting alerts#2393
kristina-solovyova wants to merge 1 commit intomainfrom
03-24-fix_address_linting_alerts

Conversation

@kristina-solovyova
Copy link
Collaborator

No description provided.

@github-actions
Copy link

github-actions bot commented Mar 24, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA fec9efd.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@kristina-solovyova kristina-solovyova marked this pull request as ready for review March 24, 2026 09:49
@kristina-solovyova kristina-solovyova requested a review from a team as a code owner March 24, 2026 09:49
Copilot AI review requested due to automatic review settings March 24, 2026 09:49
Copy link
Collaborator Author


How to use the Graphite Merge Queue

Add the label main-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link

claude bot commented Mar 24, 2026

Claude finished @kristina-solovyova's task in 1m 34s —— View job


Code Review

  • Gather context
  • Review changed files
  • Post feedback

Overall this is a solid linting cleanup. Most changes are style improvements or correct patterns. A few items worth noting:

Correctness fixes (most important)

internal/services/discovery/discovery.go contains two important bug fixes for loop variable capture:

  • GetClusterByUID (line ~317): for i := range clustersList.Items + &clustersList.Items[i] instead of &cluster from a range variable — correct fix, the old code would yield dangling/aliased pointers
  • GetWekaClientsForCluster (line ~492): same pattern, &clientsList.Items[i] — correct fix

Error propagation improvement

GetClusterContainers now returns (error) instead of silently swallowing it. All 4 callers have been updated to handle the error. This is a meaningful behavioral improvement — previously, k8s API failures would silently produce empty container lists.

Concerns

  1. .golangci.yaml — broad test file suppressions (errcheck, gocritic, ineffassign, staticcheck, unused suppressed for all _test.go files). This is quite broad and could hide real issues like unchecked errors in test setup code. It would be safer to fix the specific test file issues rather than suppress wholesale. Fix this →

  2. internal/services/discovery/discovery.go:322errors.New("Cluster not found") still uses a capital C, inconsistent with the error casing fix in pod.go ("weka container not found in pod" was lowercased). Minor, but worth making consistent.

  3. ComputeCapacityBasedHugepages (hugepages.go:75)ctx is discarded (_, logger, end := ...). This is fine since ctx isn't passed to any child calls in this function, but it means the span won't be linked as a parent if any downstream calls are added. Low risk given the current function body, just worth being aware of.

Clean removals confirmed

  • getBoolEnv, getFloatEnvOrDefault, getDurationEnv — confirmed unused across the codebase, safe to remove
  • getHugePagesOffset method on PodFactory — confirmed unused, safe to remove

Minor style improvements are all correct:

  • else after return removed ✓
  • if/else if/elseswitch
  • Multiple append calls merged ✓
  • strings.Join([]string{a, b}, "")a + b
  • container.ObjectMeta.Labelscontainer.Labels
  • Import grouping (stdlib / k8s / internal) ✓

Copy link

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 addresses Go lint warnings across the operator by tightening up API/error handling, fixing common Go pitfalls (range-variable pointers, shadowing), and applying small refactors for cleaner code.

Changes:

  • Fix pointer-to-range-variable patterns and variable shadowing in several controllers/services.
  • Make discovery.GetClusterContainers return an error (instead of silently discarding it) and update call sites accordingly.
  • Refactor a few blocks to satisfy linters (ineffassign/unused, simplified returns, import grouping) and update golangci-lint exclusions.

Reviewed changes

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

Show a summary per file
File Description
internal/services/discovery/discovery.go Removes duplicate util import, simplifies logic, fixes pointer-to-range-variable bug, and propagates container-listing errors.
internal/controllers/wekacontainer/funcs_getters.go Handles new GetClusterContainers error return.
internal/controllers/wekacluster/funcs_helpers.go Handles new GetClusterContainers error return.
internal/controllers/wekaclient/client_reconciler_loop.go Fetches cluster containers with error handling; fixes err shadowing; removes now-unneeded helper.
internal/controllers/resources/pod.go Refactors slice appends and minor cleanups to satisfy lint.
internal/controllers/operations/trace_session.go Groups imports; handles new GetClusterContainers error return.
internal/controllers/allocator/hugepages.go Simplifies branching and avoids ineffectual ctx assignment from instrumentation span helper.
internal/config/env.go Removes unused env helpers and minor signature cleanup.
.golangci.yaml Adds exclusions for several linters in _test.go files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@graphite-app
Copy link

graphite-app bot commented Mar 24, 2026

Graphite Automations

"Add anton/matt/sergey/kristina as reviwers on operator PRs" took an action on this PR • (03/24/26)

2 reviewers were added to this PR based on Anton Bykov's automation.

@kristina-solovyova kristina-solovyova force-pushed the 03-24-fix_address_linting_alerts branch from 810204f to fec9efd Compare March 25, 2026 12:00
@claude
Copy link

claude bot commented Mar 25, 2026

Claude finished @kristina-solovyova's task in 46s —— View job


No changes since the last review (tip commit fec9efd6 is unchanged). See the previous review below for full feedback.


Code Review

Overall this is a solid linting cleanup. Most changes are style improvements or correct patterns. A few items worth noting:

Correctness fixes (most important)

internal/services/discovery/discovery.go contains two important bug fixes for loop variable capture:

  • GetClusterByUID (line ~317): for i := range clustersList.Items + &clustersList.Items[i] instead of &cluster from a range variable — correct fix, the old code would yield dangling/aliased pointers
  • GetWekaClientsForCluster (line ~492): same pattern, &clientsList.Items[i] — correct fix

Error propagation improvement

GetClusterContainers now returns (error) instead of silently swallowing it. All 4 callers have been updated to handle the error. This is a meaningful behavioral improvement — previously, k8s API failures would silently produce empty container lists.

Concerns

  1. .golangci.yaml — broad test file suppressions (errcheck, gocritic, ineffassign, staticcheck, unused suppressed for all _test.go files). This is quite broad and could hide real issues like unchecked errors in test setup code. It would be safer to fix the specific test file issues rather than suppress wholesale. Fix this →

  2. internal/services/discovery/discovery.go:322errors.New("Cluster not found") still uses a capital C, inconsistent with the error casing fix in pod.go ("weka container not found in pod" was lowercased). Minor, but worth making consistent.

  3. ComputeCapacityBasedHugepages (hugepages.go:75)ctx is discarded (_, logger, end := ...). This is fine since ctx isn't passed to any child calls in this function, but it means the span won't be linked as a parent if any downstream calls are added. Low risk given the current function body, just worth being aware of.

Clean removals confirmed

  • getBoolEnv, getFloatEnvOrDefault, getDurationEnv — confirmed unused across the codebase, safe to remove
  • getHugePagesOffset method on PodFactory — confirmed unused, safe to remove

Minor style improvements are all correct:

  • else after return removed ✓
  • if/else if/elseswitch
  • Multiple append calls merged ✓
  • strings.Join([]string{a, b}, "")a + b
  • container.ObjectMeta.Labelscontainer.Labels
  • Import grouping (stdlib / k8s / internal) ✓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants