Skip to content

feat: add disableResourcePooling flag#191

Open
Yu-Jack wants to merge 1 commit into
harvester:masterfrom
Yu-Jack:HARV-6724
Open

feat: add disableResourcePooling flag#191
Yu-Jack wants to merge 1 commit into
harvester:masterfrom
Yu-Jack:HARV-6724

Conversation

@Yu-Jack
Copy link
Copy Markdown
Contributor

@Yu-Jack Yu-Jack commented May 27, 2026

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.

# Example 1
cat <<EOF | k apply -f -
apiVersion: devices.harvesterhci.io/v1beta1
kind: PCIDeviceClaim
metadata:
  name: dell-190-000001105
  ownerReferences:
  - apiVersion: devices.harvesterhci.io/v1beta1
    kind: PCIDevice
    name: dell-190-000001105
    uid: b4c02319-bb1e-44b5-8192-c87942dfbe8a 
spec:
  address: "0000:01:10.5"
  nodeName: dell-190
  userName: admin
  disableResourcePooling: true
EOF

additional context:

UI has two parts

  1. Removing old format checking feat: remove old format pci device name checking harvester-ui-extension#889
  2. Provide a good UI/UX for users to check disableResourcePooling (Pending)

Signed-off-by: Jack Yu <jack.yu@suse.com>
Copy link
Copy Markdown

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 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.disableResourcePooling to PCIDeviceClaim.
  • On claim reconcile, set a per-device PCIDeviceOverrideResourceName and persist it into PCIDevice.Status.ResourceName.
  • On claim deletion, remove the per-device override annotation so the pcidevice controller can revert Status.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)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants