314 Commits
Author SHA1 Message Date
Patrick Ohly c13f052503 ktesting: move to staging
This moves the existing code unchanged, updates package and module name, and
updates all import statements.
2026-10-07 11:08:22 +02:00
Patrick Ohly 2579861734 kube-controller-manager: use context-aware client-go
Kubernetes 1.37 finished the introduction of context-aware client-go APIs.
Components like kube-controller-manager which are meant to support contextual
logging should use those new APIs.

This is not enforced yet because existing code must be updated first. Once
that is done, enforcement of everything touched here can be enabled tree-wide.
2026-09-07 16:49:09 +02:00
inspirit941 c34029cea1 Set Namespace on placeholder Endpoints object in syncService
When the endpoints lister returns NotFound, syncService builds a local
placeholder Endpoints object to diff against, but never sets its
Namespace. If the subsequent Create fails, the FailedToCreateEndpoint/
FailedToUpdateEndpoint event is recorded against this object, so
event.involvedObject.namespace ends up empty even though the event
message text contains the correct namespace. This breaks consumers
that filter or route on involvedObject.namespace.
2026-08-21 14:35:18 +09:00
Joe Betz e89ecc6af0 generate 2026-06-30 18:02:28 -04:00
Kubernetes Prow Robot 1bb07fcb35 Merge pull request #138736 from rahulbabu95/fix/endpoint-controller-ipfamilies-guard
fix: avoid panic on services with empty IPFamilies
2026-05-20 17:13:45 +05:30
Joe Betz 119a1460c1 Generate deepcopy 2026-05-11 12:27:56 -04:00
Rahul 53361ff47e fix(endpoint): avoid panic on services with empty IPFamilies
Accessing svc.Spec.IPFamilies[0] without a bounds check panics when a
service reaches the controller with an empty IPFamilies field. This can
happen via watch events: the apiserver's defaultOnRead decorator populates
IPFamilies on GET/LIST but not on watch (cachingObject wrapping bypasses
the type assertion).

Restore the inference logic removed in #130101: fall back to ClusterIP
for headful services and pod IP for headless services.

Signed-off-by: Rahul <rahulbabu95@gmail.com>
2026-05-01 13:39:13 -07:00
Ondra Kupka ccd35f7c5e controller/endpoint: Improve goroutine mgmt
Make sure all threads are terminated when Run returns.
2025-10-29 19:00:31 +01:00
Kubernetes Prow Robot 60e1f61a63 Merge pull request #133511 from BenTheElder/no-md5
eliminate md5 usage, block new usage
2025-10-24 10:59:35 -07:00
Benjamin Elder a99a5c4bdc avoid updating when endpoint subsets are merely sorted differently 2025-10-22 08:07:19 -07:00
Shyam Jeedigunta 8346bed9e7 Introduce pod queuing in endpoint/slice controllers 2025-10-21 17:08:01 -07:00
Aditi Gupta 7d14367f57 Change WaitForNamedCacheSync to WaitForNamedCacheSyncWithContext.
This is part of the ongoing effort to adopt contextual logging
and utilities throughout the codebase.

Contributes to  #126379

Signed-off-by: Aditi Gupta <aditigpta@google.com>
2025-09-05 18:49:31 +00:00
Dan Winship 24065780ed Add e2eendpointslice.WaitForEndpointPorts, use in some tests.
Slightly-more-generic replacement for validateEndpointsPortsOrFail()
(but only validates EndpointSlices, not Endpoints).

Also, add two new unit tests to the Endpoints controller, to assert
the correct Endpoints-generating behavior in the cases formerly
covered by the "should serve endpoints on same port and different
protocols" and "should be updated after adding or deleting ports" e2e
tests (since they are now EndpointSlice-only). (There's not much point
in testing the Endpoints controller in "end to end" tests, since
nothing in a normal cluster ever looks at its output, so there's
really only one "end" anyway.)
2025-07-17 15:34:34 -04:00
PatrickLaabs baf71997f5 chore: depr. pointer pkg replacement for pkg/controller 2025-07-07 13:22:36 +02:00
Tsubasa Nagasawa 0ad351281b Cleanup duplicate function to get port number from named port
Currently, the function to translate named port to port number is
located in two places (pod utils and endpointslice lib).
When fixing the bug in restartable init containers, one part of the code
was fixed, but the other part was not, leaving the bug unresolved.
To prevent such partial fixes in the future, we will make the function
in the endpointslice lib public and remove the other part of the code
from pod utils. Then consume the endpointslice lib in k/k.

