jiebi/CodeConvo huggingface dataset:
github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= <del> github.com/google/cadvisor v0.38.5 h1:XOvqjL2+xMEuDORcLMv77NystZvQB7YgGxcKpRul/vE= github.com/google/cadvisor v0.38.5/go.mod h1:1OFB9sOOMkBdUBGCO/1SArawTnDscgMzTodacVDe8mA= </del> <ins> github.com/google/cadvisor v0.38.6 h1:5vu8NaOqsBKF6wOxBLeDPD7hcmxfg/4I5NZGYXK7gIo= github.com/google/cadvisor v0.38.6/go.mod h1:1OFB9sOOMkBdUBGCO/1SArawTnDscgMzTodacVDe8mA= </ins> github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
tryConn.Close() connParams := grpc.ConnectParams{ <del> Backoff: backoff.Config{ BaseDelay: baseBackoffDelay, MaxDelay:  maxBackoffDelay, }, </del> <ins> Backoff: backoff.DefaultConfig, </ins> } <ins> connParams.Backoff.BaseDelay = baseBackoffDelay connParams.Backoff.MaxDelay = maxBackoffDelay </ins> gopts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithContextDialer(dialer.ContextDialer),
# github.com/google/btree v1.0.0 => github.com/google/btree v1.0.0 github.com/google/btree # github.com/google/btree => github.com/google/btree v1.0.0 <del> # github.com/google/cadvisor v0.38.5 => github.com/google/cadvisor v0.38.5 </del> <ins> # github.com/google/cadvisor v0.38.6 => github.com/google/cadvisor v0.38.6 </ins> ## explicit <del> # github.com/google/cadvisor => github.com/google/cadvisor v0.38.5 </del> <ins> # github.com/google/cadvisor => github.com/google/cadvisor v0.38.6 </ins> github.com/google/cadvisor/accelerators github.com/google/cadvisor/cache/memory github.com/google/cadvisor/client/v2
ADD bin/pause-windows-${ARCH}.exe /pause.exe ADD bin/wincat-windows-amd64 /Windows/System32/wincat.exe <ins> # NOTE(claudiub): We're replacing the diagtrack.dll as a means to disable the # DiagTrack service (it cannot run without this DLL). We do not need this # service in the pause image and there's no reason for it to have any CPU usage. ADD windows/pause.c /Windows/System32/diagtrack.dll </ins> # NOTE(claudiub): docker buildx sets the PATH env variable to a Linux-like PATH, # which is not desirable. See: https://github.com/moby/buildkit/issues/1560 # TODO(claudiub): remove this once the issue has been resolved.
serviceName = "kubelet" ) <del> func initForOS(windowsService bool) error { </del> <ins> // getPriorityValue returns the value associated with a Windows process priorityClass // Ref: https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/setpriority-method-in-class-win32-process func getPriorityValue(priorityClassName string) uint32 { var priorityClassMap = map[string]uint32{ "IDLE_PRIORITY_CLASS":         uint32(64), "BELOW_NORMAL_PRIORITY_CLASS": uint32(16384), "NORMAL_PRIORITY_CLASS":       uint32(32), "ABOVE_NORMAL_PRIORITY_CLASS": uint32(32768), "HIGH_PRIORITY_CLASS":         uint32(128), "REALTIME_PRIORITY_CLASS":     uint32(256), } return priorityClassMap[priorityClassName] } func initForOS(windowsService bool, windowsPriorityClass string) error { priority := getPriorityValue(windowsPriorityClass) if priority == 0 { return fmt.Errorf("unknown priority class %s, valid ones are available at "+ "https://docs.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities", windowsPriorityClass) } kubeletProcessHandle := windows.CurrentProcess() // Set the priority of the kubelet process to given priority klog.Infof("Setting the priority of kubelet process to %s", windowsPriorityClass) if err := windows.SetPriorityClass(kubeletProcessHandle, priority); err != nil { return err } </ins> if windowsService { return service.InitService(serviceName) }
<ins> /* Copyright 2020 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package app import "testing" func TestIsValidPriorityClass(t *testing.T) { testCases := []struct { description           string priorityClassName     string expectedPriorityValue uint32 }{ { description:           "Invalid Priority Class", priorityClassName:     "myPriorityClass", expectedPriorityValue: 0, }, { description:           "Valid Priority Class", priorityClassName:     "IDLE_PRIORITY_CLASS", expectedPriorityValue: uint32(64), }, } for _, test := range testCases { actualPriorityValue := getPriorityValue(test.priorityClassName) if test.expectedPriorityValue != actualPriorityValue { t.Fatalf("unexpected error for %s", test.description) } } } </ins>
// Its corresponding flag only gets registered in Windows builds. WindowsService bool <ins> // WindowsPriorityClass sets the priority class associated with the Kubelet process // Its corresponding flag only gets registered in Windows builds // The default priority class associated with any process in Windows is NORMAL_PRIORITY_CLASS. Keeping it as is // to maintain backwards compatibility. // Source: https://docs.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities WindowsPriorityClass string </ins> // remoteRuntimeEndpoint is the endpoint of remote runtime service RemoteRuntimeEndpoint string // remoteImageEndpoint is the endpoint of remote image service
func (f *KubeletFlags) addOSFlags(fs *pflag.FlagSet) { fs.BoolVar(&f.WindowsService, "windows-service", f.WindowsService, "Enable Windows Service Control Manager API integration") <ins> // The default priority class associated with any process in Windows is NORMAL_PRIORITY_CLASS. Keeping it as is // to maintain backwards compatibility. // Source: https://docs.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities fs.StringVar(&f.WindowsPriorityClass, "windows-priorityclass", "NORMAL_PRIORITY_CLASS", "Set the PriorityClass associated with kubelet process, the default ones are available at "+ "https://docs.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities") </ins> }
logOption.Apply() // To help debugging, immediately log version klog.Infof("Version: %+v", version.Get()) <del> if err := initForOS(s.KubeletFlags.WindowsService); err != nil { </del> <ins> if err := initForOS(s.KubeletFlags.WindowsService, s.KubeletFlags.WindowsPriorityClass); err != nil { </ins> return fmt.Errorf("failed OS init: %v", err) } if err := run(ctx, s, kubeDeps, featureGate); err != nil {
allowAnyProfile = true continue } <ins> // With the graduation of seccomp to GA we automatically convert // the deprecated seccomp profile annotation `docker/default` to // `runtime/default`. This means that we now have to automatically // allow `runtime/default` if a user specifies `docker/default` and // vice versa in a PSP. if p == v1.DeprecatedSeccompProfileDockerDefault || p == v1.SeccompProfileRuntimeDefault { allowedProfiles[v1.SeccompProfileRuntimeDefault] = true allowedProfiles[v1.DeprecatedSeccompProfileDockerDefault] = true } </ins> allowedProfiles[p] = true } }
allowSpecificLocalhost = map[string]string{ AllowedProfilesAnnotationKey: v1.SeccompLocalhostProfileNamePrefix + "foo", } <ins> allowSpecificDockerDefault = map[string]string{ AllowedProfilesAnnotationKey: v1.DeprecatedSeccompProfileDockerDefault, } allowSpecificRuntimeDefault = map[string]string{ AllowedProfilesAnnotationKey: v1.SeccompProfileRuntimeDefault, } </ins> ) func TestNewStrategy(t *testing.T) {
}, expectedError: "", }, <ins> "docker/default PSP annotation automatically allows runtime/default pods": { pspAnnotations: allowSpecificDockerDefault, podAnnotations: map[string]string{ api.SeccompPodAnnotationKey: v1.SeccompProfileRuntimeDefault, }, expectedError: "", }, "runtime/default PSP annotation automatically allows docker/default pods": { pspAnnotations: allowSpecificRuntimeDefault, podAnnotations: map[string]string{ api.SeccompPodAnnotationKey: v1.DeprecatedSeccompProfileDockerDefault, }, expectedError: "", }, </ins> } for k, v := range tests { pod := &api.Pod{
codename: '[sig-cli] Kubectl client Kubectl server-side dry-run should check if kubectl can dry-run update Pods [Conformance]' description: The command 'kubectl run' must create a pod with the specified image <del> name. After, the command 'kubectl replace --dry-run=server' should update the Pod with the new image name and server-side dry-run enabled. The image name must not change. </del> <ins> name. After, the command 'kubectl patch pod -p {...} --dry-run=server' should update the Pod with the new image name and server-side dry-run enabled. The image name must not change. </ins> release: v1.19 file: test/e2e/kubectl/kubectl.go - testname: Kubectl, version
/* Release: v1.19 Testname: Kubectl, server-side dry-run Pod <del> Description: The command 'kubectl run' must create a pod with the specified image name. After, the command 'kubectl replace --dry-run=server' should update the Pod with the new image name and server-side dry-run enabled. The image name must not change. </del> <ins> Description: The command 'kubectl run' must create a pod with the specified image name. After, the command 'kubectl patch pod -p {...} --dry-run=server' should update the Pod with the new image name and server-side dry-run enabled. The image name must not change. </ins> */ framework.ConformanceIt("should check if kubectl can dry-run update Pods", func() { ginkgo.By("running the image " + httpdImage)
framework.RunKubectlOrDie(ns, "run", podName, "--image="+httpdImage, "--labels=run="+podName) ginkgo.By("replace the image in the pod with server-side dry-run") <del> podJSON := framework.RunKubectlOrDie(ns, "get", "pod", podName, "-o", "json") podJSON = strings.Replace(podJSON, httpdImage, busyboxImage, 1) if !strings.Contains(podJSON, busyboxImage) { framework.Failf("Failed replacing image from %s to %s in:n%sn", httpdImage, busyboxImage, podJSON) } framework.RunKubectlOrDieInput(ns, podJSON, "replace", "-f", "-", "--dry-run=server") </del> <ins> specImage := fmt.Sprintf(`{"spec":{"containers":[{"name": "%s","image": "%s"}]}}`, podName, busyboxImage) framework.RunKubectlOrDie(ns, "patch", "pod", podName, "-p", specImage, "--dry-run=server") </ins> ginkgo.By("verifying the pod " + podName + " has the right image " + httpdImage) pod, err := c.CoreV1().Pods(ns).Get(context.TODO(), podName, metav1.GetOptions{})
type timeBudgetImpl struct { sync.Mutex <del> budget time.Duration refresh   time.Duration </del> <ins> clock     clock.Clock budget    time.Duration </ins> maxBudget time.Duration <ins> refresh   time.Duration // last store last access time last time.Time </ins> } <del> func newTimeBudget(stopCh <-chan struct{}) timeBudget { </del> <ins> func newTimeBudget() timeBudget { </ins> result := &timeBudgetImpl{ <ins> clock:     clock.RealClock{}, </ins> budget:    time.Duration(0), refresh:   refreshPerSecond, maxBudget: maxBudget, } <del> go result.periodicallyRefresh(stopCh) </del> <ins> result.last = result.clock.Now() </ins> return result } <del> func (t *timeBudgetImpl) periodicallyRefresh(stopCh <-chan struct{}) { ticker := time.NewTicker(time.Second) defer ticker.Stop() for { select { case <-ticker.C: t.Lock() if t.budget = t.budget + t.refresh; t.budget > t.maxBudget { t.budget = t.maxBudget } t.Unlock() case <-stopCh: return } } } </del> func (t *timeBudgetImpl) takeAvailable() time.Duration { t.Lock() defer t.Unlock() <ins> // budget accumulated since last access now := t.clock.Now() acc := now.Sub(t.last).Seconds() * t.refresh.Seconds() if acc < 0 { acc = 0 } // update current budget and store the current time if t.budget = t.budget + time.Duration(acc*1e9); t.budget > t.maxBudget { t.budget = t.maxBudget } t.last = now </ins> result := t.budget t.budget = time.Duration(0) return result
import ( "testing" "time" <ins> "k8s.io/apimachinery/pkg/util/clock" </ins> ) func TestTimeBudget(t *testing.T) { <ins> fakeClock := clock.NewFakeClock(time.Now()) </ins> budget := &timeBudgetImpl{ <ins> clock:     fakeClock, </ins> budget:    time.Duration(0), <del> maxBudget: time.Duration(200), </del> <ins> maxBudget: 200 * time.Millisecond, refresh:   50 * time.Millisecond, last:      fakeClock.Now(), </ins> } if res := budget.takeAvailable(); res != time.Duration(0) { t.Errorf("Expected: %v, got: %v", time.Duration(0), res) } <del> budget.budget = time.Duration(100) if res := budget.takeAvailable(); res != time.Duration(100) { t.Errorf("Expected: %v, got: %v", time.Duration(100), res) </del> <ins> // wait for longer than the maxBudget nextTime := time.Now().Add(10 * time.Second) fakeClock.SetTime(nextTime) if res := budget.takeAvailable(); res != budget.maxBudget { t.Errorf("Expected: %v, got: %v", budget.maxBudget, res) } // add two refresh intervals to accumulate 2*refresh durations nextTime = nextTime.Add(2 * time.Second) fakeClock.SetTime(nextTime) if res := budget.takeAvailable(); res != 2*budget.refresh { t.Errorf("Expected: %v, got: %v", 2*budget.refresh, res) } // return one refresh duration to have only one refresh duration available // we didn't advanced on time yet budget.returnUnused(budget.refresh) if res := budget.takeAvailable(); res != budget.refresh { t.Errorf("Expected: %v, got: %v", budget.refresh, res) </ins> } <ins> // return a negative value to the budget // we didn't advanced on time yet budget.returnUnused(-time.Duration(50)) </ins> if res := budget.takeAvailable(); res != time.Duration(0) { t.Errorf("Expected: %v, got: %v", time.Duration(0), res) } <del> budget.returnUnused(time.Duration(50)) if res := budget.takeAvailable(); res != time.Duration(50) { t.Errorf("Expected: %v, got: %v", time.Duration(50), res) </del> <ins> // handle back in time problem with an empty budget nextTime = nextTime.Add(-2 * time.Minute) fakeClock.SetTime(nextTime) if res := budget.takeAvailable(); res != time.Duration(0) { t.Errorf("Expected: %v, got: %v", time.Duration(0), res) </ins> } <del> budget.budget = time.Duration(100) budget.returnUnused(-time.Duration(50)) if res := budget.takeAvailable(); res != time.Duration(100) { t.Errorf("Expected: %v, got: %v", time.Duration(100), res) </del> <ins> // wait for longer than the maxBudget // verify that adding a negative value didn't affected nextTime = nextTime.Add(10 * time.Minute) fakeClock.SetTime(nextTime) if res := budget.takeAvailable(); res != budget.maxBudget { t.Errorf("Expected: %v, got: %v", budget.maxBudget, res) </ins> } <del> // test overflow. budget.returnUnused(time.Duration(500)) if res := budget.takeAvailable(); res != time.Duration(200) { t.Errorf("Expected: %v, got: %v", time.Duration(200), res) </del> <ins> // handle back in time problem with time on the budget budget.returnUnused(10 * time.Second) nextTime = nextTime.Add(-2 * time.Minute) fakeClock.SetTime(nextTime) if res := budget.takeAvailable(); res != budget.maxBudget { t.Errorf("Expected: %v, got: %v", budget.maxBudget, res) </ins> } }
var ( dInfo = driver.GetDriverInfo() cs    clientset.Interface <ins> l     *stressTest </ins> ) <ins> // Check preconditions before setting up namespace via framework below. </ins> ginkgo.BeforeEach(func() { <del> // Check preconditions. </del> if dInfo.StressTestOptions == nil { e2eskipper.Skipf("Driver %s doesn't specify stress test options -- skipping", dInfo.Name) }
// f must run inside an It or Context callback. f := framework.NewDefaultFramework("stress") <del> init := func() *stressTest { </del> <ins> init := func() { </ins> cs = f.ClientSet <del> l := &stressTest{} </del> <ins> l = &stressTest{} </ins> // Now do the more expensive test initialization. l.config, l.driverCleanup = driver.PrepareTest(f)
l.pods = []*v1.Pod{} l.testOptions = *dInfo.StressTestOptions l.ctx, l.cancel = context.WithCancel(context.Background()) <ins> } </ins> <del> return l </del> <ins> createPodsAndVolumes := func() { for i := 0; i < l.testOptions.NumPods; i++ { framework.Logf("Creating resources for pod %v/%v", i, l.testOptions.NumPods-1) r := CreateVolumeResource(driver, l.config, pattern, t.GetTestSuiteInfo().SupportedSizeRange) l.resources = append(l.resources, r) podConfig := e2epod.Config{ NS:           f.Namespace.Name, PVCs:         []*v1.PersistentVolumeClaim{r.Pvc}, SeLinuxLabel: e2epv.SELinuxLabel, } pod, err := e2epod.MakeSecPod(&podConfig) framework.ExpectNoError(err) l.pods = append(l.pods, pod) } </ins> } <del> cleanup := func(l *stressTest) { </del> <ins> cleanup := func() { </ins> var errs []error framework.Logf("Stopping and waiting for all test routines to finish")
l.migrationCheck.validateMigrationVolumeOpCounts() } <del> ginkgo.It("multiple pods should access different volumes repeatedly [Slow] [Serial]", func() { l := init() defer func() { cleanup(l) }() for i := 0; i < l.testOptions.NumPods; i++ { framework.Logf("Creating resources for pod %v/%v", i, l.testOptions.NumPods-1) r := CreateVolumeResource(driver, l.config, pattern, t.GetTestSuiteInfo().SupportedSizeRange) l.resources = append(l.resources, r) podConfig := e2epod.Config{ NS:           f.Namespace.Name, PVCs:         []*v1.PersistentVolumeClaim{r.Pvc}, SeLinuxLabel: e2epv.SELinuxLabel, } pod, err := e2epod.MakeSecPod(&podConfig) framework.ExpectNoError(err) </del> <ins> ginkgo.BeforeEach(func() { init() createPodsAndVolumes() }) </ins> <del> l.pods = append(l.pods, pod) } </del> <ins> f.AddAfterEach("cleanup", func(f *framework.Framework, failed bool) { cleanup() }) ginkgo.It("multiple pods should access different volumes repeatedly [Slow] [Serial]", func() { </ins> // Restart pod repeatedly for i := 0; i < l.testOptions.NumPods; i++ { podIndex := i
CaptureStderr bool // If false, whitespace in std{err,out} will be removed. PreserveWhitespace bool <ins> Quiet              bool </ins> } // ExecWithOptions executes a command in the specified container, // returning stdout, stderr and error. `options` allowed for // additional parameters to be passed. func (f *Framework) ExecWithOptions(options ExecOptions) (string, string, error) { <del> Logf("ExecWithOptions %+v", options) </del> <ins> if !options.Quiet { Logf("ExecWithOptions %+v", options) } </ins> config, err := LoadConfig() ExpectNoError(err, "failed to load restclient config")
s.Lock() defer s.Unlock() for i := begin; i <= end; i++ { <del> s.used.SetBit(&s.used, i, 0) s.allocatedCIDRs-- cidrSetReleases.WithLabelValues(s.label).Inc() </del> <ins> // Only change the counters if we change the bit to prevent // double counting. if s.used.Bit(i) != 0 { s.used.SetBit(&s.used, i, 0) s.allocatedCIDRs-- cidrSetReleases.WithLabelValues(s.label).Inc() } </ins> } cidrSetUsage.WithLabelValues(s.label).Set(float64(s.allocatedCIDRs) / float64(s.maxCIDRs)) return nil } <del> // Occupy marks the given CIDR range as used. Occupy does not check if the CIDR </del> <ins> // Occupy marks the given CIDR range as used. Occupy succeeds even if the CIDR </ins> // range was previously used. func (s *CidrSet) Occupy(cidr *net.IPNet) (err error) { begin, end, err := s.getBeginingAndEndIndices(cidr)
s.Lock() defer s.Unlock() for i := begin; i <= end; i++ { <del> s.used.SetBit(&s.used, i, 1) s.allocatedCIDRs++ cidrSetAllocations.WithLabelValues(s.label).Inc() </del> <ins> // Only change the counters if we change the bit to prevent // double counting. if s.used.Bit(i) == 0 { s.used.SetBit(&s.used, i, 1) s.allocatedCIDRs++ cidrSetAllocations.WithLabelValues(s.label).Inc() } </ins> } cidrSetUsage.WithLabelValues(s.label).Set(float64(s.allocatedCIDRs) / float64(s.maxCIDRs))
} } <ins> func TestDoubleOccupyRelease(t *testing.T) { // Run a sequence of operations and check the number of occupied CIDRs // after each one. clusterCIDRStr := "10.42.0.0/16" operations := []struct { cidrStr     string operation   string numOccupied int }{ // Occupy 1 element: +1 { cidrStr:     "10.42.5.0/24", operation:   "occupy", numOccupied: 1, }, // Occupy 1 more element: +1 { cidrStr:     "10.42.9.0/24", operation:   "occupy", numOccupied: 2, }, // Occupy 4 elements overlapping with one from the above: +3 { cidrStr:     "10.42.8.0/22", operation:   "occupy", numOccupied: 5, }, // Occupy an already-coccupied element: no change { cidrStr:     "10.42.9.0/24", operation:   "occupy", numOccupied: 5, }, // Release an coccupied element: -1 { cidrStr:     "10.42.9.0/24", operation:   "release", numOccupied: 4, }, // Release an unoccupied element: no change { cidrStr:     "10.42.9.0/24", operation:   "release", numOccupied: 4, }, // Release 4 elements, only one of which is occupied: -1 { cidrStr:     "10.42.4.0/22", operation:   "release", numOccupied: 3, }, } // Check that there are exactly that many allocatable CIDRs after all // operations have been executed. numAllocatable24s := (1 << 8) - 3 _, clusterCIDR, _ := net.ParseCIDR(clusterCIDRStr) a, err := NewCIDRSet(clusterCIDR, 24) if err != nil { t.Fatalf("Error allocating CIDRSet") } // Execute the operations for _, op := range operations { _, cidr, _ := net.ParseCIDR(op.cidrStr) switch op.operation { case "occupy": a.Occupy(cidr) case "release": a.Release(cidr) default: t.Fatalf("test error: unknown operation %v", op.operation) } if a.allocatedCIDRs != op.numOccupied { t.Fatalf("Expected %d occupied CIDRS, got %d", op.numOccupied, a.allocatedCIDRs) } } // Make sure that we can allocate exactly `numAllocatable24s` elements. for i := 0; i < numAllocatable24s; i++ { _, err := a.AllocateNext() if err != nil { t.Fatalf("Expected to be able to allocate %d CIDRS, failed after %d", numAllocatable24s, i) } } _, err = a.AllocateNext() if err == nil { t.Fatalf("Expected to be able to allocate exactly %d CIDRS, got one more", numAllocatable24s) } } </ins> func TestGetBitforCIDR(t *testing.T) { cases := []struct { clusterCIDRStr string
NodeCIDRMaskSizes:    []int{24, 98, 24}, }, }, <ins> { description: "no double counting", fakeNodeHandler: &testutil.FakeNodeHandler{ Existing: []*v1.Node{ { ObjectMeta: metav1.ObjectMeta{ Name: "node0", }, Spec: v1.NodeSpec{ PodCIDRs: []string{"10.10.0.0/24"}, }, }, { ObjectMeta: metav1.ObjectMeta{ Name: "node1", }, Spec: v1.NodeSpec{ PodCIDRs: []string{"10.10.2.0/24"}, }, }, { ObjectMeta: metav1.ObjectMeta{ Name: "node2", }, }, }, Clientset: fake.NewSimpleClientset(), }, allocatorParams: CIDRAllocatorParams{ ClusterCIDRs: func() []*net.IPNet { _, clusterCIDR, _ := net.ParseCIDR("10.10.0.0/22") return []*net.IPNet{clusterCIDR} }(), ServiceCIDR:          nil, SecondaryServiceCIDR: nil, NodeCIDRMaskSizes:    []int{24}, }, expectedAllocatedCIDR: map[int]string{ 0: "10.10.1.0/24", }, }, </ins> } // test function testFunc := func(tc testCase) { <ins> fakeNodeInformer := getFakeNodeInformer(tc.fakeNodeHandler) nodeList, _ := tc.fakeNodeHandler.List(context.TODO(), metav1.ListOptions{}) </ins> // Initialize the range allocator. <del> allocator, err := NewCIDRRangeAllocator(tc.fakeNodeHandler, getFakeNodeInformer(tc.fakeNodeHandler), tc.allocatorParams, nil) </del> <ins> allocator, err := NewCIDRRangeAllocator(tc.fakeNodeHandler, fakeNodeInformer, tc.allocatorParams, nodeList) </ins> if err != nil { t.Errorf("%v: failed to create CIDRRangeAllocator with error %v", tc.description, err) return