Commit Graph

429 Commits

Author SHA1 Message Date
Tim Hockin
049e158a8f Don't write fake logs to the real test log
This caused consternation as errors were logged but tests did not fail.
It was expected to log!
2021-11-09 22:56:34 -08:00
Tim Hockin
26db11f3dc Clean up some service logging
This is a holdover from previous work.  It is not complete, but it
should be incrementally better.
2021-11-09 22:46:22 -08:00
Tom Payne
21755f9ec0 Speed up counting of bits in allocator
Benchmark:

goos: linux
goarch: amd64
pkg: k8s.io/kubernetes/pkg/registry/core/service/allocator
cpu: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz

Before:

BenchmarkCountBits-8     9459236               140.4 ns/op

After:

BenchmarkCountBits-8    140667842                9.541 ns/op
2021-10-01 17:09:56 +02:00
Tom Payne
125312a8cf Add extra test and benchmark for count bits 2021-10-01 17:08:36 +02:00
Khaled Henidak (Kal)
a53e2eaeab
move IPv6DualStack feature to stable. (#104691)
* kube-proxy

* endpoints controller

* app: kube-controller-manager

* app: cloud-controller-manager

* kubelet

* app: api-server

* node utils + registry/strategy

* api: validation (comment removal)

* api:pod strategy (util pkg)

* api: docs

* core: integration testing

* kubeadm: change feature gate to GA

* service registry and rest stack

* move feature to GA

* generated
2021-09-24 16:30:22 -07:00
Tim Hockin
52f54ce90d Svc REST: clean up defaultOnRead to be consistent
Headless+selectorless -> RequireDualStack

Headless+selector -> SingleStack

Add test cases to cover this and ExternalName and dual-stack init (which
I think can never trigger, but best to be safe).
2021-09-16 11:17:45 -07:00
Tim Hockin
009aa36c89 Svc REST: Make transaction-accumulating funcs safe
Identified in review, these funcs are now more reslient to future
changes.
2021-09-11 11:30:02 -07:00
Tim Hockin
e594dd4281 Svc REST: Convert FIXME to TODO 2021-09-11 11:30:02 -07:00
Tim Hockin
03d11c53a8 Svc REST: Rename RESTAllocStuff
This was a dumb placeholder name.
2021-09-11 11:30:02 -07:00
Tim Hockin
5847426e5e Svc REST: Use types for safer arg ordering
In all the places we pass (old, new) or (new, old), use wrapper-types to
make sure that we don't flip the order by accident.
2021-09-11 11:30:02 -07:00
Tim Hockin
d5143bca84 Svc REST: Rename GenericREST -> REST
This is consistent with every other registry.  Service is no longer the
oddball.
2021-09-11 11:30:02 -07:00
Tim Hockin
fe6f278ea1 Svc REST: Move isValidAddress to storage.go 2021-09-11 11:30:02 -07:00
Tim Hockin
d7c8557281 Svc REST: Make update/releaseNodePorts methods
More consistent overall.
2021-09-11 11:30:02 -07:00
Tim Hockin
4c9bc5a53c Svc REST: Move alloc code around
This is detrimental to future `blame` but makes it so much morereadable
I convinced myself it was worthwhile.
2021-09-11 11:30:02 -07:00
Tim Hockin
7ce34e311a Svc REST: rename rest.go -> alloc.go 2021-09-11 11:30:02 -07:00
Tim Hockin
1ce9807de0 Svc REST: Make allocHCNP a method: more consistent 2021-09-11 11:30:02 -07:00
Tim Hockin
c94deffa48 Svc REST: rename allocateHealthCheckNodePort 2021-09-11 11:30:02 -07:00
Tim Hockin
6b06b9bfd3 Svc REST: rename healthCheckNodePortUpdate 2021-09-11 11:30:02 -07:00
Tim Hockin
5dfcb905d1 Svc REST: rename handleClusterIPsForUpdatedService 2021-09-11 11:30:02 -07:00
Tim Hockin
9c622230fc Svc REST: rename releaseServiceClusterIPs 2021-09-11 11:30:02 -07:00
Tim Hockin
4fb338b279 Svc REST: rename releaseServiceClusterIP 2021-09-11 11:30:02 -07:00
Tim Hockin
2a98ec667e Svc REST: rename allocServiceClusterIPs 2021-09-11 11:30:02 -07:00
Tim Hockin
b9f1f4712a Svc REST: rename allocServiceClusterIP 2021-09-11 11:30:02 -07:00
Tim Hockin
1b79bbc9f4 Svc REST: rename releaseClusterIPs -> releaseIPs 2021-09-11 11:30:01 -07:00
Tim Hockin
8e330eb611 Svc REST: rename allocClusterIPs -> allocIPs 2021-09-11 11:30:01 -07:00
Tim Hockin
7d9357b181 Svc REST: rename allocUpdateServiceNodePortsNew 2021-09-11 11:30:01 -07:00
Tim Hockin
bb815e6687 Svc REST: rename allocUpdateServiceClusterIPsNew 2021-09-11 11:30:01 -07:00
Tim Hockin
3b971b137c Svc REST: rename allocServiceNodePortsNew 2021-09-11 11:30:01 -07:00
Tim Hockin
f94782b4f5 Svc REST: rename allocServiceClusterIPsNew 2021-09-11 11:30:01 -07:00
Tim Hockin
8f5189a49f Svc REST: Move tests and scaffolding around
No code edits.  Just a little whitespace, adding comments, and
re-ordering functions.
2021-09-11 11:30:01 -07:00
Tim Hockin
017a430dcd Svc REST: Move patchAllocatedValues to storage pkg
All the meaningful callers of it are in that pkg anyway.  Removes 1
FIXME.
2021-09-11 11:30:01 -07:00
Tim Hockin
4ff4160e34 Svc REST: Move normalizeClusterIPs to storage pkg
All the meaningful callers of it are in that pkg anyway.  Removes some
FIXMEs.
2021-09-11 11:30:01 -07:00
Tim Hockin
4718a0f214 DeepCopy() input objects in Service REST test
Since the PR to do this deeper in the stack was declined, we'll do it
ourselves.  This ensures that we don't accidentally mutate the input and
then compare that mutated form to the result (which caused previous test
failures).
2021-09-11 11:30:01 -07:00
Tim Hockin
4ac7c73b2e Svc REST: Remove old rest_test
All the tests have been ported to storage_test.go
2021-09-11 11:30:01 -07:00
Tim Hockin
b6da6c9c0f Svc REST: Add InternalTrafficPolicy tests
Remove older form.
2021-09-11 11:30:01 -07:00
Tim Hockin
c71467def0 Svc REST: Remove overlapping rest_tests
Most are moved to storage_test
2021-09-11 11:30:01 -07:00
Tim Hockin
12ac38f661 Svc REST: Beef up ports test, remove old form 2021-09-11 11:30:01 -07:00
Tim Hockin
652dc8787c Svc REST: Use "prove" helpers in other tests 2021-09-11 11:30:01 -07:00
Tim Hockin
245a654dec Svc REST: Rename service NewGenericREST to NewREST
Just like all the other registries.
2021-09-11 11:30:01 -07:00
Tim Hockin
03e7690cdb Svc REST: Remove old, now unused stubs 2021-09-11 11:30:01 -07:00
Tim Hockin
8e68b587e8 Svc REST: De-layering done! Convert to 1 layer
This is the culmination of all the previous commits which made this last
move less dramatic.  More tests and cleanup commits will follow.

Background, for future archaeologists:

Service has (had) an "outer" and "inner" REST handler.  This is because of how we do IP and port allocations synchronously, but since we don't have API transactions, we need to roll those back in case of a failure.  Both layers use the same `Strategy`, but the outer calls into the inner, which causes a lot of complexity in the code (including an open-coded partial reimplementation of a date-unknown snapshot of the generic REST code) and results in `Prepare` and `Validate` hooks being called twice.

The "normal" REST flow seems to be:

```
mutating webhooks
generic REST store Create {
    cleanup = BeginCreate
    BeforeCreate {
        strategy.PrepareForCreate {
            dropDisabledFields
        }
        strategy.Validate
        strategy.Canonicalize
    }
    createValidation (validating webhooks)
    storage Create
    cleanup
    AfterCreate
    Decorator
}
```

Service (before this series of commits) does:

```
mutating webhooks
svc custom Create {
    BeforeCreate {
        strategy.PrepareForCreate {
            dropDisabledFields
        }
        strategy.Validate
        strategy.Canonicalize
    }
    Allocations
    inner (generic) Create {
        cleanup = BeginCreate
        BeforeCreate {
            strategy.PrepareForCreate {
                dropDisabledFields
            }
            strategy.Validate
            strategy.Canonicalize
        }
        createValidation (validating webhooks)
        storage Create
        cleanup
        AfterCreate
        Decorator
    }
}
```

After this:

```
mutating webhooks
generic REST store Create {
    cleanup = BeginCreate
        Allocations
    BeforeCreate {
        strategy.PrepareForCreate {
            dropDisabledFields
        }
        strategy.Validate
        strategy.Canonicalize
    }
    createValidation (validating webhooks)
    storage Create
    cleanup
    AfterCreate
        Rollback allocations on error
    Decorator
}
```
2021-09-11 11:30:01 -07:00
Tim Hockin
cf4804643a Svc REST: Remove obviously unused args
This is part of the de-layering conclusion and cleanup.

Bridge the old tests into the new REST.  This will all be removed soon.
2021-09-11 11:30:01 -07:00
Tim Hockin
d30ae6a5ab Svc REST: Make ipFamilyPolicy authoritative
Previously we would try to infer the `ipFamilyPolicy` from `clusterIPs`
and/or `ipFamilies`.  That is too tricky.  Now you MUST specify
`ipFamilyPolicy` as one of the dual-stack options in order to get a
dual-stack service.
2021-09-11 11:30:01 -07:00
Tim Hockin
ca8cfdcae9 Svc REST: Fix single<->dual-stack updates
This removes the old rest_tests and adds significantly more coverage.
Maybe too much.  The v4,v6 and v6,v4 tables are identical but for the
order of families.

This exposed that `trimFieldsForDualStackDowngrade` is called too late
to do anything (since we don't run strategy twice any more).  I moved
similar logic to `PatchAllocatedValues` but I hit on some unclarity.

Specifically, consider a PATCH operation.

Assume I have a valid dual-stack service (with 2 IPs, 2 families, and
policy either require or prefer). What fields can I patch, on their own,
to trigger a downgrade to single-stack?

I think patching policy to "single" is pretty clear intent.

But what if I leave policy and only patch `ipFamilies` down to a single
value (without violating the "can't change first family" rule)?

Or what if I patch `clusterIPs` down to a single IP value?

After much discussion, we decided to make a small API change (OK since
we are beta).  When you want a dual-stack Service you MUST specify the
`ipFamilyPolicy`.  Now we can infer less and avoid ambiguity.
2021-09-11 11:30:01 -07:00
Tim Hockin
650f8cfd35 Svc REST: Validate input before IP allocation
This commit started as removing FIXME comments, but in doing so I
realized that the IP allocation process was using unvalidated user
input.  Before de-layering, validation was called twice - once before
init and once after, which the init code depended on.

Fortunately (or not?) we had duplicative checks that caught errors but
with less friendly messages.

This commit calls validation before initializing the rest of the
IP-related fields.

This also re-organizes that code a bit, cleans up error messages and
comments, and adds a test SPECIFICALLY for the errors in those cases.
2021-09-11 11:30:01 -07:00
Tim Hockin
7602260d0a Svc REST: Fix comments to make next commits easier 2021-09-11 11:30:01 -07:00
Tim Hockin
d1b83bad67 Svc REST: Move ResourceLocation() to 'inner' layer
Part of the de-layering effort.

Also move the test.
2021-09-11 11:30:01 -07:00
Tim Hockin
7887c4c8fc Svc REST: allow tests to set cluster IP families 2021-09-11 11:30:01 -07:00
Tim Hockin
aea90a2324 Svc REST: add a beforeUpdate hook in feature tests 2021-09-11 11:30:01 -07:00
Tim Hockin
ced629e657 Svc REST: Add proof funcs in feature test logic
Allows for more control of tests to assert specific things.
2021-09-11 11:30:01 -07:00
Tim Hockin
7cf75dbdd8 Svc REST: Beef up NodePort tests
Remove old test from rest_test.go.
2021-09-11 11:30:01 -07:00
Tim Hockin
7b1e43665d Svc REST: Change ETP create test to a feature test
All the same test cases and more.
2021-09-11 11:30:01 -07:00
Tim Hockin
f4521aa75a Fix validation on ETP: "" is not valid
This was causing tests to pass which ought not be passing.  This is not
an API change because we default the value of it when needed.  So we
would never see this in the wild, but it makes the tests sloppy.
2021-09-11 11:30:01 -07:00
Tim Hockin
5363f1646f Svc REST: Add new model of feature tests
This scaffolding allows us to assert more on each test case, and more
consistently.

Set input fields from output fields IFF they are expected AND not set on
input.  This allows us to verify the "after" state (expected) whether
the test case specified the value or not, and still pass the generic
cmp.Equal.

Use this in a few tests to prove its worth, more to do.

Some of the existing tests that are focused on create and delete can
probably be replaced by these.

This could be used in other test cases that are open-coding a lot of the
same stuff.  Later commits.
2021-09-11 11:30:00 -07:00
Tim Hockin
446a2c730d Svc REST: Add a test for PatchAllocatedValues 2021-09-11 11:30:00 -07:00
Tim Hockin
30bd8198e3 Svc REST: Set Cluster IPs during dry-run Update()
Dry-run should return valid results.

Also add a test.
2021-09-11 11:30:00 -07:00
Tim Hockin
ccf3376570 Svc REST: De-layer Update
This is the last layered method.  All allocator logic is moved to the
beginUpdate() path.  Removing the now-useless layer will happen in a
subsequent commit.
2021-09-11 11:30:00 -07:00
Tim Hockin
89a9ca52bc Svc REST: Add a delete-with-finalizer test
This is a long-standing bug that gets fixed "for free" in the
de-layering.
2021-09-11 11:30:00 -07:00
Tim Hockin
cb4d8700d3 Svc REST: Clean up redundant delete tests 2021-09-11 11:30:00 -07:00
Tim Hockin
61a5e7498d Svc REST: De-layer Delete
Gut the "outer" Delete() and move it to the inner AfterDelete().
2021-09-11 11:30:00 -07:00
Tim Hockin
42b53d850d Svc REST: Move test to reduce diff in next commits
No changes - just move.
2021-09-11 11:01:44 -07:00
Tim Hockin
6d640aa244 Svc REST: Remove redundant Get test 2021-09-11 11:01:32 -07:00
Tim Hockin
15c513cc36 Svc REST: IP and port reallocation
Make sure the logic that was covered in rest_test is covered in
storage_test.
2021-09-11 11:01:23 -07:00
Tim Hockin
a957f63ec5 Svc REST: HealthCheckNodePort tests
This commit ports the ExternalTrafficPolicy and HealthCheckNodePort
tests from rest_test to storage_test.  It's not a direct port, though.
I have added more cases (much more exhaustive) and more assertions.
2021-09-11 11:01:07 -07:00
Tim Hockin
2212924a96 Svc REST: Better NodePort tests
This commit ports the NodePort test from rest_test to storage_test.
It's not a direct port, though.  I have added many more cases (much more
exhaustive) and more assertions.

This includes cases for gate MixedProtocolLBService.
2021-09-11 11:00:44 -07:00
Tim Hockin
46d7289655 Svc REST: Remove redundant Create tests
These cases are all covered in storage_test.
2021-09-11 11:00:29 -07:00
Tim Hockin
0dc509a0c8 Svc REST: Test that Headless doesn't set IPs 2021-09-11 11:00:11 -07:00
Tim Hockin
9ca582f3b7 Svc REST: Test that ExternalName doesn't set IPs 2021-09-11 10:59:30 -07:00
Tim Hockin
ca4a95ee49 Svc REST: Dedup tests for defaulting 2021-09-11 10:59:02 -07:00
Tim Hockin
b880d3a149 Svc REST: better test checks in new tests
"Has()" was strengthened in the older rest_test, now in the newer.
2021-09-11 10:58:32 -07:00
Tim Hockin
e338c9db4b Svc REST: Set Cluster IPs during dry-run Create
Dry-run should behave like a real API call and return valid results.
2021-09-11 10:57:01 -07:00
Tim Hockin
52856f3fbe Add dry-run support to the IP allocator subsystem 2021-09-11 10:56:39 -07:00
Tim Hockin
237434bd42 Svc REST: Overhaul Create test wrt dual-stack
This includes a few cases.

1) TestCreateIgnoresIPFamilyForExternalName: Prove that ExternalName is
ignored for dual-stack.  A small set of test cases were chosen to
demonstrate.

