Skip to content

Commit

Permalink
initial work to reconcile devices from launcher pods
Browse files Browse the repository at this point in the history
initial work to reconcile devices from launcher pods

refactor vmi reconcile to pass codefactor check

refactor code and change validation logic to use new annotations

modified vmi/vm reconcile to also update vm with correct device names based on vgpu annotation when VM is stopped

include pr review feedback

fine tune logic for removing duplicates from allocation annotation
  • Loading branch information
ibrokethecloud committed Oct 2, 2024
1 parent 0454d8b commit b913aa8
Show file tree
Hide file tree
Showing 19 changed files with 1,544 additions and 40 deletions.
10 changes: 10 additions & 0 deletions pkg/apis/devices.harvesterhci.io/v1beta1/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package v1beta1

const (
DeviceAllocationKey = "harvesterhci.io/deviceAllocationDetails"
)

type AllocationDetails struct {
GPUs map[string][]string `json:"gpus,omitempty"`
HostDevices map[string][]string `json:"hostdevices,omitempty"`
}
2 changes: 2 additions & 0 deletions pkg/codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func main() {
kubevirtv1.SchemeGroupVersion.Group: {
Types: []interface{}{
kubevirtv1.KubeVirt{},
kubevirtv1.VirtualMachineInstance{},
kubevirtv1.VirtualMachine{},
},
GenerateTypes: false,
GenerateClients: true,
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/factory_magement.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package config

import (
ctlnetwork "github.com/harvester/harvester-network-controller/pkg/generated/controllers/network.harvesterhci.io"
ctlcore "github.com/rancher/wrangler/pkg/generated/controllers/core"
"k8s.io/client-go/rest"
"kubevirt.io/client-go/kubecli"

ctlnetwork "github.com/harvester/harvester-network-controller/pkg/generated/controllers/network.harvesterhci.io"

ctldevices "github.com/harvester/pcidevices/pkg/generated/controllers/devices.harvesterhci.io"
ctlkubevirt "github.com/harvester/pcidevices/pkg/generated/controllers/kubevirt.io"
)
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"time"

ctlnetwork "github.com/harvester/harvester-network-controller/pkg/generated/controllers/network.harvesterhci.io"
"github.com/rancher/lasso/pkg/cache"
"github.com/rancher/lasso/pkg/client"
"github.com/rancher/lasso/pkg/controller"
Expand All @@ -18,13 +17,16 @@ import (
"k8s.io/client-go/util/workqueue"
"kubevirt.io/client-go/kubecli"

ctlnetwork "github.com/harvester/harvester-network-controller/pkg/generated/controllers/network.harvesterhci.io"

"github.com/harvester/pcidevices/pkg/config"
"github.com/harvester/pcidevices/pkg/controller/gpudevice"
"github.com/harvester/pcidevices/pkg/controller/nodecleanup"
"github.com/harvester/pcidevices/pkg/controller/nodes"
"github.com/harvester/pcidevices/pkg/controller/pcideviceclaim"
"github.com/harvester/pcidevices/pkg/controller/sriovdevice"
"github.com/harvester/pcidevices/pkg/controller/usbdevice"
"github.com/harvester/pcidevices/pkg/controller/virtualmachine"
"github.com/harvester/pcidevices/pkg/crd"
ctldevices "github.com/harvester/pcidevices/pkg/generated/controllers/devices.harvesterhci.io"
ctlkubevirt "github.com/harvester/pcidevices/pkg/generated/controllers/kubevirt.io"
Expand Down Expand Up @@ -103,6 +105,7 @@ func Setup(ctx context.Context, cfg *rest.Config, _ *runtime.Scheme) error {
sriovdevice.Register,
nodecleanup.Register,
gpudevice.Register,
virtualmachine.Register,
}

for _, register := range registers {
Expand All @@ -111,7 +114,7 @@ func Setup(ctx context.Context, cfg *rest.Config, _ *runtime.Scheme) error {
}
}

if err := start.All(ctx, 2, coreFactory, networkFactory, deviceFactory); err != nil {
if err := start.All(ctx, 2, coreFactory, networkFactory, deviceFactory, kubevirtFactory); err != nil {
return fmt.Errorf("error starting controllers :%v", err)
}

Expand Down
Loading

0 comments on commit b913aa8

Please sign in to comment.