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
  • Loading branch information
ibrokethecloud committed Sep 23, 2024
1 parent b6ed907 commit 46ee5eb
Show file tree
Hide file tree
Showing 19 changed files with 1,447 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 46ee5eb

Please sign in to comment.