PR 1271: preselect a StorageClass that exists

pohanhuang’s fix for harvester/harvester#12384 (a sub-issue of #12129, run Harvester without a Longhorn data disk). Reviewed in two passes, Cody’s process and ours, each by a fresh agent, one after the other, then merged and re-checked by me.

Preview: harvesterpr1271r.mf-created-dashboard.ui.rancher.space, built from 8db93eb (the head; Pass B ran on fc7d1b6, whose image code is identical). Baseline harvestermainr…, rebuilt from upstream main e66b61d (the PR’s base). Backend .105 (v1.10.0-rc1 with the master API, harvester-longhorn default plus longhorn). Login admin, the usual lab password.

Where it stands: request changes, one blocker

The issue’s own case works: with no default and no longhorn, both forms now pick a class that exists, where main sent a longhorn that isn’t there. But the PR tries longhorn before the cluster default, so on every stock cluster Create Image and Create Volume switch from harvester-longhorn to longhorn, and a custom default is skipped. Both passes found it on their own. The rest is about the new message.

Pending review 5993855990 is on GitHub, not submitted: the intro plus the 7 comments below, anchored at 8db93eb, with 4 screenshots. CI is green; Copilot’s two threads are fixed in 8db93eb.

Thanks for picking this up. The issue's case works now: with no default and no longhorn, both forms pick a class that exists. The main thing is the new order, which puts longhorn ahead of the cluster default on every stock cluster. The rest is about the new message.

How the two passes compare

FindingPass A (Cody)Pass B (ours)Outcome
1. longhorn before the default✓ Major✓ BlockerPosted (blocker)
2. Encrypt message asks for the wrong classSaw it; called the selection an improvement✓ SuggestionPosted
3. Message on Edit pages✓ Minor✓ SuggestionPosted
4. Tests miss the filters / keep-existing / loaded flag—✓ Suggestion (mutations)Posted
5. Wording “selectable”, no link—✓ NitPosted, optional
6. data() alignmentDropped (no-nit rule)✓ NitPosted, optional
7. What to preselect with no default✓ Open question✓ QuestionPosted (question)
Image message only on the Storage tab; Create sends an empty classDropped: main is no better there✓ SuggestionYour call, not posted
'longhorn' literal vs LONGHORN constant; rule written twiceDropped (no-nit / simplify)—Not posted
Shared Banner not announced, tabindex on a divDropped (on master)—Not posted (pre-existing)
Copilot’s two threadsFixed at 8db93ebConfirmed live on fc7d1b6; fixed at 8db93ebNothing to add

Only A: the parent issue #12129, the acceptance table, 7 clips. Only B: the backend’s own fallback rule (EnsureTargetSC), the Encrypt message, the mutation run, Create payloads for images. A: 27 min, 104 tool calls, ~271k tokens. B: 24 min, 147 calls, ~271k tokens.

What’s in the pending review

1

longhorn now wins over the cluster default StorageClass

pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue:448 · Dev · UX
Blocker
Pass A (Cody)Pass B (ours)

Comment as posted (pending)

This tries longhorn before the cluster's default StorageClass. A stock cluster has both harvester-longhorn (the default) and longhorn, so Create Image and Create Volume now preselect and send longhorn where main sends harvester-longhorn. The volume form does the same at harvesterhci.io.volume.vue:86. A default the admin set on purpose, like a third-party class, is skipped too, and an image's class can't be changed after it's created.

The issue only covers clusters with no default, and its parent harvester/harvester#12129 asks for the cluster default instead of a hard-coded class. The backend also uses the default class when an image doesn't name one, and every other StorageClass picker in the extension starts from the default (Restore Snapshot, Export Image, VM volumes, vm-import-controller, the upgrade repository picker).

main / this PR, same cluster:

main: harvester-longhorn (Default)
main: harvester-longhorn (Default)
This PR: longhorn
This PR: longhorn

Evidence

Live on both previews with Create payloads from the write net (stock cluster and a simulated custom default), API read of .105, backend EnsureTargetSC source, the parent issue harvester/harvester#12129, and the five other pickers in the repo.

2

Under Encrypt, the message asks for the wrong thing

pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue:599 · UX
Suggestion
Pass B (ours)

Comment as posted (pending)

With Encrypt selected on a cluster that has no encrypted StorageClass, this shows "No selectable StorageClasses are available. Create a StorageClass before creating an image." while harvester-longhorn, longhorn and lvm-backup-test exist. What's missing is an encrypted class, so the message sends the user to create the wrong thing.

This PR, Encrypt selected
This PR, Encrypt selected

Evidence

Live on the real cluster (no encrypted class). Pass A saw the same banner on Encrypt and judged the new <i>selection</i> an improvement, which it is (main preselected a non-encrypted default that isn’t in the encrypted list). The comment is about the text only.

3

The message shows on Edit pages, under a locked field

pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue:180 · UX
Suggestion
Pass A (Cody)Pass B (ours)

Comment as posted (pending)

mode !== 'view' lets the message show on the Edit page too. Editing an existing image on a cluster with nothing selectable says "Create a StorageClass before creating an image" under the locked Storage Class field, though nothing is being created. The volume form does the same for an existing blank volume (harvesterhci.io.volume.vue:263). Main shows nothing there.

This PR, Edit image
This PR, Edit image

Evidence

