Skip to content

Conversation

@galkremer1
Copy link
Member

@galkremer1 galkremer1 commented Nov 25, 2025

📝 Description

Jira ticket: CNV-69048

  • Boot order summary shows only the devices with explicit bootOrder property.
  • Saving the changes in the boot order modal adds the bootOrder property to all devices.

🎥 Demo

Before:

Before.mov

After:

after.mov

Summary by CodeRabbit

  • Bug Fixes
    • Consistent boot-order handling so device lists reflect only bootable items with defined order.
  • Behavior Changes
    • Reordering now returns the new device sequence as-is (boot-order metadata is no longer auto-updated in-place).
  • UI
    • Simplified reorder UI rendering while preserving drag-and-drop and delete controls.

✏️ Tip: You can customize this high-level summary in your review settings.

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Nov 25, 2025

@galkremer1: This pull request references CNV-69048 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.21.0" version, but no target version was set.

Details

In response to this:

📝 Description

Jira ticket: CNV-69048

  • Boot order summary shows only the devices with explicit bootOrder property.
  • Saving the changes in the boot order modal adds the bootOrder property to all devices.

🎥 Demo

Before:

Before.mov

After:

after.mov

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
Copy link
Contributor

openshift-ci bot commented Nov 25, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: galkremer1

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 This issue is something we want to fix label Nov 25, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

📝 Walkthrough

Walkthrough

Boot order handling was changed: BootOrderModal now sets bootOrder for devices based on their index; BootOrderModalBody stops mutating bootOrder on reorders and passes the reordered list through; BootOrderSummary filters to only show devices with a defined bootOrder.

Changes

Cohort / File(s) Change Summary
BootOrder summary update
src/utils/components/BootOrder/BootOrderSummary.tsx
Filters sorted bootable devices to include only those with a defined bootOrder before rendering the list.
BootOrder modal assignment
src/utils/components/BootOrderModal/BootOrderModal.tsx
Maps devices to updatedDevices setting bootOrder = index + 1, then derives VM disk/NIC values from that mapped list; retains path ensures but centralizes bootOrder assignment.
BootOrder modal body reorder behavior
src/utils/components/BootOrderModal/BootOrderModalBody.tsx
Reordering (onDrop) no longer mutates per-item bootOrder; it passes the reordered array to onChange as-is and rendering was flattened (NIC labeling/explicit bootOrder mapping removed).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to bootOrder assignment correctness in BootOrderModal.tsx (index → bootOrder).
  • Verify consumers expect reordered arrays without per-item bootOrder updates.
  • Confirm BootOrderSummary filtering doesn't unintentionally hide devices that should be shown.

Possibly related PRs

Suggested labels

lgtm

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly references the Jira ticket (CNV-69048) and accurately summarizes the main changes affecting boot order modal and summary components.
Description check ✅ Passed The description covers required sections (Description and Demo) with clear bullet points explaining the behavioral changes and includes before/after demo videos.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d5c6ca and e863a65.

📒 Files selected for processing (3)
  • src/utils/components/BootOrder/BootOrderSummary.tsx (1 hunks)
  • src/utils/components/BootOrderModal/BootOrderModal.tsx (1 hunks)
  • src/utils/components/BootOrderModal/BootOrderModalBody.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/utils/components/BootOrder/BootOrderSummary.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.tsx

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.tsx: Use .tsx for all React components. One component per file. No nested components.
Use PascalCase for all React component names (e.g., HeaderTop.tsx).
Extract styling logic into separate SCSS files (e.g., my-component-name.scss) rather than embedding styles within React components.
Use functional components as the default. Use class components only for specific lifecycle methods unavailable in functional components (e.g., componentDidCatch).
Use default exports for all React components.
Extract as much logic as possible from React components into custom hooks or utility files for easier unit testing.
Keep React component files under 150 lines whenever possible.
Use React's memoization tools (React.memo, useMemo, useCallback) to avoid unnecessary re-renders and lazy load components with React.lazy and Suspense.

Files:

  • src/utils/components/BootOrderModal/BootOrderModal.tsx
  • src/utils/components/BootOrderModal/BootOrderModalBody.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{ts,tsx}: Keep functions short and focused on a single responsibility and be easily understood.
