Skip to content

Commit

Permalink
move namespace to vars pkg
Browse files Browse the repository at this point in the history
Namespace variable is used in both controllers and daemon.
Move it to vars pkg and use in both.

Signed-off-by: adrianc <[email protected]>
  • Loading branch information
adrianchiris committed Jan 30, 2024
1 parent 54b342c commit da7011a
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 44 deletions.
7 changes: 3 additions & 4 deletions controllers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/apply"
constants "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/render"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
)

var webhooks = map[string](string){
Expand All @@ -55,8 +56,6 @@ const (
trueString = "true"
)

var namespace = os.Getenv("NAMESPACE")

func GetImagePullSecrets() []string {
imagePullSecrets := os.Getenv("IMAGE_PULL_SECRETS")
if imagePullSecrets != "" {
Expand Down Expand Up @@ -85,7 +84,7 @@ func syncPluginDaemonObjs(ctx context.Context, client k8sclient.Client, scheme *

// render plugin manifests
data := render.MakeRenderData()
data.Data["Namespace"] = namespace
data.Data["Namespace"] = vars.Namespace
data.Data["SRIOVDevicePluginImage"] = os.Getenv("SRIOV_DEVICE_PLUGIN_IMAGE")
data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION")
data.Data["ResourcePrefix"] = os.Getenv("RESOURCE_PREFIX")
Expand All @@ -94,7 +93,7 @@ func syncPluginDaemonObjs(ctx context.Context, client k8sclient.Client, scheme *

defaultConfig := &sriovnetworkv1.SriovOperatorConfig{}
err := client.Get(ctx, types.NamespacedName{
Name: constants.DefaultConfigName, Namespace: namespace}, defaultConfig)
Name: constants.DefaultConfigName, Namespace: vars.Namespace}, defaultConfig)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion controllers/sriovibnetwork_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
)

// SriovIBNetworkReconciler reconciles a SriovIBNetwork object
Expand All @@ -58,7 +59,7 @@ type SriovIBNetworkReconciler struct {
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
func (r *SriovIBNetworkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
// The SriovNetwork CR shall only be defined in operator namespace.
req.Namespace = namespace
req.Namespace = vars.Namespace
reqLogger := log.FromContext(ctx).WithValues("sriovnetwork", req.NamespacedName)
reqLogger.Info("Reconciling SriovIBNetwork")
var err error
Expand Down
3 changes: 2 additions & 1 deletion controllers/sriovnetwork_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
)

// SriovNetworkReconciler reconciles a SriovNetwork object
Expand All @@ -57,7 +58,7 @@ type SriovNetworkReconciler struct {
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
func (r *SriovNetworkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
req.Namespace = namespace
req.Namespace = vars.Namespace
reqLogger := log.FromContext(ctx).WithValues("sriovnetwork", req.NamespacedName)

reqLogger.Info("Reconciling SriovNetwork")
Expand Down
17 changes: 9 additions & 8 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

utils "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"

dptypes "github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/types"

Expand Down Expand Up @@ -82,11 +83,11 @@ func (r *SriovNetworkNodePolicyReconciler) Reconcile(ctx context.Context, req ct
reqLogger.Info("Reconciling")

defaultPolicy := &sriovnetworkv1.SriovNetworkNodePolicy{}
err := r.Get(ctx, types.NamespacedName{Name: constants.DefaultPolicyName, Namespace: namespace}, defaultPolicy)
err := r.Get(ctx, types.NamespacedName{Name: constants.DefaultPolicyName, Namespace: vars.Namespace}, defaultPolicy)
if err != nil {
if errors.IsNotFound(err) {
// Default policy object not found, create it.
defaultPolicy.SetNamespace(namespace)
defaultPolicy.SetNamespace(vars.Namespace)
defaultPolicy.SetName(constants.DefaultPolicyName)
defaultPolicy.Spec = sriovnetworkv1.SriovNetworkNodePolicySpec{
NumVfs: 0,
Expand All @@ -95,7 +96,7 @@ func (r *SriovNetworkNodePolicyReconciler) Reconcile(ctx context.Context, req ct
}
err = r.Create(ctx, defaultPolicy)
if err != nil {
reqLogger.Error(err, "Failed to create default Policy", "Namespace", namespace, "Name", constants.DefaultPolicyName)
reqLogger.Error(err, "Failed to create default Policy", "Namespace", vars.Namespace, "Name", constants.DefaultPolicyName)
return reconcile.Result{}, err
}
reqLogger.Info("Default policy created")
Expand Down Expand Up @@ -125,7 +126,7 @@ func (r *SriovNetworkNodePolicyReconciler) Reconcile(ctx context.Context, req ct
"kubernetes.io/os": "linux",
}
defaultOpConf := &sriovnetworkv1.SriovOperatorConfig{}
if err := r.Get(ctx, types.NamespacedName{Namespace: namespace, Name: constants.DefaultConfigName}, defaultOpConf); err != nil {
if err := r.Get(ctx, types.NamespacedName{Namespace: vars.Namespace, Name: constants.DefaultConfigName}, defaultOpConf); err != nil {
return reconcile.Result{}, err
}
if len(defaultOpConf.Spec.ConfigDaemonNodeSelector) > 0 {
Expand Down Expand Up @@ -216,7 +217,7 @@ func (r *SriovNetworkNodePolicyReconciler) syncDevicePluginConfigMap(ctx context
},
ObjectMeta: metav1.ObjectMeta{
Name: constants.ConfigMapName,
Namespace: namespace,
Namespace: vars.Namespace,
},
Data: configData,
}
Expand Down Expand Up @@ -246,14 +247,14 @@ func (r *SriovNetworkNodePolicyReconciler) syncAllSriovNetworkNodeStates(ctx con
logger := log.Log.WithName("syncAllSriovNetworkNodeStates")
logger.V(1).Info("Start to sync all SriovNetworkNodeState custom resource")
found := &corev1.ConfigMap{}
if err := r.Get(ctx, types.NamespacedName{Namespace: namespace, Name: constants.ConfigMapName}, found); err != nil {
if err := r.Get(ctx, types.NamespacedName{Namespace: vars.Namespace, Name: constants.ConfigMapName}, found); err != nil {
logger.V(1).Info("Fail to get", "ConfigMap", constants.ConfigMapName)
}
for _, node := range nl.Items {
logger.V(1).Info("Sync SriovNetworkNodeState CR", "name", node.Name)
ns := &sriovnetworkv1.SriovNetworkNodeState{}
ns.Name = node.Name
ns.Namespace = namespace
ns.Namespace = vars.Namespace
j, _ := json.Marshal(ns)
logger.V(2).Info("SriovNetworkNodeState CR", "content", j)
if err := r.syncSriovNetworkNodeState(ctx, np, npl, ns, &node, utils.HashConfigMap(found)); err != nil {
Expand Down Expand Up @@ -428,7 +429,7 @@ func (r *SriovNetworkNodePolicyReconciler) renderDevicePluginConfigData(ctx cont
}

nodeState := &sriovnetworkv1.SriovNetworkNodeState{}
err := r.Get(ctx, types.NamespacedName{Namespace: namespace, Name: node.Name}, nodeState)
err := r.Get(ctx, types.NamespacedName{Namespace: vars.Namespace, Name: node.Name}, nodeState)
if err != nil {
return rcl, err
}
Expand Down
3 changes: 2 additions & 1 deletion controllers/sriovnetworknodepolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
v1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
)

func TestNodeSelectorMerge(t *testing.T) {
Expand Down Expand Up @@ -213,7 +214,7 @@ func TestRenderDevicePluginConfigData(t *testing.T) {
reconciler := SriovNetworkNodePolicyReconciler{}

node := corev1.Node{ObjectMeta: metav1.ObjectMeta{Name: "node1"}}
nodeState := sriovnetworkv1.SriovNetworkNodeState{ObjectMeta: metav1.ObjectMeta{Name: node.Name, Namespace: namespace}}
nodeState := sriovnetworkv1.SriovNetworkNodeState{ObjectMeta: metav1.ObjectMeta{Name: node.Name, Namespace: vars.Namespace}}

scheme := runtime.NewScheme()
utilruntime.Must(sriovnetworkv1.AddToScheme(scheme))
Expand Down
14 changes: 7 additions & 7 deletions controllers/sriovoperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (r *SriovOperatorConfigReconciler) Reconcile(ctx context.Context, req ctrl.
}
defaultConfig := &sriovnetworkv1.SriovOperatorConfig{}
err := r.Get(ctx, types.NamespacedName{
Name: consts.DefaultConfigName, Namespace: namespace}, defaultConfig)
Name: consts.DefaultConfigName, Namespace: vars.Namespace}, defaultConfig)
if err != nil {
if apierrors.IsNotFound(err) {
singleNode, err := utils.IsSingleNodeCluster(r.Client)
Expand All @@ -86,7 +86,7 @@ func (r *SriovOperatorConfigReconciler) Reconcile(ctx context.Context, req ctrl.
}

// Default Config object not found, create it.
defaultConfig.SetNamespace(namespace)
defaultConfig.SetNamespace(vars.Namespace)
defaultConfig.SetName(consts.DefaultConfigName)
defaultConfig.Spec = sriovnetworkv1.SriovOperatorConfigSpec{
EnableInjector: func() *bool { b := vars.EnableAdmissionController; return &b }(),
Expand All @@ -100,7 +100,7 @@ func (r *SriovOperatorConfigReconciler) Reconcile(ctx context.Context, req ctrl.
err = r.Create(ctx, defaultConfig)
if err != nil {
logger.Error(err, "Failed to create default Operator Config", "Namespace",
namespace, "Name", consts.DefaultConfigName)
vars.Namespace, "Name", consts.DefaultConfigName)
return reconcile.Result{}, err
}
return reconcile.Result{}, nil
Expand All @@ -118,13 +118,13 @@ func (r *SriovOperatorConfigReconciler) Reconcile(ctx context.Context, req ctrl.
}

defaultPolicy := &sriovnetworkv1.SriovNetworkNodePolicy{}
err = r.Get(ctx, types.NamespacedName{Name: consts.DefaultPolicyName, Namespace: namespace}, defaultPolicy)
err = r.Get(ctx, types.NamespacedName{Name: consts.DefaultPolicyName, Namespace: vars.Namespace}, defaultPolicy)
if err != nil {
// Error reading the object - requeue the request.
return reconcile.Result{}, err
}

if req.Namespace != namespace {
if req.Namespace != vars.Namespace {
return reconcile.Result{}, nil
}

Expand Down Expand Up @@ -173,7 +173,7 @@ func (r *SriovOperatorConfigReconciler) syncConfigDaemonSet(ctx context.Context,

data := render.MakeRenderData()
data.Data["Image"] = os.Getenv("SRIOV_NETWORK_CONFIG_DAEMON_IMAGE")
data.Data["Namespace"] = namespace
data.Data["Namespace"] = vars.Namespace
data.Data["SRIOVCNIImage"] = os.Getenv("SRIOV_CNI_IMAGE")
data.Data["SRIOVInfiniBandCNIImage"] = os.Getenv("SRIOV_INFINIBAND_CNI_IMAGE")
data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION")
Expand Down Expand Up @@ -231,7 +231,7 @@ func (r *SriovOperatorConfigReconciler) syncWebhookObjs(ctx context.Context, dc
for name, path := range webhooks {
// Render Webhook manifests
data := render.MakeRenderData()
data.Data["Namespace"] = namespace
data.Data["Namespace"] = vars.Namespace
data.Data["SRIOVMutatingWebhookName"] = name
data.Data["NetworkResourcesInjectorImage"] = os.Getenv("NETWORK_RESOURCES_INJECTOR_IMAGE")
data.Data["SriovNetworkWebhookImage"] = os.Getenv("SRIOV_NETWORK_WEBHOOK_IMAGE")
Expand Down
5 changes: 3 additions & 2 deletions controllers/sriovoperatorconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import (

sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
constants "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars"
util "github.com/k8snetworkplumbingwg/sriov-network-operator/test/util"
)

var _ = Describe("Operator", func() {
var config *sriovnetworkv1.SriovOperatorConfig
BeforeEach(func() {
defaultPolicy := &sriovnetworkv1.SriovNetworkNodePolicy{}
defaultPolicy.SetNamespace(namespace)
defaultPolicy.SetNamespace(vars.Namespace)
defaultPolicy.SetName(constants.DefaultPolicyName)
defaultPolicy.Spec = sriovnetworkv1.SriovNetworkNodePolicySpec{
NumVfs: 0,
Expand All @@ -30,7 +31,7 @@ var _ = Describe("Operator", func() {
})
AfterEach(func() {
defaultPolicy := &sriovnetworkv1.SriovNetworkNodePolicy{}
defaultPolicy.SetNamespace(namespace)
defaultPolicy.SetNamespace(vars.Namespace)
defaultPolicy.SetName(constants.DefaultPolicyName)
Expect(k8sClient.Delete(goctx.TODO(), defaultPolicy)).Should(Succeed())
})
Expand Down
20 changes: 9 additions & 11 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ const (
annoMcpPaused = "Draining_MCP_Paused"
)

var namespace = os.Getenv("NAMESPACE")

// writer implements io.Writer interface as a pass-through for log.Log.
type writer struct {
logFunc func(msg string, keysAndValues ...interface{})
Expand Down Expand Up @@ -210,7 +208,7 @@ func (dn *Daemon) Run(stopCh <-chan struct{}, exitCh <-chan error) error {
dn.mu = &sync.Mutex{}
informerFactory := sninformer.NewFilteredSharedInformerFactory(dn.client,
time.Second*15,
namespace,
vars.Namespace,
func(lo *metav1.ListOptions) {
lo.FieldSelector = metadataKey + "=" + vars.NodeName
lo.TimeoutSeconds = &timeout
Expand All @@ -227,7 +225,7 @@ func (dn *Daemon) Run(stopCh <-chan struct{}, exitCh <-chan error) error {

cfgInformerFactory := sninformer.NewFilteredSharedInformerFactory(dn.client,
time.Second*30,
namespace,
vars.Namespace,
func(lo *metav1.ListOptions) {
lo.FieldSelector = metadataKey + "=" + "default"
},
Expand Down Expand Up @@ -410,7 +408,7 @@ func (dn *Daemon) nodeStateSyncHandler() error {
// Get the latest NodeState
var latestState *sriovnetworkv1.SriovNetworkNodeState
var sriovResult = &systemd.SriovResult{SyncStatus: consts.SyncStatusSucceeded, LastSyncError: ""}
latestState, err = dn.client.SriovnetworkV1().SriovNetworkNodeStates(namespace).Get(context.Background(), vars.NodeName, metav1.GetOptions{})
latestState, err = dn.client.SriovnetworkV1().SriovNetworkNodeStates(vars.Namespace).Get(context.Background(), vars.NodeName, metav1.GetOptions{})
if err != nil {
log.Log.Error(err, "nodeStateSyncHandler(): Failed to fetch node state", "name", vars.NodeName)
return err
Expand Down Expand Up @@ -502,7 +500,7 @@ func (dn *Daemon) nodeStateSyncHandler() error {
// we need to load the latest status to our object
// if we don't do it we can have a race here where the user remove the virtual functions but the operator didn't
// trigger the refresh
updatedState, err := dn.client.SriovnetworkV1().SriovNetworkNodeStates(namespace).Get(context.Background(), vars.NodeName, metav1.GetOptions{})
updatedState, err := dn.client.SriovnetworkV1().SriovNetworkNodeStates(vars.Namespace).Get(context.Background(), vars.NodeName, metav1.GetOptions{})
if err != nil {
log.Log.Error(err, "nodeStateSyncHandler(): Failed to fetch node state", "name", vars.NodeName)
return err
Expand Down Expand Up @@ -733,7 +731,7 @@ func (dn *Daemon) restartDevicePluginPod() error {
log.Log.V(2).Info("restartDevicePluginPod(): try to restart device plugin pod")

var podToDelete string
pods, err := dn.kubeClient.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{
pods, err := dn.kubeClient.CoreV1().Pods(vars.Namespace).List(context.Background(), metav1.ListOptions{
LabelSelector: "app=sriov-device-plugin",
FieldSelector: "spec.nodeName=" + vars.NodeName,
})
Expand All @@ -753,7 +751,7 @@ func (dn *Daemon) restartDevicePluginPod() error {
podToDelete = pods.Items[0].Name

log.Log.V(2).Info("restartDevicePluginPod(): Found device plugin pod, deleting it", "pod-name", podToDelete)
err = dn.kubeClient.CoreV1().Pods(namespace).Delete(context.Background(), podToDelete, metav1.DeleteOptions{})
err = dn.kubeClient.CoreV1().Pods(vars.Namespace).Delete(context.Background(), podToDelete, metav1.DeleteOptions{})
if errors.IsNotFound(err) {
log.Log.Info("restartDevicePluginPod(): pod to delete not found")
return nil
Expand All @@ -764,7 +762,7 @@ func (dn *Daemon) restartDevicePluginPod() error {
}

if err := wait.PollImmediateUntil(3*time.Second, func() (bool, error) {
_, err := dn.kubeClient.CoreV1().Pods(namespace).Get(context.Background(), podToDelete, metav1.GetOptions{})
_, err := dn.kubeClient.CoreV1().Pods(vars.Namespace).Get(context.Background(), podToDelete, metav1.GetOptions{})
if errors.IsNotFound(err) {
log.Log.Info("restartDevicePluginPod(): device plugin pod exited")
return true, nil
Expand Down Expand Up @@ -875,7 +873,7 @@ func (dn *Daemon) getDrainLock(ctx context.Context, done chan bool) {
lock := &resourcelock.LeaseLock{
LeaseMeta: metav1.ObjectMeta{
Name: "config-daemon-draining-lock",
Namespace: namespace,
Namespace: vars.Namespace,
},
Client: dn.kubeClient.CoordinationV1(),
LockConfig: resourcelock.ResourceLockConfig{
Expand Down Expand Up @@ -1052,7 +1050,7 @@ func (dn *Daemon) drainNode() error {
// TODO: move this to host interface
func (dn *Daemon) tryCreateSwitchdevUdevRule() error {
log.Log.V(2).Info("tryCreateSwitchdevUdevRule()")
nodeState, nodeStateErr := dn.client.SriovnetworkV1().SriovNetworkNodeStates(namespace).Get(
nodeState, nodeStateErr := dn.client.SriovnetworkV1().SriovNetworkNodeStates(vars.Namespace).Get(
context.Background(),
vars.NodeName,
metav1.GetOptions{},
Expand Down
12 changes: 6 additions & 6 deletions pkg/daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
var FakeSupportedNicIDs corev1.ConfigMap = corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: sriovnetworkv1.SupportedNicIDConfigmap,
Namespace: namespace,
Namespace: vars.Namespace,
},
Data: map[string]string{
"Intel_i40e_XXV710": "8086 158a 154c",
Expand All @@ -41,7 +41,7 @@ var FakeSupportedNicIDs corev1.ConfigMap = corev1.ConfigMap{
var SriovDevicePluginPod corev1.Pod = corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "sriov-device-plugin-xxxx",
Namespace: namespace,
Namespace: vars.Namespace,
Labels: map[string]string{
"app": "sriov-device-plugin",
},
Expand Down Expand Up @@ -110,7 +110,7 @@ var _ = Describe("Config Daemon", func() {
kubeClient := fakek8s.NewSimpleClientset(&FakeSupportedNicIDs, &SriovDevicePluginPod)
client := fakesnclientset.NewSimpleClientset()

err = sriovnetworkv1.InitNicIDMapFromConfigMap(kubeClient, namespace)
err = sriovnetworkv1.InitNicIDMapFromConfigMap(kubeClient, vars.Namespace)
Expect(err).ToNot(HaveOccurred())

er := NewEventRecorder(client, kubeClient)
Expand Down Expand Up @@ -203,7 +203,7 @@ var _ = Describe("Config Daemon", func() {
Expect(msg.syncStatus).To(Equal("Succeeded"))

Eventually(func() (int, error) {
podList, err := sut.kubeClient.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{
podList, err := sut.kubeClient.CoreV1().Pods(vars.Namespace).List(context.Background(), metav1.ListOptions{
LabelSelector: "app=sriov-device-plugin",
FieldSelector: "spec.nodeName=test-node",
})
Expand Down Expand Up @@ -260,14 +260,14 @@ var _ = Describe("Config Daemon", func() {

func createSriovNetworkNodeState(c snclientset.Interface, nodeState *sriovnetworkv1.SriovNetworkNodeState) error {
_, err := c.SriovnetworkV1().
SriovNetworkNodeStates(namespace).
SriovNetworkNodeStates(vars.Namespace).
Create(context.Background(), nodeState, metav1.CreateOptions{})
return err
}

func updateSriovNetworkNodeState(c snclientset.Interface, nodeState *sriovnetworkv1.SriovNetworkNodeState) error {
_, err := c.SriovnetworkV1().
SriovNetworkNodeStates(namespace).
SriovNetworkNodeStates(vars.Namespace).
Update(context.Background(), nodeState, metav1.UpdateOptions{})
return err
}
2 changes: 1 addition & 1 deletion pkg/daemon/event_recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewEventRecorder(c snclientset.Interface, kubeclient kubernetes.Interface)

// SendEvent Send an Event on the NodeState object
func (e *EventRecorder) SendEvent(eventType string, msg string) {
nodeState, err := e.client.SriovnetworkV1().SriovNetworkNodeStates(namespace).Get(context.Background(), vars.NodeName, metav1.GetOptions{})
nodeState, err := e.client.SriovnetworkV1().SriovNetworkNodeStates(vars.Namespace).Get(context.Background(), vars.NodeName, metav1.GetOptions{})
if err != nil {
log.Log.V(2).Error(err, "SendEvent(): Failed to fetch node state, skip SendEvent", "name", vars.NodeName)
return
Expand Down
Loading

0 comments on commit da7011a

Please sign in to comment.