Skip to content

OCPBUGS-62700: Fix VolumeSnapshot table sorting#16200

Open
stefanonardo wants to merge 1 commit intoopenshift:mainfrom
stefanonardo:OCPBUGS-62700
Open

OCPBUGS-62700: Fix VolumeSnapshot table sorting#16200
stefanonardo wants to merge 1 commit intoopenshift:mainfrom
stefanonardo:OCPBUGS-62700

Conversation

@stefanonardo
Copy link

@stefanonardo stefanonardo commented Mar 26, 2026

Summary

  • Fixed Status, Size, and Source column sorting in VolumeSnapshot table
  • Fixed Status and Size column sorting in VolumeSnapshotContent table
  • Corrected TypeScript types to distinguish string vs number restoreSize values
  • Refactored volumeSnapshotStatus to shared location and renamed to snapshotStatus

Problem

The Status, Size, and Source columns in the VolumeSnapshot table and Status and Size columns in VolumeSnapshotContent table were not sorting correctly. The columns referenced non-existent sort field names (like 'volumeSnapshotSize') instead of using function wrappers with the sorts registry.

Additionally, TypeScript types incorrectly defined restoreSize as a number for both VolumeSnapshot and VolumeSnapshotContent, when in reality VolumeSnapshot uses Kubernetes quantity strings (e.g., "1Gi") and VolumeSnapshotContent uses integer bytes.

Changes

Sorting fix:

  • Updated sort columns to use inline wrapper functions: (data, direction) => data.sort(sortResourceByValue(direction, sorts.functionName))
  • Added volumeSnapshotStatus, volumeSnapshotSize, volumeSnapshotContentSize, and volumeSnapshotSource to the sorts registry in table.tsx
  • Fixed TypeScript types to correctly represent VolumeSnapshot.status.restoreSize as string and VolumeSnapshotContent.status.restoreSize as number
  • Added snapshotContentSize() utility function to handle VolumeSnapshotContent size sorting
  • Removed dead code from useConsoleDataViewData.tsx (redundant string sort check that was never reached)

Refactoring:

  • Moved volumeSnapshotStatus from @console/app/src/status to @console/shared/src/sorts/snapshot
  • Renamed to snapshotStatus for consistency with other snapshot utilities (snapshotSize, snapshotSource, snapshotContentSize)
  • Updated all imports across 9 files to use the new shared location
  • Maintained backwards compatibility by re-exporting from old location

Test plan

  • Navigate to Storage → VolumeSnapshots in the OpenShift console
  • Create test snapshots with different sizes and statuses
  • Click Status column header and verify snapshots sort alphabetically by status
  • Click Size column header and verify snapshots sort numerically by size (ascending/descending)
  • Click Source column header and verify snapshots sort alphabetically by source PVC name
  • Navigate to VolumeSnapshotContents tab and verify Status and Size sorting works

🤖 Generated with Claude Code

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 26, 2026
@openshift-ci-robot
Copy link
Contributor

@stefanonardo: This pull request references Jira Issue OCPBUGS-62700, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

  • Fixed Status, Size, and Source column sorting in VolumeSnapshot table
  • Fixed Status and Size column sorting in VolumeSnapshotContent table
  • Corrected TypeScript types to distinguish string vs number restoreSize values

Problem

The Status, Size, and Source columns in the VolumeSnapshot table and Status and Size columns in VolumeSnapshotContent table were not sorting correctly. The columns referenced non-existent sort field names (like 'volumeSnapshotSize') instead of using function wrappers with the sorts registry.

Additionally, TypeScript types incorrectly defined restoreSize as a number for both VolumeSnapshot and VolumeSnapshotContent, when in reality VolumeSnapshot uses Kubernetes quantity strings (e.g., "1Gi") and VolumeSnapshotContent uses integer bytes.

Changes

  • Updated sort columns to use inline wrapper functions: (data, direction) => data.sort(sortResourceByValue(direction, sorts.functionName))
  • Added volumeSnapshotStatus, volumeSnapshotSize, volumeSnapshotContentSize, and volumeSnapshotSource to the sorts registry in table.tsx
  • Fixed TypeScript types to correctly represent VolumeSnapshot.status.restoreSize as string and VolumeSnapshotContent.status.restoreSize as number
  • Added snapshotContentSize() utility function to handle VolumeSnapshotContent size sorting
  • Removed dead code from useConsoleDataViewData.tsx (redundant string sort check that was never reached)

Test plan

  • Navigate to Storage → VolumeSnapshots in the OpenShift console
  • Create test snapshots with different sizes and statuses (or use setup-snapshot-test.sh script)
  • Click Status column header and verify snapshots sort alphabetically by status
  • Click Size column header and verify snapshots sort numerically by size (ascending/descending)
  • Click Source column header and verify snapshots sort alphabetically by source PVC name
  • Navigate to VolumeSnapshotContents tab and verify Status and Size sorting works

🤖 Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from Leo6Leo and TheRealJon March 26, 2026 12:15
@openshift-ci openshift-ci bot added component/core Related to console core functionality component/shared Related to console-shared labels Mar 26, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

This pull request refactors volume snapshot sorting logic across the console application. Type definitions for VolumeSnapshotKind and VolumeSnapshotContentKind were updated to include restoreSize fields in their status objects, with the field removed from the shared VolumeSnapshotStatus type. New sort helpers (snapshotContentSize) and sort map entries (volumeSnapshotStatus, volumeSnapshotContentSize) were added. Column sorting implementations in snapshot-related components were updated to use custom comparator functions instead of static string keys, and the generic data view sorting logic was simplified to remove a redundant sorting branch.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
frontend/public/components/factory/table.tsx (1)

66-66: Avoid coupling shared table utilities to @console/app