Always specify dependencies in useEffect to avoid unnecessary re-renders or missed updates. If no dependencies are required, pass an empty array [] to run the effect only once.
Define constants in utility files with uppercase and underscore-separated naming (e.g., API_URL).
Use descriptive names for variables, functions, and components. Avoid abbreviations unless widely recognized.
Prefer using type instead of interface for defining the shapes of objects or functions in TypeScript.
Avoid using any type in TypeScript. Use unknown instead and narrow the type as needed to maintain type safety.
Always explicitly define return types for functions rather than relying on TypeScript to infer them from the implementation.
Avoid hardcoded values (magic numbers) and define them as constants for easy adjustments and readability.
Avoid comments whenever possible. Write self-explanatory code. Use comments sparingly for unusual values or decisions to explain the rationale.
Avoid circular dependencies. Use index files cautiously to prevent situations that lead to circular dependencies.

Files:

  • src/utils/components/BootOrderModal/BootOrderModal.tsx
  • src/utils/components/BootOrderModal/BootOrderModalBody.tsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: galkremer1
Repo: kubevirt-ui/kubevirt-plugin PR: 3219
File: src/utils/components/BootOrderModal/BootOrderModal.tsx:36-53
Timestamp: 2025-11-25T19:31:46.140Z
Learning: In the KubeVirt plugin boot order modal, the product decision is to always set explicit `bootOrder` values for all devices when saving. Since KubeVirt defaults to device order if `bootOrder` is not specified, maintaining explicit boot order values for all devices is the intended behavior.
📚 Learning: 2025-11-25T19:31:46.140Z
Learnt from: galkremer1
Repo: kubevirt-ui/kubevirt-plugin PR: 3219
File: src/utils/components/BootOrderModal/BootOrderModal.tsx:36-53
Timestamp: 2025-11-25T19:31:46.140Z
Learning: In the KubeVirt plugin boot order modal, the product decision is to always set explicit `bootOrder` values for all devices when saving. Since KubeVirt defaults to device order if `bootOrder` is not specified, maintaining explicit boot order values for all devices is the intended behavior.

Applied to files:

  • src/utils/components/BootOrderModal/BootOrderModal.tsx
  • src/utils/components/BootOrderModal/BootOrderModalBody.tsx
📚 Learning: 2025-12-09T17:30:56.131Z
Learnt from: rszwajko
Repo: kubevirt-ui/kubevirt-plugin PR: 3235
File: src/views/checkups/self-validation/details/tabs/details/components/CheckupsSelfValidationDetailsDescriptionList.tsx:26-93
Timestamp: 2025-12-09T17:30:56.131Z
Learning: When using the Timestamp component from openshift-console/dynamic-plugin-sdk, you can pass sentinel values like NO_DATA_DASH directly to the timestamp prop without wrapping in conditional rendering. The component handles invalid/missing values gracefully. This applies to all TSX files that render the Timestamp component; ensure you do not add extra conditional logic for such values and rely on the component's internal handling. Reference: OpenShift Console Timestamp.tsx implementation.

Applied to files:

  • src/utils/components/BootOrderModal/BootOrderModal.tsx
  • src/utils/components/BootOrderModal/BootOrderModalBody.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: i18n
  • GitHub Check: build
  • GitHub Check: unit-test
🔇 Additional comments (4)
src/utils/components/BootOrderModal/BootOrderModal.tsx (2)

38-44: LGTM! Boot order assignment correctly implements the product decision.

The updatedDevices mapping correctly assigns explicit bootOrder values (1-indexed) to all devices based on their position in the array. This aligns with the product decision to always maintain explicit boot order values.

Based on learnings, this is the intended behavior since KubeVirt defaults to device order if bootOrder is not specified.


46-52: LGTM! Device filtering and assignment is correct.

The filtering logic correctly separates disks and interfaces from updatedDevices while preserving their boot order values.

src/utils/components/BootOrderModal/BootOrderModalBody.tsx (2)

46-53: LGTM! Simplified reordering logic is correct.

The onDrop handler now cleanly delegates bootOrder assignment to the parent component, making the data flow more straightforward. The parent modal will assign explicit bootOrder values based on the final array order when saving.


85-132: LGTM! Rendering simplification improves maintainability.

The flattened rendering structure is cleaner and easier to maintain. The delete button logic correctly shows for all items except the last one (since moving the last item to the end would have no effect).


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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