2) TestCreateIgnoresIPFamilyWithoutDualStack: Prove that when the
dual-stack gate is off, all services are ignored for dual-stack.  A
small set of test cases were chosen to demonstrate

3) TestCreateInitIPFields: Run over a huge array of test cases for
dual-stack.  This was generated by this program:
https://gist.github.com/thockin/cccc9c9a580b4830ee0946ddd43eeafe and
then updated by hand.
2021-09-11 10:56:03 -07:00
Tim Hockin
e4c6d0837e Svc REST: Rename some tests for clarity 2021-09-11 10:55:51 -07:00
Tim Hockin
bdbf2c6ef4 Svc REST: Allow multi-IP-family in tests 2021-09-11 10:54:24 -07:00
Tim Hockin
6cc9ef3874 Svc REST: Rename a long, hard function name 2021-09-11 10:54:03 -07:00
Tim Hockin
634055bded Svc REST: De-layer Create
Gut the "outer" Create() and move it to the inner BeginCreate().  This
uses a "transaction" type to make cleanup functions easy to read.

Background:

Service has an "outer" and "inner" REST handler.  This is because of how we do IP and port allocations synchronously, but since we don't have API transactions, we need to roll those back in case of a failure.  Both layers use the same `Strategy`, but the outer calls into the inner, which causes a lot of complexity in the code (including an open-coded partial reimplementation of a date-unknown snapshot of the generic REST code) and results in `Prepare` and `Validate` hooks being called twice.

