Skip to content

Conversation

@komer3
Copy link
Contributor

@komer3 komer3 commented Jul 16, 2025

This PR fixes a bug where we were calculating the maxVolumes incorrectly which caused users to not be able to attach max volumes. With this fix, advertised maxVolume should be idempotent.

General:

  • Have you removed all sensitive information, including but not limited to access keys and passwords?
  • Have you checked to ensure there aren't other open or closed Pull Requests for the same bug/feature/question?

Pull Request Guidelines:

  1. Does your submission pass tests?
  2. Have you added tests?
  3. Are you addressing a single feature in this PR?
  4. Are your commits atomic, addressing one change per commit?
  5. Are you following the conventions of the language?
  6. Have you saved your large formatting changes for a different PR, so we can focus on your work?
  7. Have you explained your rationale for why this feature is needed?
  8. Have you linked your PR to an open issue

…ing maxVolumes. Refactor maxVolumeAttachments to be more concise.
@komer3 komer3 requested review from a team as code owners July 16, 2025 17:50
@komer3 komer3 requested review from Copilot and removed request for a team July 16, 2025 17:50
@github-actions github-actions bot added the bugfix for any bug fixes in the changelog. label Jul 16, 2025

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.65%. Comparing base (1b93949) to head (9610f8c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #455      +/-   ##
==========================================
- Coverage   70.69%   70.65%   -0.05%     
==========================================
  Files          24       24              
  Lines        2761     2757       -4     
==========================================
- Hits         1952     1948       -4     
  Misses        681      681              
  Partials      128      128              

☔ 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.

This comment was marked as outdated.

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 fixes a bug in the volume attachment calculation logic by changing how the system counts disks when determining the maximum number of volumes that can be attached to a node. The fix ensures that only appropriate disk types are counted as volumes, preventing users from being unable to attach the maximum number of volumes.

  • Updated disk counting logic to filter by controller type (SCSI/virtio) and vendor (QEMU)
  • Modernized the maxVolumeAttachments function to use Go's built-in min/max functions
  • Added comprehensive e2e tests to validate node volume limits behavior

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/driver/limits.go Core fix - replaced attachedVolumeCount with diskCount and updated filtering logic
internal/driver/nodeserver.go Updated function calls and improved logging for the new disk counting approach
internal/driver/limits_test.go Comprehensive test updates to cover new disk filtering scenarios
internal/driver/nodeserver_test.go Added vendor field to test data to support new filtering logic
tests/e2e/test/node-volume-limit/ New e2e test suite to validate volume limit functionality end-to-end

Comment on lines +29 to +30
// diskCount calculates the number of attached block devices that are not
// being used as Kubernetes PersistentVolumeClaims (PVCs).
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

The comment is misleading. The function actually counts disks that ARE being used (boot/swap disks from QEMU vendor), not those that are NOT being used as PVCs. Based on the code logic, it should describe counting QEMU vendor disks to exclude them from volume capacity calculations.

Suggested change
// diskCount calculates the number of attached block devices that are not
// being used as Kubernetes PersistentVolumeClaims (PVCs).
// diskCount calculates the number of attached block devices that are from
// the vendor "QEMU" and use either the "SCSI" or "virtio" storage controllers.

Copilot uses AI. Check for mistakes.
maxVolumes := maxVolumeAttachments(ns.metadata.Memory) - attachedVolumeCount
log.V(2).Info("functionStatusfully completed")
maxVolumes := maxVolumeAttachments(ns.metadata.Memory) - diskCount
log.V(2).Info("Calculated maxVolumes", "maxVolumes", maxVolumes, "diskCount", diskCount)
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

[nitpick] The log message says 'functionStatusfully completed' was replaced, but 'Calculated maxVolumes' should be 'Successfully calculated maxVolumes' for better clarity and consistency with the previous message style.

Suggested change
log.V(2).Info("Calculated maxVolumes", "maxVolumes", maxVolumes, "diskCount", diskCount)
log.V(2).Info("Successfully calculated maxVolumes", "maxVolumes", maxVolumes, "diskCount", diskCount)

Copilot uses AI. Check for mistakes.
rahulait
rahulait previously approved these changes Jul 17, 2025
Copy link
Contributor

@rahulait rahulait left a comment

Choose a reason for hiding this comment

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

LGTM

@komer3 komer3 merged commit 6f9c4af into main Jul 17, 2025
9 checks passed
@komer3 komer3 deleted the fix-disk-calculation branch July 17, 2025 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix for any bug fixes in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants