Skip to content

Commit

Permalink
static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelichkovich committed Jun 17, 2024
1 parent 4ff1ccb commit 4780eea
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
2 changes: 1 addition & 1 deletion e2e/e2e_node_slice/e2e_node_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = Describe("Whereabouts node slice functionality", func() {
testNamespace = "default"
ipv4TestRange = "10.0.0.0/8"
sliceSize = "/20" // tests will depend on subnets being > node count of test environment
testNetworkName = "wa-nad"
testNetworkName = "net1"
subnets = 4096
rsName = "whereabouts-scale-test"
)
Expand Down
50 changes: 0 additions & 50 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"context"
"fmt"
"github.com/k8snetworkplumbingwg/whereabouts/e2e/util"
"k8s.io/client-go/tools/clientcmd"
"net"
"os"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -900,59 +898,11 @@ func allocationForPodRef(podRef string, ipPool v1alpha1.IPPool) []v1alpha1.IPAll
return allocations
}

func clusterConfig() (*rest.Config, error) {
const kubeconfig = "KUBECONFIG"

kubeconfigPath, found := os.LookupEnv(kubeconfig)
if !found {
return nil, fmt.Errorf("must provide the path to the kubeconfig via the `KUBECONFIG` env variable")
}

config, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
if err != nil {
return nil, err
}
return config, nil
}

func podTierLabel(podTier string) map[string]string {
const tier = "tier"
return map[string]string{tier: podTier}
}

// Waits for all replicas to be fully removed from replicaset, and checks that there are 0 ip pool allocations
func checkZeroIPPoolAllocationsAndReplicas(ctx context.Context, clientInfo *wbtestclient.ClientInfo, k8sIPAM *wbstorage.KubernetesIPAM, rsName, namespace string, ipPoolCIDR string, networkNames ...string) error {
const (
emptyReplicaSet = 0
rsSteadyTimeout = 1200 * time.Second
zeroIPPoolTimeout = 2 * time.Minute
)
var err error

replicaSet, err := clientInfo.UpdateReplicaSet(
entities.ReplicaSetObject(
emptyReplicaSet,
rsName,
namespace,
podTierLabel(rsName),
entities.PodNetworkSelectionElements(networkNames...),
))
if err != nil {
return err
}

matchingLabel := entities.ReplicaSetQuery(rsName)
if err = wbtestclient.WaitForReplicaSetSteadyState(ctx, clientInfo.Client, namespace, matchingLabel, replicaSet, rsSteadyTimeout); err != nil {
return err
}

if err = wbtestclient.WaitForZeroIPPoolAllocations(ctx, k8sIPAM, ipPoolCIDR, zeroIPPoolTimeout); err != nil {
return err
}

return nil
}

// Returns a network attachment definition object configured by provided parameters
func generateNetAttachDefSpec(name, namespace, config string) *nettypes.NetworkAttachmentDefinition {
return &nettypes.NetworkAttachmentDefinition{
Expand Down

0 comments on commit 4780eea

Please sign in to comment.