const onDrop = (source, dest) => {
if (dest) {
const newBootableDevices = reorder(devices, source.index, dest.index).map(
Copy link
Member Author

Choose a reason for hiding this comment

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

bootOrder is added when submitting the changes using the boot order modal.

title={t('No resource selected')}
/>
) : (
<>
Copy link
Member Author

Choose a reason for hiding this comment

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

removed unnecessary Fragment wrapper.

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Nov 25, 2025

@galkremer1: This pull request references CNV-69048 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.21.0" version, but no target version was set.

Details

In response to this:

📝 Description

Jira ticket: CNV-69048

  • Boot order summary shows only the devices with explicit bootOrder property.
  • Saving the changes in the boot order modal adds the bootOrder property to all devices.

🎥 Demo

Before:

Before.mov

After:

after.mov

Summary by CodeRabbit

  • Bug Fixes
  • Improved boot order assignment and handling for virtual machine devices, ensuring consistent device sequencing during reordering operations.

✏️ Tip: You can customize this high-level summary in your review settings.

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.

Copy link

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/utils/components/BootOrder/BootOrderSummary.tsx (1)

13-21: Guard against getSortedBootableDevices returning undefined before calling .filter.

getSortedBootableDevices can return undefined, so calling .filter on it risks a runtime error when there are no bootable devices. Consider defaulting to an empty array before filtering:

-  const transformedDevices = useMemo(
-    () =>
-      getSortedBootableDevices({ instanceTypeVM, vm }).filter(
-        (device) => device.value.bootOrder !== undefined,
-      ),
-    [vm, instanceTypeVM],
-  );
+  const transformedDevices = useMemo(
+    () =>
+      (getSortedBootableDevices({ instanceTypeVM, vm }) ?? []).filter(
+        (device) => device.value.bootOrder !== undefined,
+      ),
+    [vm, instanceTypeVM],
+  );
♻️ Duplicate comments (1)
src/utils/components/BootOrderModal/BootOrderModalBody.tsx (1)

46-65: onDelete no longer actually “removes” boot order once persisted.

onDelete still clears bootOrder on the selected device and moves it to the end of the list, but BootOrderModal now unconditionally assigns bootOrder = index + 1 for every device on save. As a result, the cleared bootOrder is immediately reintroduced, and this handler no longer has its intended effect.

Once you adjust BootOrderModal (see corresponding comment there) to respect bootOrder: undefined, this function will regain its original meaning. Otherwise, if the new design is “all devices always have bootOrder,” you should update this handler and the comment to reflect the new behavior (e.g., treat it as “move to end” rather than “remove boot order”).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9104155 and 2d5c6ca.

📒 Files selected for processing (3)
  • src/utils/components/BootOrder/BootOrderSummary.tsx (1 hunks)
  • src/utils/components/BootOrderModal/BootOrderModal.tsx (1 hunks)
  • src/utils/components/BootOrderModal/BootOrderModalBody.tsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/utils/components/BootOrder/BootOrderSummary.tsx (1)
src/utils/resources/vm/utils/boot-order/bootOrder.ts (1)
  • getSortedBootableDevices (72-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: unit-test
  • GitHub Check: i18n
  • GitHub Check: build
🔇 Additional comments (1)
src/utils/components/BootOrderModal/BootOrderModalBody.tsx (1)

85-132: Drag-and-drop reordering implementation looks correct.

The new DragDrop/Droppable/Draggable block correctly maps devices in order, uses onDrop to reorder by indices, and wires up the drag handle and delete button per item. No obvious logic or accessibility regressions introduced here.

Comment on lines 36 to 53
const updatedVirtualMachine = produce<V1VirtualMachine>(vm, (draftVM) => {
ensurePath(draftVM, ['spec.template.spec.domain.devices']);
const updatedDevices = devices.map((device, index) => ({
...device,
value: {
...device.value,
bootOrder: index + 1,
},
}));

draftVM.spec.template.spec.domain.devices.disks = devices
draftVM.spec.template.spec.domain.devices.disks = updatedDevices
.filter((source) => source.type === DeviceType.DISK)
.map((source) => source.value);

draftVM.spec.template.spec.domain.devices.interfaces = devices
draftVM.spec.template.spec.domain.devices.interfaces = updatedDevices
.filter((source) => source.type === DeviceType.NIC)
.map((source) => source.value);
});
Copy link

@coderabbitai coderabbitai bot Nov 25, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

updatedDevices overwrites cleared bootOrder values, breaking “remove from boot order” semantics.

updatedDevices assigns bootOrder: index + 1 for every device, so any device whose bootOrder was cleared in BootOrderModalBody.onDelete is still persisted with a new bootOrder. That:

  • Removes the ability to keep a device without explicit boot order.
  • Makes the minus button effectively just move the device to the end.
  • Conflicts with BootOrderSummary, which now shows only devices with bootOrder !== undefined.

If the intent is to keep “unset boot order” as a supported state, you should only renumber devices that currently have bootOrder defined, preserving undefined:

-    const updatedDevices = devices.map((device, index) => ({
-      ...device,
-      value: {
-        ...device.value,
-        bootOrder: index + 1,
-      },
-    }));
+    let nextOrder = 1;
+    const updatedDevices = devices.map((device) => {
+      const hasBootOrder = device.value.bootOrder !== undefined;
+
+      return {
+        ...device,
+        value: {
+          ...device.value,
+          bootOrder: hasBootOrder ? nextOrder++ : undefined,
+        },
+      };
+    });

If instead the product decision is that all devices must always have a bootOrder after saving, then onDelete in BootOrderModalBody and the summary filtering logic should be aligned to that behavior (e.g., by removing the “clear boot order” path and/or changing the summary filter).

Copy link
Member Author

Choose a reason for hiding this comment

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

For now I left the onDelete for reference. Basically it is just moving the device all the way down the list.
Per product decision since the bootOrder defaults to device order if it is not stated - we can just leave the boot order explicitly.

Copy link

Choose a reason for hiding this comment

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

@galkremer1, thank you for the clarification! That makes sense—if the product decision is to always maintain explicit bootOrder values for all devices (since KubeVirt defaults to device order anyway), then the current implementation correctly assigns bootOrder: index + 1 to every device on save.

Given this, the filtering in BootOrderSummary will show all devices after the modal is saved at least once, which aligns with the expected behavior.

One minor suggestion: since onDelete no longer actually removes a device from boot order but instead moves it to the end of the list, consider renaming it (e.g., onMoveToEnd or onMoveDown) or adding a comment to clarify its new purpose, to avoid confusion for future maintainers.


✏️ Learnings added
Learnt from: galkremer1
Repo: kubevirt-ui/kubevirt-plugin PR: 3219
File: src/utils/components/BootOrderModal/BootOrderModal.tsx:36-53
Timestamp: 2025-11-25T19:31:46.118Z
Learning: In the KubeVirt plugin boot order modal, the product decision is to always set explicit `bootOrder` values for all devices when saving. Since KubeVirt defaults to device order if `bootOrder` is not specified, maintaining explicit boot order values for all devices is the intended behavior.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@galkremer1
Copy link
Member Author

/retest

Comment on lines +15 to +17
getSortedBootableDevices({ instanceTypeVM, vm }).filter(
(device) => device.value.bootOrder !== undefined,
),
Copy link
Member

Choose a reason for hiding this comment

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

From what i understood, the bootOrder is required only for NIC

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I understand - bootOrder is optional for both interfaces and disks.
If the order is not applied explicitly using the bootOrder property, it's applied implicitly by the order in the array (disks first, then interfaces).

Copy link
Member

Choose a reason for hiding this comment

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

yes its optional. But it works differently for disks and interfaces.
For disks if no bootoder is provided, then we can use the index. but for interfaces if no bootoder is provided, the vm is not bootable using that interface

Copy link
Member

Choose a reason for hiding this comment

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

I asked this question on the ticket and the backend team responded

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the clarification Ugo. The question is if we still want to show the boot order in the summary even though it was not provided explicitly (for disks).

@galkremer1
Copy link
Member Author

/retest

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Dec 13, 2025

@galkremer1: This pull request references CNV-69048 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.22.0" version, but no target version was set.

Details

In response to this:

📝 Description

Jira ticket: CNV-69048

  • Boot order summary shows only the devices with explicit bootOrder property.
  • Saving the changes in the boot order modal adds the bootOrder property to all devices.

🎥 Demo

Before:

Before.mov

After:

after.mov

Summary by CodeRabbit

  • Bug Fixes
  • Consistent boot-order handling so device lists reflect only bootable items with defined order.
  • Behavior Changes
  • Reordering now returns the new device sequence as-is (boot-order metadata is no longer auto-updated in-place).
  • UI
  • Simplified reorder UI rendering while preserving drag-and-drop and delete controls.

✏️ Tip: You can customize this high-level summary in your review settings.

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 This issue is something we want to fix jira/valid-reference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants