Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Sch <sebassch@gmail.com>
  • Loading branch information
SchSeba committed Jun 12, 2023
1 parent 2ee9c3f commit 221046b
Show file tree
Hide file tree
Showing 13 changed files with 1,327 additions and 38 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/coreos/go-systemd/v22 v22.4.0
github.com/fsnotify/fsnotify v1.6.0
github.com/golang/glog v1.0.0
github.com/golang/mock v1.4.4
github.com/google/go-cmp v0.5.9
github.com/hashicorp/go-retryablehttp v0.7.0
github.com/jaypipes/ghw v0.9.0
Expand All @@ -26,6 +27,7 @@ require (
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.25.2
k8s.io/apiextensions-apiserver v0.25.2
k8s.io/apimachinery v0.25.2
Expand Down Expand Up @@ -146,7 +148,6 @@ require (
google.golang.org/grpc v1.50.1 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
howett.net/plist v1.0.0 // indirect
k8s.io/cli-runtime v0.25.1 // indirect
k8s.io/component-base v0.25.2 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down
22 changes: 0 additions & 22 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
netattdefv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
openshiftconfigv1 "github.com/openshift/api/config/v1"
mcfgv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"
mcclientset "github.com/openshift/machine-config-operator/pkg/generated/clientset/versioned"
"k8s.io/apimachinery/pkg/api/errors"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
Expand Down Expand Up @@ -85,27 +84,6 @@ func main() {

restConfig := ctrl.GetConfigOrDie()

var openshiftContext *utils.OpenshiftContext
if utils.ClusterType == utils.ClusterTypeOpenshift {
mcclient := mcclientset.NewForConfigOrDie(restConfig)
openshiftFlavor := utils.OpenshiftFlavorDefault
infraClient, err := client.New(restConfig, client.Options{
Scheme: scheme,
})
if err != nil {
panic(err)
}
isHypershift, err := utils.IsExternalControlPlaneCluster(infraClient)
if err != nil {
panic(err)
}
if isHypershift {
openshiftFlavor = utils.OpenshiftFlavorHypershift
}

openshiftContext = &utils.OpenshiftContext{McClient: mcclient, OpenshiftFlavor: openshiftFlavor}
}

kubeClient, err := client.New(restConfig, client.Options{Scheme: scheme})
if err != nil {
setupLog.Error(err, "couldn't create client")
Expand Down
15 changes: 8 additions & 7 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ type Daemon struct {
}

const (
udevScriptsPath = "/bindata/scripts/load-udev.sh"
annoKey = "sriovnetwork.openshift.io/state"
annoIdle = "Idle"
annoDraining = "Draining"
annoMcpPaused = "Draining_MCP_Paused"
syncStatusSucceeded = "Succeeded"
syncStatusFailed = "Failed"syncStatusInProgress = "InProgress"
udevScriptsPath = "/bindata/scripts/load-udev.sh"
annoKey = "sriovnetwork.openshift.io/state"
annoIdle = "Idle"
annoDraining = "Draining"
annoMcpPaused = "Draining_MCP_Paused"
syncStatusSucceeded = "Succeeded"
syncStatusFailed = "Failed"
syncStatusInProgress = "InProgress"
)

var namespace = os.Getenv("NAMESPACE")
Expand Down
16 changes: 8 additions & 8 deletions pkg/plugins/generic/generic_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type GenericPlugin struct {
LastState *sriovnetworkv1.SriovNetworkNodeState
LoadVfioDriver uint
LoadVirtioVdpaDriver uint
RunningOnHost bool
HostManager host.HostManagerInterface
RunningOnHost bool
HostManager host.HostManagerInterface
}

const scriptsPath = "bindata/scripts/enable-kargs.sh"
Expand All @@ -41,12 +41,12 @@ const (
// Initialize our plugin and set up initial values
func NewGenericPlugin(runningOnHost bool) (plugin.VendorPlugin, error) {
return &GenericPlugin{
PluginName: PluginName,
SpecVersion: "1.0",
LoadVfioDriver: unloaded,
PluginName: PluginName,
SpecVersion: "1.0",
LoadVfioDriver: unloaded,
LoadVirtioVdpaDriver: unloaded,
RunningOnHost: runningOnHost,
HostManager: host.NewHostManager(runningOnHost),
RunningOnHost: runningOnHost,
HostManager: host.NewHostManager(runningOnHost),
}, nil
}

Expand Down Expand Up @@ -89,7 +89,7 @@ func (p *GenericPlugin) Apply() error {
}

if p.LoadVirtioVdpaDriver == loading {
if err := utils.LoadKernelModule("virtio_vdpa"); err != nil {
if err := p.HostManager.LoadKernelModule("virtio_vdpa"); err != nil {
glog.Errorf("generic-plugin Apply(): fail to load virtio_vdpa kmod: %v", err)
return err
}
Expand Down
12 changes: 12 additions & 0 deletions vendor/github.com/golang/mock/AUTHORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions vendor/github.com/golang/mock/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

202 changes: 202 additions & 0 deletions vendor/github.com/golang/mock/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 221046b

Please sign in to comment.