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

Migrations to golang 1.19 #271

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 1 addition & 4 deletions e2e/client/ippool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ package client

import (
"context"
"errors"
"fmt"
"time"

kubeClient "github.com/k8snetworkplumbingwg/whereabouts/pkg/storage/kubernetes"
Expand All @@ -16,8 +14,7 @@ import (
func isIPPoolAllocationsEmpty(k8sIPAM *kubeClient.KubernetesIPAM, ipPoolName string) wait.ConditionFunc {
return func() (bool, error) {
ipPool, err := k8sIPAM.GetIPPool(context.Background(), ipPoolName)
noPoolError := fmt.Errorf("k8s pool initialized")
if errors.As(err, &noPoolError) {
if err.Error() == kubeClient.ErrKMsg8sPoolInit {
kmlebedev marked this conversation as resolved.
Show resolved Hide resolved
return true, nil
} else if err != nil {
return false, err
Expand Down
6 changes: 5 additions & 1 deletion pkg/storage/kubernetes/ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (
"gomodules.xyz/jsonpatch/v2"
)

const (
ErrKMsg8sPoolInit = "k8s pool initialized"
kmlebedev marked this conversation as resolved.
Show resolved Hide resolved
)

// NewKubernetesIPAM returns a new KubernetesIPAM Client configured to a kubernetes CRD backend
func NewKubernetesIPAM(containerID string, ipamConf whereaboutstypes.IPAMConfig) (*KubernetesIPAM, error) {
var namespace string
Expand Down Expand Up @@ -144,7 +148,7 @@ func (i *KubernetesIPAM) getPool(ctx context.Context, name string, iprange strin
}
// if the pool was created for the first time, trigger another retry of the allocation loop
// so all of the metadata / resourceVersions are populated as necessary by the `client.Get` call
return nil, &temporaryError{fmt.Errorf("k8s pool initialized")}
return nil, &temporaryError{fmt.Errorf(ErrKMsg8sPoolInit)}
} else if err != nil {
return nil, fmt.Errorf("k8s get error: %s", err)
}
Expand Down