The "normal" REST flow seems to be:

```
mutating webhooks
generic REST store Create {
    cleanup = BeginCreate
    BeforeCreate {
        strategy.PrepareForCreate {
            dropDisabledFields
        }
        strategy.Validate
        strategy.Canonicalize
    }
    createValidation (validating webhooks)
    storage Create
    cleanup
    AfterCreate
    Decorator
}
```

Service (before this commit) does:

```
mutating webhooks
svc custom Create {
    BeforeCreate {
        strategy.PrepareForCreate {
            dropDisabledFields
        }
        strategy.Validate
        strategy.Canonicalize
    }
    Allocations
    inner (generic) Create {
        cleanup = BeginCreate
        BeforeCreate {
            strategy.PrepareForCreate {
                dropDisabledFields
            }
            strategy.Validate
            strategy.Canonicalize
        }
        createValidation (validating webhooks)
        storage Create
        cleanup
        AfterCreate
        Decorator
    }
}
```

After this commit:

```
mutating webhooks
generic REST store Create {
    cleanup = BeginCreate
        Allocations
    BeforeCreate {
        strategy.PrepareForCreate {
            dropDisabledFields
        }
        strategy.Validate
        strategy.Canonicalize
    }
    createValidation (validating webhooks)
    storage Create
    cleanup
    AfterCreate
        Rollback allocations on error
    Decorator
}
```