Live with a simulated “nothing selectable” list: edit of image default/image-p7c4z and of a blank volume. Main shows nothing there. Pass A filed it as Minor with a clip. It’s what is left of Copilot’s first thread after 8db93eb.

4

The new tests miss what the PR adds besides the order

pkg/harvester/edit/__tests__/harvesterhci.io.virtualmachineimage.test.js:28 · Dev
Suggestion
Pass B (ours)

Comment as posted (pending)

These tests still pass if the internal-class filter is removed from either form, if the image form stops keeping an existing selection, or if storageClassesLoaded is never set, which means the message can never show. Those are what this PR adds besides the order, so a later change could break them without a test failing.

Evidence

Mutation runs in a separate worktree: 9 of 12 mutations still pass (internal-class filter removed, keep-existing dropped, loaded flag never set, LVM and encryption filters dropped). Reverting both .vue files makes 11 of 13 fail, so the tests do pin the order.

5

Message wording: “selectable”, and no way to get there

pkg/harvester/l10n/en-us.yaml:1239 · UI
Optional
Pass B (ours)

Comment as posted (pending)

Optional: "selectable" isn't a word the UI uses anywhere else, and "Create a StorageClass" doesn't say where. The VM form's persistent-state message links to the Storage Classes page, and the upgrade repository picker's empty state says "No StorageClasses are available." The volume message at line 1196 is the same.

Evidence

Code reading. Existing patterns: the VM form’s persistent-state banner links to the Storage Classes page; the upgrade picker’s empty state says “No StorageClasses are available.”

6

data() alignment

pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue:107 · Dev
Optional
Pass B (ours)

Comment as posted (pending)

Optional: the data() values now start in three different columns.

Evidence

Code reading. Lint passes (key-spacing is in minimum mode). Pass A dropped it under its no-nit rule.

7

With no default, what should be preselected?

pkg/harvester/edit/harvesterhci.io.volume.vue:87 · UX
Question
Pass A (Cody)Pass B (ours)

Comment as posted (pending)

With no default, both forms still preselect longhorn when it exists, otherwise the first class in the list, which can be an LVM class nobody picked. The issue's title asks not to default to longhorn when there's no default. Is a preselection wanted in that case? The upgrade repository picker leaves the field empty and required there, and the backend only ever falls back to the default class.

Evidence

Both passes raised it: Pass A as an open question about the issue title (“don’t default to Longhorn when no default exists”, yet both main and the PR pick longhorn there), Pass B as Q1 (the first class can be an LVM class nobody picked). Upgrade picker: default or empty, required. Backend: default class only.

Your call, not posted

·

When nothing is usable, the image form explains it only on the Storage tab

harvesterhci.io.virtualmachineimage.vue:599 · UX
Your call

Pass B: the form opens on Basics, Create stays enabled and sends an empty class; the backend then uses the default class or fails with “missing default storage class”. Pass A dropped it because main sends a longhorn that isn’t there in the same state, so it’s no worse, and that state needs a cluster with no usable class at all. I left it out for the same reason; it fits your form rule (Save blocked, tab marked) if you want it.

Pass A’s demos (same backend, same walk)

Before (main), the issue’s case: longhorn preselected, not on the cluster
After (PR), same walk: an existing class preselected
Comment 1, main: harvester-longhorn (Default) on both forms
Comment 1, PR: longhorn on both forms
Comment 3, PR: the message on the Edit pages

The before/after pair can go in the review body if you want it; the pending review has none.

Pass A’s acceptance table

#CriterionSourcePR (8db93eb)main
AC1Image create, no default and no longhorn: an existing class is preselectedIssue bodyMetNot met (longhorn)
AC2Image create with a default: the default is preselectedImplied; parent #12129Not met (longhorn)Met
AC3Volume create follows AC1 and AC2PR test step 1Partly (AC1 yes, AC2 no)Partly (AC2 yes, AC1 no)
AC4Fallback never picks an internal or per-image classPR summaryMetNot met
AC5An existing selection is kept on editPR test step 2MetMet
AC6Nothing selectable: a per-form info messagePR test step 4; CopilotMetNot met (no message)
AC7No volume message when Source = VM imageCopilot threadMet at 8db93ebMet

Pass B’s live cases, main vs PR

StorageClass setCasemainPR
Stock cluster (.105)Image createharvester-longhorn (Default)longhorn
Stock cluster (.105)Volume createharvester-longhorn (Default)longhorn
Custom default fast next to longhornImage / Volume createfast (Default)longhorn
Issue’s case: no default, no longhornImage / Volume createlonghorn (not on the cluster)fast (first usable)
Default fast, no longhornImage / Volume createfast (Default)fast (Default)
Default is encrypted, no longhornImage createlonghorn (not on the cluster)fast
Stock cluster, Encrypt selectedImage createempty, no messageempty + “Create a StorageClass” message
Nothing usable (internal + backing-image only)Image createinternal default, no messageempty + message on the Storage tab only; Create sends an empty class
Nothing usableVolume create, source VM imageno messageno message at 8db93eb (Copilot’s thread, fixed)
Nothing usableImage / Volume editno messagemessage under the locked field

Lists rewritten in the browser, the Steve socket filtered, store contents asserted before reading the form. 19 cases per preview over 6 sets. Unit tests: 13/13 on both heads, all of pkg/harvester green; lint clean.

Environment and cleanup