-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae849f3
commit e4e9ffa
Showing
9 changed files
with
1,497 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package main | ||
|
||
import ( | ||
"io" | ||
"log" | ||
"os" | ||
|
||
"github.com/inaccel/daemon/pkg/plugin" | ||
"github.com/inaccel/device-selector/internal" | ||
"github.com/sirupsen/logrus" | ||
"github.com/urfave/cli/v2" | ||
kubevirtv1 "kubevirt.io/api/core/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/client/config" | ||
) | ||
|
||
var version string | ||
|
||
func main() { | ||
app := &cli.App{ | ||
Name: "device-selector", | ||
Version: version, | ||
Usage: "A self-sufficient runtime for accelerators.", | ||
Flags: []cli.Flag{ | ||
&cli.BoolFlag{ | ||
Name: "debug", | ||
Aliases: []string{"d"}, | ||
Usage: "enable debug output", | ||
}, | ||
}, | ||
Before: func(context *cli.Context) error { | ||
log.SetOutput(io.Discard) | ||
|
||
logrus.SetFormatter(new(logrus.JSONFormatter)) | ||
|
||
if context.Bool("debug") { | ||
logrus.SetLevel(logrus.DebugLevel) | ||
} | ||
|
||
return nil | ||
}, | ||
Action: func(context *cli.Context) error { | ||
kube, err := config.GetConfig() | ||
if err != nil { | ||
return err | ||
} | ||
api, err := client.New(kube, client.Options{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := kubevirtv1.AddToScheme(api.Scheme()); err != nil { | ||
return err | ||
} | ||
|
||
kubeVirt := &kubevirtv1.KubeVirt{} | ||
if err := api.Get(context.Context, client.ObjectKey{ | ||
Namespace: os.Getenv("KUBE_VIRT_NAMESPACE"), | ||
Name: os.Getenv("KUBE_VIRT_NAME"), | ||
}, kubeVirt); err != nil { | ||
return err | ||
} | ||
|
||
var new []plugin.New | ||
if kubeVirt.Spec.Configuration.PermittedHostDevices != nil { | ||
for _, pciHostDevice := range kubeVirt.Spec.Configuration.PermittedHostDevices.PciHostDevices { | ||
if pciHostDevice.ExternalResourceProvider { | ||
new = append(new, internal.NewPciHostDevicePlugin(context.Context, pciHostDevice)) | ||
} | ||
} | ||
} | ||
|
||
plugin.Handle(new...) | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
if err := app.Run(os.Args); err != nil { | ||
logrus.Fatal(err) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,82 @@ | ||
module github.com/inaccel/device-selector | ||
|
||
go 1.21 | ||
|
||
require ( | ||
github.com/inaccel/daemon v1.1.12 | ||
github.com/sirupsen/logrus v1.9.3 | ||
github.com/u-root/u-root v0.14.0 | ||
github.com/urfave/cli/v2 v2.27.1 | ||
google.golang.org/grpc v1.61.0 | ||
k8s.io/kubelet v0.29.1 | ||
kubevirt.io/api v1.1.1 | ||
kubevirt.io/kubevirt v1.1.1 | ||
sigs.k8s.io/controller-runtime v0.17.2 | ||
) | ||
|
||
require ( | ||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect | ||
github.com/evanphx/json-patch/v5 v5.8.0 // indirect | ||
github.com/go-kit/kit v0.10.0 // indirect | ||
github.com/go-logfmt/logfmt v0.5.1 // indirect | ||
github.com/go-logr/logr v1.4.1 // indirect | ||
github.com/go-openapi/jsonpointer v0.19.6 // indirect | ||
github.com/go-openapi/jsonreference v0.20.2 // indirect | ||
github.com/go-openapi/swag v0.22.3 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/glog v1.1.2 // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/google/gnostic-models v0.6.8 // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/uuid v1.4.0 // indirect | ||
github.com/imdario/mergo v0.3.15 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/klauspost/compress v1.17.5 // indirect | ||
github.com/klauspost/pgzip v1.2.6 // indirect | ||
github.com/mailru/easyjson v0.7.7 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
github.com/openshift/api v0.0.0 // indirect | ||
github.com/openshift/custom-resource-status v1.1.2 // indirect | ||
github.com/pborman/uuid v1.2.1 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/ulikunitz/xz v0.5.11 // indirect | ||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect | ||
golang.org/x/net v0.21.0 // indirect | ||
golang.org/x/oauth2 v0.14.0 // indirect | ||
golang.org/x/sys v0.17.0 // indirect | ||
golang.org/x/term v0.17.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
golang.org/x/time v0.3.0 // indirect | ||
google.golang.org/appengine v1.6.8 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
k8s.io/api v0.29.1 // indirect | ||
k8s.io/apiextensions-apiserver v0.29.0 // indirect | ||
k8s.io/apimachinery v0.29.1 // indirect | ||
k8s.io/client-go v12.0.0+incompatible // indirect | ||
k8s.io/klog/v2 v2.110.1 // indirect | ||
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect | ||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect | ||
kubevirt.io/client-go v0.0.0-00010101000000-000000000000 // indirect | ||
kubevirt.io/containerized-data-importer-api v1.57.0-alpha1 // indirect | ||
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 // indirect | ||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect | ||
sigs.k8s.io/yaml v1.4.0 // indirect | ||
) | ||
|
||
replace ( | ||
github.com/openshift/api => github.com/openshift/api v0.0.0-20191219222812-2987a591a72c | ||
k8s.io/client-go => k8s.io/client-go v0.29.1 | ||
kubevirt.io/client-go => kubevirt.io/client-go v1.1.1 | ||
) |
Oops, something went wrong.