This same fix pattern will be applied to Delete and Update in subsequent
commits.
2021-09-11 10:51:45 -07:00
Tim Hockin
5e7e35ca45 Svc REST: Add stub begin* hooks
These will be used in the next set of commits to de-0layer service REST.
2021-09-11 10:51:09 -07:00
Tim Hockin
f3c7e846f1 Svc REST: Move allocations in Create into funcs
All the logic remains unchanged, just reorganized.  The functions are
imperfect but emphasize the change being made and can be cleaned up
subsequently.

This makes the following steps easier to comprehend.
2021-09-11 10:50:27 -07:00
Tim Hockin
960b36b124 Svc REST: Add a transaction API
This will be used in upcoming commits, but for easier history and review
it is pretty stand-alone.
2021-09-11 10:49:37 -07:00
Tim Hockin
14d0571a5f Svc REST: Don't call validation directly
The validation is called soon after anyway.
2021-09-11 10:49:13 -07:00
Tim Hockin
b76a8c3c40 Svc REST: move allocator methods -> alloc object
Move all allocator-related methods onto the alloc object so it can be
used in either REST layer.  There's an INORDINATE amount of test code
here and I am skeptical that it is all useful.  That's for later
commits.
2021-09-11 10:48:32 -07:00
Tim Hockin
89587b3c6a Svc REST: Encapsulate IP and Port allocator logic
Encapsulate the allocator logic so it can be shared across REST
layers while we stage a series of commits to get rid of one layer.
2021-09-11 10:46:48 -07:00
Tim Hockin
d13c920606 Svc: Move ETP clearing to dropTypeDependentFields
I  am not sure why ExternalTrafficPolicy was different, but this is more
consistent with other field clearing logic.
2021-09-11 10:45:30 -07:00
Kubernetes Prow Robot
85b11ad24e
Merge pull request #104699 from vincepri/generate-name-error
Object creation with generateName should return AlreadyExists instead of a Timeout
2021-09-07 17:41:20 -07:00
Vince Prignano
8a9d61278f Object creation with generateName should return a proper error
Signed-off-by: Vince Prignano <vincepri@vmware.com>
2021-09-04 07:34:32 -07:00
Kubernetes Prow Robot
295a8c1371
Merge pull request #104467 from khenidak/fix-104329
fix 104329: check for headless before trying to release the ClusterIPs
2021-09-02 10:55:39 -07:00
Kubernetes Prow Robot
2a88664ecc
Merge pull request #104652 from MikeSpreitzer/add-resourcde-config
Introduce storagebackend.ConfigForResource
2021-09-02 04:00:10 -07:00
Mike Spreitzer
85bcd243aa Introduce storagebackend.ConfigForResource
This is a Config specialized for a GroupResource.
It will support generating new resource-specific metrics.
2021-09-01 16:54:26 -04:00
Tim Hockin
73503a4936 Fix a small regression in Service updates
Prior to 1.22 a user could change NodePort values within a service
during an update, and the apiserver would allocate values for any that
were not specified.

Consider a YAML like:

```
apiVersion: v1
kind: Service
metadata:
  name: foo
spec:
  type: NodePort
  ports:
  - name: p
    port: 80
  - name: q
    port: 81
  selector:
    app: foo
```

When this is created, nodeport values will be allocated for each port.
Something like:

```
apiVersion: v1
kind: Service
metadata:
  name: foo
spec:
  clusterIP: 10.0.149.11
  type: NodePort
  ports:
  - name: p
    nodePort: 30872
    port: 80
    protocol: TCP
    targetPort: 9376
  - name: q
    nodePort: 31310
    port: 81
    protocol: TCP
    targetPort: 81
  selector:
    app: foo
```

If the user PUTs (kubectl replace) the original YAML, we would see that
`.nodePort = 0`, and allocate new ports.  This was ugly at best.

In 1.22 we fixed this to not allocate new values if we still had the old
values, but instead re-assign them.  Net new ports would still be seen
as `.nodePort = 0` and so new allocations would be made.

This broke a corner case as follows:

Prior to 1.22, the user could PUT this YAML:

```
apiVersion: v1
kind: Service
metadata:
  name: foo
spec:
  type: NodePort
  ports:
  - name: p
    nodePort: 31310 # note this is the `q` value
    port: 80
  - name: q
    # note this nodePort is not specified
    port: 81
  selector:
    app: foo
```

The `p` port would take the `q` port's value.  The `q` port would be
seen as `.nodePort = 0` and a new value allocated.  In 1.22 this results
in an error (duplicate value in `p` and `q`).

This is VERY minor but it is an API regression, which we try to avoid,
and the fix is not too horrible.

This commit adds more robust testing of this logic.
2021-08-30 12:42:17 -07:00
Tim Hockin
75dea6b8bc Service REST: Use DeepCopy() on Create() and fix tests 2021-08-22 11:59:33 -07:00
Khaled (Kal) Henidak
2f9cd08831 fix 104329: check for headless before trying to release the ClusterIPs 2021-08-20 22:03:42 +00:00
Antonio Ojea
0cd75e8fec run hack/update-netparse-cve.sh 2021-08-20 10:42:09 +02:00
Tim Hockin
28de406a37 Allocator renames for clarity
Rename `NewCIDRRange()` to `NewInMemory()`
Rename `NewAllocatorCIDRRange()` to `New()`

Rename `NewPortAllocator()` to `NewInMemory()`
Rename `NewPortAllocatorCustom()` to `New()`
2021-08-15 16:44:12 -07:00
Tim Hockin
907fceb206 Remove unused NewContiguousAllocationMap
This was used at some point in the past and never removed.  We are not
in the business of hosting unused code.
2021-08-15 14:12:14 -07:00
Antonio Ojea
ee7562a2f8 add clusterIP allocator metrics
Add 4 new metrics to the ClusterIP allocators:
- current number of available IPs per Service CIDR
- current number of used IPs per Service CIDR
- total number of allocation per Service CIDR
- total number of allocation errors per ServiceCIDR
2021-08-04 13:14:42 +02:00
Tim Hockin
80dda49ce2 Service: Fix semantics for Update wrt allocations
It is not uncommon for users to Create a Service and not specify things
like ClusterIP and NodePort, which we then allocate for them.  They same
that YAML somewhere and later use it again in an Update, but then it
fails.