Signed-off-by: Tsubasa Nagasawa <toversus2357@gmail.com>
2025-07-05 10:03:30 +09:00
Dan Winship d4c55d06cf Export endpoints, endpointslice, mirroring controller names 2025-03-07 10:52:54 -05:00
Dan Winship c4ea350ef6 Add "endpoints.kubernetes.io/managed-by" label to Endpoints
Add a label to allow us to recognize endpoint-controller-generated
Endpoints in the future. (In particular, to allow us to recognize
stale Endpoints whose Service gets deleted while the Endpoints
controller is not running.)

Unlike the corresponding EndpointSlice label, this is not defined as
part of the public API, because we have no interest in getting other
controllers to use it. (They should switch to creating EndpointSlices
instead.)
2025-03-04 11:06:10 -05:00
Dan Winship 7259742e23 Make Endpoints controller always canonicalize the IPs it writes out
Also, fix the unit tests to not sometimes generate alleged pod IPs
like "1.2.3.999".
2025-02-11 21:46:13 -05:00
Dan Winship 1bd3d34d6f Remove some dead code in the Endpoints controller
There was code to deal with upgrades from pre-dual-stack-aware
apiservers, with a note to "remove when the possibility of upgrading
from a cluster that does not support dual stack is nil".

(This requires fixing the unit tests to fill in
service.Spec.IPFamilies like a modern apiserver would do.)
2025-02-11 18:11:56 -05:00
Patrick Ohly 8a908e0c0b remove import doc comments
The "// import <path>" comment has been superseded by Go modules.
We don't have to remove them, but doing so has some advantages:

- They are used inconsistently, which is confusing.
- We can then also remove the (currently broken) hack/update-vanity-imports.sh.
- Last but not least, it would be a first step towards avoiding the k8s.io domain.

This commit was generated with
   sed -i -e 's;^package \(.*\) // import.*;package \1;' $(git grep -l '^package.*// import' | grep -v 'vendor/')

Everything was included, except for
   package labels // import k8s.io/kubernetes/pkg/util/labels
because that package is marked as "read-only".
2024-12-02 16:59:34 +01:00
Monis Khan 6595fa4026 Fix tests that assume core clients use JSON
Signed-off-by: Monis Khan <mok@microsoft.com>
2024-10-23 11:35:30 -04:00
Kubernetes Prow Robot f2700895a4 Merge pull request #127422 from srivastav-abhishek/go-vet-fix
Go vet fixes for gotip
2024-09-20 14:37:58 +01:00
Abhishek Kr SrivastavandRajalakshmi-Girish 95860cff1c Fix Go vet errors for master golang
Co-authored-by: Rajalakshmi-Girish <rajalakshmi.girish1@ibm.com>
Co-authored-by: Abhishek Kr Srivastav <Abhishek.kr.srivastav@ibm.com>
2024-09-20 12:36:38 +05:30
Yang Yang dba4e42a39 bugfix: endpoints controller track resource version conrrectly
The endpoints controller store the resource version of the previous
Endpoints objects to avoid issues related to stale information on the
cache.

However, there can be update operations that succeed without increasing
the resource version, causing the endpoints controller to declare stale
the existing Resource Version and stopping the Endpoints to be updated.

Co-Author-By: Quan Tian <quan.tian@broadcom.com>
Co-Author-By: Yang Yang <yyyng@amazon.com>
2024-09-17 11:01:35 +00:00
Joe Betz 2595aa1309 generate 2024-09-03 14:26:26 -04:00
Quan Tian 3bd975862a Fix endpoints status out-of-sync when the pod state changes rapidly
When Pod state changes rapidly, endpoints controller may use outdated
informer cache to sync Service. If the outdated endpoints appear to be
expected by the controller, it skips updating it.

The commit fixes it by checking if endpoints informer cache is outdated
when processing a service. If the endpoints is stale, it returns an
error and retries later.

