Skip to content

Commit

Permalink
Init sriovnetworkv1.NicIdMap on operator startup
Browse files Browse the repository at this point in the history
After moving sriovnetworkv1.NicIdMap into ConfigMap we need to
initialize it's data on operator startup.

Signed-off-by: Ivan Kolodyazhny <[email protected]>
  • Loading branch information
e0ne committed Jul 29, 2021
1 parent 348e699 commit 31ca34e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -99,6 +100,11 @@ func main() {
os.Exit(1)
}

if err := initNicIdMap(); err != nil {
setupLog.Error(err, "unable to init NicIdMap")
os.Exit(1)
}

if err = (&controllers.SriovNetworkReconciler{
Client: mgrGlobal.GetClient(),
Scheme: mgrGlobal.GetScheme(),
Expand Down Expand Up @@ -174,6 +180,16 @@ func main() {
}
}

func initNicIdMap() error {
namespace := os.Getenv("NAMESPACE")
kubeclient := kubernetes.NewForConfigOrDie(ctrl.GetConfigOrDie())
if err := sriovnetworkv1.InitNicIdMap(kubeclient, namespace); err != nil {
return err
}

return nil
}

func createDefaultPolicy(cfg *rest.Config) error {
logger := setupLog.WithName("createDefaultPolicy")
c, err := client.New(cfg, client.Options{Scheme: scheme})
Expand Down

0 comments on commit 31ca34e

Please sign in to comment.