Line 66 makes frontend/public/components/factory/table.tsx depend on @console/app/src/status, which inverts layering for shared infrastructure. Prefer moving the status value getter to a shared module (e.g., @console/shared/src/sorts/snapshot) or defining it locally in this layer.

As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

Also applies to: 95-96

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/public/components/factory/table.tsx` at line 66, The import of
volumeSnapshotStatus from `@console/app/src/status` in table.tsx couples shared
table utilities to a higher-level package; remove that import and either (a)
move the status value getter (volumeSnapshotStatus) into a shared module (e.g.,
create and export it from a new or existing shared sorts/util module) and import
it from that shared location, or (b) define the volumeSnapshotStatus getter
locally in frontend/public/components/factory/table.tsx where it’s used
(referencing the symbol volumeSnapshotStatus and the usages around lines 95–96)
so the table layer no longer depends on `@console/app`; update the import sites to
the new shared path or local definition and ensure tests/types still pass.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@frontend/public/components/factory/table.tsx`:
- Line 66: The import of volumeSnapshotStatus from `@console/app/src/status` in
table.tsx couples shared table utilities to a higher-level package; remove that
import and either (a) move the status value getter (volumeSnapshotStatus) into a
shared module (e.g., create and export it from a new or existing shared
sorts/util module) and import it from that shared location, or (b) define the
volumeSnapshotStatus getter locally in
frontend/public/components/factory/table.tsx where it’s used (referencing the
symbol volumeSnapshotStatus and the usages around lines 95–96) so the table
layer no longer depends on `@console/app`; update the import sites to the new
shared path or local definition and ensure tests/types still pass.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b8834ae4-122f-404b-ba16-65cd841762c8

📥 Commits

Reviewing files that changed from the base of the PR and between f2cf862 and 29ba6d5.

📒 Files selected for processing (6)
  • frontend/packages/console-app/src/components/data-view/useConsoleDataViewData.tsx
  • frontend/packages/console-app/src/components/volume-snapshot/volume-snapshot-content.tsx
  • frontend/packages/console-app/src/components/volume-snapshot/volume-snapshot.tsx
  • frontend/packages/console-shared/src/sorts/snapshot.ts
  • frontend/public/components/factory/table.tsx
  • frontend/public/module/k8s/types.ts
💤 Files with no reviewable changes (1)
  • frontend/packages/console-app/src/components/data-view/useConsoleDataViewData.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/packages/console-app/src/components/volume-snapshot/volume-snapshot-content.tsx
  • frontend/packages/console-app/src/components/volume-snapshot/volume-snapshot.tsx
  • frontend/packages/console-shared/src/sorts/snapshot.ts
  • frontend/public/components/factory/table.tsx
  • frontend/public/module/k8s/types.ts
🔇 Additional comments (5)
frontend/public/module/k8s/types.ts (1)

1087-1105: Type split for restoreSize looks correct

Good change: VolumeSnapshotKind now models quantity strings, while VolumeSnapshotContentKind models byte counts numerically, which matches the intended sort behavior.

frontend/packages/console-shared/src/sorts/snapshot.ts (1)

13-15: snapshotContentSize is a solid addition

Defaulting to 0 keeps sorting deterministic when status.restoreSize is missing.

frontend/public/components/factory/table.tsx (1)

98-99: volumeSnapshotContentSize sort getter is correctly wired

This gives the content table a numeric size value path consistent with the new type updates.

frontend/packages/console-app/src/components/volume-snapshot/volume-snapshot.tsx (1)

170-172: Value-based sort functions fix the broken columns

The new sortResourceByValue(direction, sorts.*) usage correctly fixes Status, Size, and Source sorting for VolumeSnapshots.

Also applies to: 177-179, 184-186

frontend/packages/console-app/src/components/volume-snapshot/volume-snapshot-content.tsx (1)

120-122: Status and Size sorting updates look correct

Using sortResourceByValue with sorts.volumeSnapshotStatus and sorts.volumeSnapshotContentSize is the right fix for VolumeSnapshotContent sorting.

Also applies to: 127-129

Copy link
Contributor

@cajieh cajieh left a comment

Choose a reason for hiding this comment

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

lgtm

import { displayDurationInWords } from '../utils/build-utils';
import { useTableData } from './table-data-hook';
import TableHeader from './Table/TableHeader';
import { volumeSnapshotStatus } from '@console/app/src/status';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This import (@console/internal → @console/app) creates improper layering. While it matches existing patterns in table-filters.ts, we should consider moving volumeSnapshotStatus() to "@console/shared" to resolve the dependency cycle, and then, import it from there.

The Status, Size, and Source columns in the VolumeSnapshot table and
Status and Size columns in VolumeSnapshotContent table were not sorting
correctly because they referenced non-existent sort field names instead
of using the sorts registry.
@openshift-ci openshift-ci bot added the component/dashboard Related to dashboard label Mar 26, 2026
@cajieh
Copy link
Contributor

cajieh commented Mar 26, 2026

/lgtm
/verified later @yapei

@openshift-ci-robot openshift-ci-robot added verified-later verified Signifies that the PR passed pre-merge verification criteria labels Mar 26, 2026
@openshift-ci-robot
Copy link
Contributor

@cajieh: This PR has been marked to be verified later by @yapei.

Details

In response to this:

/lgtm
/verified later @yapei

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 26, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 26, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cajieh, stefanonardo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 26, 2026
@cajieh
Copy link
Contributor

cajieh commented Mar 26, 2026

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 26, 2026
@openshift-ci-robot
Copy link
Contributor

@cajieh: This pull request references Jira Issue OCPBUGS-62700, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/dashboard Related to dashboard component/shared Related to console-shared jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria verified-later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants