Skip to content

Commit

Permalink
Merge pull request #734 from BSWANG/main
Browse files Browse the repository at this point in the history
omit pod erdma resource when daemon not enable erdma
  • Loading branch information
l1b0k authored Dec 3, 2024
2 parents b1a1e7c + 2eaf382 commit a030031
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func NewK8S(daemonMode string, globalConfig *daemon.Config) (Kubernetes, error)
broadcaster: broadcaster,
recorder: recorder,
Locker: &sync.RWMutex{},
enableErdma: globalConfig.EnableERDMA,
}

svcCIDR := &types.IPNetSet{}
Expand Down Expand Up @@ -204,6 +205,7 @@ type k8s struct {
node *corev1.Node
svcCIDR *types.IPNetSet
statefulWorkloadKindSet sets.Set[string]
enableErdma bool

sync.Locker
}
Expand Down Expand Up @@ -350,7 +352,7 @@ func (k *k8s) GetPod(ctx context.Context, namespace, name string, cache bool) (*
}
return nil, err
}
podInfo := convertPod(k.mode, k.statefulWorkloadKindSet, pod)
podInfo := convertPod(k.mode, k.enableErdma, k.statefulWorkloadKindSet, pod)
item := &storageItem{
Pod: podInfo,
}
Expand Down Expand Up @@ -393,7 +395,7 @@ func (k *k8s) GetLocalPods() ([]*daemon.PodInfo, error) {
continue
}

podInfo := convertPod(k.mode, k.statefulWorkloadKindSet, &pod)
podInfo := convertPod(k.mode, k.enableErdma, k.statefulWorkloadKindSet, &pod)
ret = append(ret, podInfo)
}

Expand Down Expand Up @@ -534,7 +536,7 @@ func podNetworkType(daemonMode string, pod *corev1.Pod) string {
panic(fmt.Errorf("unknown daemon mode %s", daemonMode))
}

func convertPod(daemonMode string, statefulWorkloadKindSet sets.Set[string], pod *corev1.Pod) *daemon.PodInfo {
func convertPod(daemonMode string, enableErdma bool, statefulWorkloadKindSet sets.Set[string], pod *corev1.Pod) *daemon.PodInfo {
pi := &daemon.PodInfo{
Name: pod.Name,
Namespace: pod.Namespace,
Expand Down Expand Up @@ -588,7 +590,9 @@ func convertPod(daemonMode string, statefulWorkloadKindSet sets.Set[string], pod
}
}

pi.ERdma = isERDMA(pod)
if enableErdma {
pi.ERdma = isERDMA(pod)
}

// determine whether pod's IP will stick 5 minutes for a reuse, priorities as below,
// 1. pod has a positive pod-ip-reservation annotation
Expand Down

0 comments on commit a030031

Please sign in to comment.