That's because we detected them trying to set a ClusterIP from a value
to "", which is not allowed.  If it was just NodePort, they would
actually succeed and reallocate a new port.

After this change, we try to "patch" updates where the user did not
specify those values from the old object.
2021-07-07 17:09:12 -07:00
Tim Hockin
5b787aa184 Clean up testing of AllocateLoadBalancerNodePorts
We only need one "tweak" function, and it should be set automatically in
most cases.
2021-07-06 16:36:51 -07:00
Tim Hockin
eae4a19bd3 Fix small bug with AllocateLoadBalancerNodePorts
If the user specified a port, DO reserve it, even if they asked you not
to allocate new ports.
2021-07-06 16:36:51 -07:00
Andrew Sy Kim
28f3f36505
Promote the ServiceInternalTrafficPolicy field to Beta and on by default (#103462)
* pkg/features: promote the ServiceInternalTrafficPolicy field to Beta and on by default

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/api/service/testing: update Service test fixture functions to set internalTrafficPolicy=Cluster by default

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/apis/core/validation: add more Service validation tests for internalTrafficPolicy

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/registry/core/service/storage: fix failing Service REST storage tests to use internalTrafficPolicy: Cluster

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/registry/core/service/storage: add two test cases for Service REST TestServiceRegistryInternalTrafficPolicyClusterThenLocal and TestServiceRegistryInternalTrafficPolicyLocalThenCluster

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/registry/core/service: update strategy unit tests to expect default
internalTrafficPolicy=Cluster

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/proxy/ipvs: fix unit test Test_EndpointSliceReadyAndTerminatingLocal to use internalTrafficPolicy=Cluster

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/apis/core: update fuzzers to set Service internalTrafficPolicy field

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>

* pkg/api/service/testing: refactor Service test fixtures to use Tweak funcs

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
2021-07-06 06:16:30 -07:00