Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 13 for allocateNext (0.28 sec)

  1. pkg/registry/core/service/ipallocator/cidrallocator_test.go

    	for r.Free() > 0 {
    		ip, err := r.AllocateNext()
    		if err != nil {
    			t.Fatalf("error @ free: %d count: %d: %v", r.Free(), count, err)
    		}
    		count++
    		if found.Has(ip.String()) {
    			t.Fatalf("allocated %s twice: %d", ip, count)
    		}
    		found.Insert(ip.String())
    	}
    	if count != 14 {
    		t.Fatalf("expected 14 IPs got %d", count)
    	}
    	if _, err := r.AllocateNext(); err == nil {
    		t.Fatal(err)
    	}
    
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Tue Oct 31 21:05:06 UTC 2023
    - 13.7K bytes
    - Viewed (0)
  2. pkg/registry/core/service/ipallocator/bitmap_test.go

    		errors:    2,
    	}
    	expectMetrics(t, cidrIPv4, em)
    
    	// allocate 264 addresses for each allocator
    	// the full range and 10 more (254 + 10 = 264) for IPv4
    	for i := 0; i < 264; i++ {
    		a.AllocateNext()
    		b.AllocateNext()
    	}
    	em = testMetrics{
    		free:      0,
    		used:      254,
    		allocated: 256, // this is a counter, we already had 2 allocations and we did 254 more
    		errors:    12,
    	}
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed Jan 25 20:32:40 UTC 2023
    - 21.1K bytes
    - Viewed (0)
  3. pkg/controller/nodeipam/ipam/cidrset/cidr_set_test.go

    			}
    			if a == nil {
    				return
    			}
    			p, err := a.AllocateNext()
    			if err == nil && tc.expectErr {
    				t.Errorf("a.AllocateNext() = nil, want error")
    			}
    			if err != nil && !tc.expectErr {
    				t.Errorf("a.AllocateNext() = %+v, want no error", err)
    			}
    			if !tc.expectErr {
    				if p != nil && p.String() != tc.expectedCIDR {
    					t.Fatalf("a.AllocateNext() got %+v, want %+v", p.String(), tc.expectedCIDR)
    				}
    			}
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Thu May 11 08:53:03 UTC 2023
    - 29.5K bytes
    - Viewed (0)
  4. pkg/registry/core/service/portallocator/allocator_test.go

    	count := 0
    	for r.Free() > 0 {
    		p, err := r.AllocateNext()
    		if err != nil {
    			t.Fatalf("error @ %d: %v", count, err)
    		}
    		count++
    		if !pr.Contains(p) {
    			t.Fatalf("allocated %d which is outside of %v", p, pr)
    		}
    		if found.Has(strconv.Itoa(p)) {
    			t.Fatalf("allocated %d twice @ %d", p, count)
    		}
    		found.Insert(strconv.Itoa(p))
    	}
    	if _, err := r.AllocateNext(); err != ErrFull {
    		t.Fatal(err)
    	}
    
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed May 08 07:15:02 UTC 2024
    - 14K bytes
    - Viewed (0)
  5. pkg/registry/core/service/ipallocator/ipallocator_test.go

    		errors:    2,
    	}
    	expectMetrics(t, cidrIPv4, em)
    
    	// allocate 264 addresses for each allocator
    	// the full range and 10 more (254 + 10 = 264) for IPv4
    	for i := 0; i < 264; i++ {
    		a.AllocateNext()
    		b.AllocateNext()
    	}
    	em = testMetrics{
    		free:      0,
    		used:      254,
    		allocated: 256, // this is a counter, we already had 2 allocations and we did 254 more
    		errors:    12,
    	}
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Sun Jun 25 13:14:46 UTC 2023
    - 24.2K bytes
    - Viewed (0)
  6. pkg/registry/core/service/allocator/bitmap_test.go

    		t.Run(tc.name, func(t *testing.T) {
    			m := tc.allocator(tc.max, "test", tc.reserved)
    			for i := 0; i < tc.max; i++ {
    				if _, ok, _ := m.AllocateNext(); !ok {
    					t.Fatalf("unexpected error")
    				}
    			}
    			if _, ok, _ := m.AllocateNext(); ok {
    				t.Errorf("unexpected success")
    			}
    			if f := m.Free(); f != 0 {
    				t.Errorf("expect to get %d, but got %d", 0, f)
    			}
    		})
    	}
    }
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Tue May 10 08:56:31 UTC 2022
    - 13.3K bytes
    - Viewed (0)
  7. pkg/registry/core/service/ipallocator/bitmap.go

    	r.metrics.setAvailable(label.String(), r.Free())
    
    	return nil
    }
    
    // AllocateNext reserves one of the IPs from the pool. ErrFull may
    // be returned if there are no addresses left.
    func (r *Range) AllocateNext() (net.IP, error) {
    	return r.allocateNext(dryRunFalse)
    }
    
    func (r *Range) allocateNext(dryRun bool) (net.IP, error) {
    	label := r.CIDR()
    	if dryRun {
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed Jan 25 20:32:40 UTC 2023
    - 10.8K bytes
    - Viewed (0)
  8. pkg/registry/core/service/ipallocator/ipallocator.go

    	}
    	return a.createIPAddress(ip.String(), svc, "static")
    }
    
    // AllocateNext return an IP address that wasn't allocated yet.
    // Only for testing, it will fail to create the IPAddress object because
    // the Service reference is required.
    func (a *Allocator) AllocateNext() (net.IP, error) {
    	return a.AllocateNextService(nil)
    }
    
    // AllocateNext return an IP address that wasn't allocated yet.
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Tue Oct 31 21:05:04 UTC 2023
    - 17K bytes
    - Viewed (0)
  9. pkg/registry/core/service/ipallocator/cidrallocator.go

    		ip, err := allocator.AllocateNextService(service)
    		if err == nil {
    			return ip, nil
    		}
    	}
    	return nil, ErrFull
    }
    
    func (c *MetaAllocator) AllocateNext() (net.IP, error) {
    	c.muTree.Lock()
    	defer c.muTree.Unlock()
    
    	// TODO(aojea) add strategy to return a random allocator but
    	// taking into consideration the number of addresses of each allocator.
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Sat May 04 18:33:12 UTC 2024
    - 13.2K bytes
    - Viewed (0)
  10. pkg/registry/core/service/storage/alloc.go

    				if ok {
    					allocatedIP, err = svcAllocator.AllocateNextService(service)
    				} else {
    					allocatedIP, err = allocator.AllocateNext()
    				}
    			} else {
    				allocatedIP, err = allocator.AllocateNext()
    			}
    			if err != nil {
    				return allocated, errors.NewInternalError(fmt.Errorf("failed to allocate a serviceIP: %v", err))
    			}
    			allocated[family] = allocatedIP.String()
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Tue Oct 31 21:05:05 UTC 2023
    - 37.3K bytes
    - Viewed (0)
Back to top