feat: add disableResourcePooling flag#191
Open
Yu-Jack wants to merge 1 commit into
Open
Conversation
Signed-off-by: Jack Yu <jack.yu@suse.com>
1 task
There was a problem hiding this comment.
Pull request overview
This PR introduces a disableResourcePooling flag on PCIDeviceClaim to support per-device (non-pooled) resource naming by persisting an override resource name onto the associated PCIDevice, and cleaning it up when the claim is deleted.
Changes:
- Add
spec.disableResourcePoolingtoPCIDeviceClaim. - On claim reconcile, set a per-device
PCIDeviceOverrideResourceNameand persist it intoPCIDevice.Status.ResourceName. - On claim deletion, remove the per-device override annotation so the
pcidevicecontroller can revertStatus.ResourceName.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/controller/pcideviceclaim/pcideviceclaim_controller.go | Adds per-device resource-name override set/cleanup logic tied to DisableResourcePooling. |
| pkg/controller/pcidevice/pcidevice_controller.go | Updates inline documentation explaining shared use of the override resource name annotation. |
| pkg/apis/devices.harvesterhci.io/v1beta1/pcideviceclaim.go | Adds the DisableResourcePooling field and expands the annotation constant documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+24
to
+27
| Address string `json:"address"` | ||
| NodeName string `json:"nodeName"` | ||
| UserName string `json:"userName"` | ||
| DisableResourcePooling bool `json:"disableResourcePooling,omitempty"` |
Comment on lines
+339
to
+347
| // ensureIndividualDeviceResourceName sets a unique resource name (<vendor-prefix>/<pd.Name>) | ||
| // on the PCIDevice annotation and Status.ResourceName when DisableResourcePooling is enabled. | ||
| // Cleanup is handled by cleanupIndividualDeviceResourceName on claim deletion. | ||
| func (h *Handler) ensureIndividualDeviceResourceName(pd *v1beta1.PCIDevice) (*v1beta1.PCIDevice, error) { | ||
| parts := strings.SplitN(pd.Status.ResourceName, "/", 2) | ||
| individualResourceName := pd.Name | ||
| if len(parts) == 2 { | ||
| individualResourceName = parts[0] + "/" + pd.Name | ||
| } |
Comment on lines
+349
to
+364
| pdCopy := pd.DeepCopy() | ||
| if pdCopy.Annotations == nil { | ||
| pdCopy.Annotations = make(map[string]string) | ||
| } | ||
| pdCopy.Annotations[v1beta1.PCIDeviceOverrideResourceName] = individualResourceName | ||
| updated, err := h.pdClient.Update(pdCopy) | ||
| if err != nil { | ||
| return pd, err | ||
| } | ||
|
|
||
| updated.Status.ResourceName = individualResourceName | ||
| updated, err = h.pdClient.UpdateStatus(updated) | ||
| if err != nil { | ||
| return updated, err | ||
| } | ||
|
|
Comment on lines
+424
to
+432
| // When DisableResourcePooling is set, persist the per-device resource name on the | ||
| // PCIDevice object so that the frontend (and any other consumer) can read | ||
| // pd.Status.ResourceName uniformly without needing claim-level awareness. | ||
| if pdc.Spec.DisableResourcePooling { | ||
| pd, err = h.ensureIndividualDeviceResourceName(pd) | ||
| if err != nil { | ||
| return pdc, fmt.Errorf("error setting individual device resource name: %v", err) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IMPORTANT: Please do not create a Pull Request without creating an issue first.
Problem:
Solution:
Related Issue:
harvester/harvester#6724
Test plan:
Create the corresponding claim by kubectl instead of GUI because GUI hasn't been implemented.
additional context:
UI has two parts