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

Refactor Pool-manager tests #448

Merged
merged 5 commits into from
Jan 6, 2025
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22.0

require (
github.com/go-logr/logr v1.2.4
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.2-0.20221215110210-ad3f3381681f
github.com/onsi/ginkgo/v2 v2.9.4
github.com/onsi/gomega v1.27.6
github.com/pkg/errors v0.9.1
Expand Down Expand Up @@ -52,7 +53,6 @@ require (
github.com/imdario/mergo v0.3.15 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.2-0.20221215110210-ad3f3381681f // indirect
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
Expand Down
10 changes: 6 additions & 4 deletions pkg/pool-manager/pod_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
)

const tempPodName = "tempPodName"
Expand All @@ -40,7 +42,7 @@ func (p *PoolManager) AllocatePodMac(pod *corev1.Pod, isNotDryRun bool) error {
"macmap", p.macPoolMap,
"currentMac", p.currentMac.String())

networkValue, ok := pod.Annotations[NetworksAnnotation]
networkValue, ok := pod.Annotations[networkv1.NetworkAttachmentAnnot]
if !ok {
return nil
}
Expand All @@ -49,7 +51,7 @@ func (p *PoolManager) AllocatePodMac(pod *corev1.Pod, isNotDryRun bool) error {
// we want to connect the allocated mac from the webhook to a pod object in the podToMacPoolMap
// run it before multus added the status annotation
// this mean the pod is not ready
if _, ok := pod.Annotations[networksStatusAnnotation]; ok {
if _, ok := pod.Annotations[networkv1.NetworkStatusAnnot]; ok {
return nil
}

Expand Down Expand Up @@ -97,7 +99,7 @@ func (p *PoolManager) AllocatePodMac(pod *corev1.Pod, isNotDryRun bool) error {
if err != nil {
return err
}
pod.Annotations[NetworksAnnotation] = string(networkListJson)
pod.Annotations[networkv1.NetworkAttachmentAnnot] = string(networkListJson)

return nil
}
Expand Down Expand Up @@ -238,7 +240,7 @@ func (p *PoolManager) initPodMap() error {
continue
}

networkValue, ok := pod.Annotations[NetworksAnnotation]
networkValue, ok := pod.Annotations[networkv1.NetworkAttachmentAnnot]
if !ok {
continue
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/pool-manager/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ const (
RangeStartEnv = "RANGE_START"
RangeEndEnv = "RANGE_END"
RuntimeObjectFinalizerName = "k8s.v1.cni.cncf.io/kubeMacPool"
NetworksAnnotation = "k8s.v1.cni.cncf.io/networks"
networksStatusAnnotation = "k8s.v1.cni.cncf.io/networks-status"
TransactionTimestampAnnotation = "kubemacpool.io/transaction-timestamp"
mutatingWebhookConfigName = "kubemacpool-mutator"
virtualMachnesWebhookName = "mutatevirtualmachines.kubemacpool.io"
Expand Down
Loading
Loading