Signed-off-by: Quan Tian <quan.tian@broadcom.com>
2024-07-01 21:56:36 +08:00
Alvaro Aleman 6d0ac8c561 Use the generic/typed workqueue throughout
This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.
2024-05-04 14:33:12 -04:00
Mengjiao Liu b584b87a94 kube-controller-manager: readjust log verbosity
- Increase the global level for broadcaster's logging to 3 so that users can ignore event messages by lowering the logging level. It reduces information noise.
- Making sure the context is properly injected into the broadcaster, this will allow the -v flag value to be used also in that broadcaster, rather than the above global value.
- test: use cancellation from ktesting
- golangci-hints: checked error return value
2024-02-26 14:51:56 +08:00
Maciej Skrocki 29fad383da move endpointslice reconciler to staging endpointslice repo 2023-07-11 18:08:12 +00:00
Kubernetes Prow Robot 10a12165de Merge pull request #116755 from my-git9/feat/endpoint/logging
Migrated `pkg/controller/endpoint` to contextual logging
2023-07-10 05:37:05 -07:00
xin.li 325205efb7 Migrated pkg/controller/endpoint to contextual logging
Signed-off-by: xin.li <xin.li@daocloud.io>
2023-06-11 20:12:07 +08:00
Stephen Kitt 1c4b97ea27 network: replace intstr.FromInt with intstr.FromInt32
This touches cases where FromInt() is used on numeric constants, or
values which are already int32s, or int variables which are defined
close by and can be changed to int32s with little impact.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2023-05-01 09:17:30 +02:00
Tim Hockin bc302fa414 Replace uses of ObjectReflectDiff with cmp.Diff
ObjectReflectDiff is already a shim over cmp.Diff, so no actual output
or behavior changes
2023-04-12 08:48:03 -07:00
Viacheslav Panasovets 6adf60fdf4 Do not create endpoints if service of type ExternalName (#114814) 2023-01-18 03:12:34 -08:00
Kubernetes Prow Robot 7f7bf68c7c Merge pull request #111178 from lucming/cleanup
clean up code
2022-12-16 19:17:52 -08:00
John Howard d9f2cc0c95 endpoints: remove obsolete ServiceSelectorCache
Since https://github.com/kubernetes/kubernetes/pull/112648, we can
efficiently handle selectors from pre-existing `map[string]string`,
making the cache obsolete.

Benchmark:

```
name                         old time/op    new time/op    delta
GetPodServiceMemberships-48     189µs ± 1%     193µs ± 1%  +2.10%  (p=0.000 n=10+10)

name                         old alloc/op   new alloc/op   delta
GetPodServiceMemberships-48    59.0kB ± 0%    58.9kB ± 0%  -0.09%  (p=0.000 n=9+9)

name                         old allocs/op  new allocs/op  delta
GetPodServiceMemberships-48     1.02k ± 0%     1.02k ± 0%    ~     (all equal)
```
2022-12-12 08:00:48 -08:00
ialidzhikov aede3fbf40 pkg/controller: Replace deprecated func usage from the k8s.io/utils/pointer pkg 2022-11-23 17:40:23 +02:00
Kubernetes Prow Robot bf14677914 Merge pull request #112546 from oscr/the-the
grammar: replace all occurrences of "the the" with "the"
2022-10-19 10:03:02 -07:00
Kubernetes Prow Robot 28ced69b76 Merge pull request #113054 from logicalhan/proxy-metric
remove rate limiter metric as it is not in use
2022-10-17 11:09:18 -07:00
Oscar Utbult e4f776f230 grammar: replace all occurrences of "the the" with "the" 2022-10-14 09:03:14 +02:00
Han Kang 2bbd445f50 remove rate limiter metric as it is not in use
Change-Id: I91157653e3860eeecc3f572aee88da6ffc65faed
2022-10-13 13:07:11 -07:00
Antonio Ojea 5598735370 update sig-network reviewers/approvers on controller manager 2022-09-19 10:34:39 +02:00
lucming e536d565ea clean up code 2022-07-15 20:22:37 +08:00
ldsdsy eacddf9f28 Optimising print information 2022-07-14 15:03:03 +08:00
Wojciech Tyczyński c20f7cc4e1 Clean shutdown of endpoints/endpointslice integration tests 2022-05-30 20:17:35 +02:00
Rob Scott aa02b7a434 Updating e2e test to check EndpointSlices and Endpoints as well 2022-05-27 21:10:59 +00:00
Antonio Ojea aa35f6f160 endpoints controller: don't consider terminal endpoints
Terminal pods, whose phase its Failed or Succeeded, are guaranteed
to never regress and to be stopped, so their IPs never should
be published on the Endpoints.
2022-05-27 06:42:58 +02:00
Quan Tian 906e6d4670 Stop publishing Pod ResourceVersion in Endpoints and EndpointSlice API
The field is not used anywhere and its value may be stale as Endpoints
and EndpointSlice won't be updated if there is only Pod ResourceVersion
change..
2022-03-02 22:12:35 +08:00
Quan Tian 38966453ce Skip updating Endpoints and EndpointSlice if no relevant fields change
When comparing EndpointSubsets and Endpoints, we ignore the difference
in ResourceVersion of Pod to avoid unnecessary updates caused by Pod
updates that we don't care, e.g. annotation update.

Otherwise periodic Service resync would intensively update Endpoints or
EndpointSlice whose Pods have irrelevant change between two resyncs,
leading to delay in processing newly created Services. In a scale
cluster with thousands of such Endpoints, we observed 2 minutes of
delay when the resync happens.
2022-02-18 20:47:27 +08:00
He Xiaoxi ae9f117387 Remove tolerate-unready-endpoints annotation
Remove `tolerate-unready-endpoints` annotation in Service deprecated

from 1.11, use `Service.spec.publishNotReadyAddresses` instead.

Signed-off-by: He Xiaoxi <tossmilestone@gmail.com>
2022-02-09 17:17:29 +08:00