Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix panic & hub without dedinic #87

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/cnf/CNFManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ type Manager struct {
}

func (m *Manager) Run(ctx context.Context) error {
go m.startLeaderElection(m.leaderLock, ctx)
if !m.agentSpec.AsHub {
go m.startLeaderElection(m.leaderLock, ctx)
m.dedinicEngine(ctx)
} else {
m.startLeaderElection(m.leaderLock, ctx)
}
return nil
}

func (m *Manager) dedinicEngine(ctx context.Context) {
dedinic.CNFPodName = os.Getenv("NAUTI_PODNAME")
if dedinic.CNFPodName == "" {
klog.Fatalf("get self pod name failed")
Expand All @@ -68,7 +76,6 @@ func (m *Manager) Run(ctx context.Context) error {

klog.Info("start nri dedicated plugin run")
dedinic.InitNRIPlugin(m.localK8sClient)
return nil
}

// NewCNFManager returns a new CNFController.
Expand Down
3 changes: 2 additions & 1 deletion pkg/dedinic/cni_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ func (ch cniHandler) updateTheIPToPod(podName, podNamespace, ip string) error {
// Get the Pod
pod, err := ch.kubeClient.CoreV1().Pods(podNamespace).Get(context.TODO(), podName, metav1.GetOptions{})
if err != nil {
panic(err.Error())
klog.Errorf("can not find the pod: %v/%v", podNamespace, podName)
return err
}

// Add an annotation to the Pod
Expand Down
Loading