Commit Graph

244 Commits

Author SHA1 Message Date
Naman Lakhwani
8f45b64c93
Migrated pkg/controller/replicaset to contextual logging (#114871)
* migrated controller/replicaset to contextual logging

Signed-off-by: Naman <namanlakhwani@gmail.com>

* small nits

Signed-off-by: Naman <namanlakhwani@gmail.com>

* addressed changes

Signed-off-by: Naman <namanlakhwani@gmail.com>

* small nit

Signed-off-by: Naman <namanlakhwani@gmail.com>

* taking t as input

Signed-off-by: Naman <namanlakhwani@gmail.com>

---------

Signed-off-by: Naman <namanlakhwani@gmail.com>
2023-03-07 04:19:51 -08:00
Kubernetes Prow Robot
98742f9d77
Merge pull request #110747 from harshanarayana/cleanup/GIT-110737/logging-improvements
structured-logging: replace KObjs with KObjSlice for logging
2022-11-03 00:49:34 -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
Kubernetes Prow Robot
5c36a3c372
Merge pull request #110902 from 0xff-dev/master
convert int32 to pointer using library function
2022-10-14 08:48:46 -07: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
cndoit18
ec43037d0f style: remove redundant judgment
Signed-off-by: cndoit18 <cndoit18@outlook.com>
2022-08-25 12:07:36 +08:00
0xff-dev
0a77a9122f convert int32 to pointer using library function 2022-07-01 14:58:26 +08:00
Harsha Narayana
c3cbc443ef
structured-logging: replace KObjs with KObjSlice for logging 2022-07-01 09:52:07 +05:30
Wojciech Tyczyński
11b679c66a Fix event broadcaster shutdown in multiple controllers 2022-05-17 22:14:19 +02:00
Kubernetes Prow Robot
13ebb2e757
Merge pull request #99488 from chymy/rc-test-bug
Fix pkg/controller/replicaset/replica_set_test.go variable reference error
2022-03-26 11:45:21 -07:00
Kubernetes Prow Robot
973e77ceb1
Merge pull request #102330 from tnqn/replicaset-optimization
Add controllerUID index to improve ReplicaSetController performance
2022-02-10 10:15:46 -08:00
Jordan Liggitt
c0af728f43 Handle invalid selectors properly 2022-01-14 12:11:02 -05:00
Kubernetes Prow Robot
3bd422dc76
Merge pull request #107293 from dims/jan-1-owners-cleanup
Cleanup OWNERS files - Jan 2021 Week 1
2022-01-13 10:30:30 -08:00
Patrick Ohly
9eaa2dc554 avoid klog Info calls without verbosity
In the following code pattern, the log message will get logged with v=0 in JSON
output although conceptually it has a higher verbosity:

   if klog.V(5).Enabled() {
       klog.Info("hello world")
   }

Having the actual verbosity in the JSON output is relevant, for example for
filtering out only the important info messages. The solution is to use
klog.V(5).Info or something similar.

Whether the outer if is necessary at all depends on how complex the parameters
are. The return value of klog.V can be captured in a variable and be used
multiple times to avoid the overhead for that function call and to avoid
repeating the verbosity level.
2022-01-12 07:48:36 +01:00
Davanum Srinivas
9682b7248f
OWNERS cleanup - Jan 2021 Week 1
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-01-10 08:14:29 -05:00
Davanum Srinivas
9405e9b55e
Check in OWNERS modified by update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-12-09 21:31:26 -05:00
Mike Dame
80c01707e0
Wire contexts to Batch controllers (#105491)
* Wire contexts to Batch controllers

* (hold) feedback + updates that overlap with Apps controllers

* fixup errors
2021-11-10 14:56:46 -08:00
Mike Dame
41fcb95f2f Wire contexts to Apps controllers 2021-10-13 16:32:13 -04:00
Stephen Augustus
481cf6fbe7
generated: Run hack/update-gofmt.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>
2021-08-24 15:47:49 -04:00
Mike Dame
4b9230ed27 Promote LogarithmicScaleDown to beta
This promotes the LogarithmicScaleDown feature gate to Beta, enabling it
by default. It also introduces a new metric, `sorting_deletion_age_ratio`,
intended to measure the efficacy of this new replica set scaledown behavior.
2021-07-06 09:58:03 -04:00
Quan Tian
fc462857bb Add controllerUID index to improve ReplicaSetController performance
Instead of listing all ReplicaSets in the namespace and checking their
controller UID, this patch adds a controllerUID index to the ReplicaSet
store and use it to get ReplicaSets with same controller, which reduces
the cost from O(#ReplicaSets) to O(1).

Benchmark results:
```
name                                 old time/op    new time/op    delta
GetReplicaSetsWithSameController-48    18.2µs ± 9%     0.4µs ± 5%  -97.64%  (p=0.008 n=5+5)

name                                 old alloc/op   new alloc/op   delta
GetReplicaSetsWithSameController-48    4.18kB ± 0%    0.05kB ± 0%  -98.85%  (p=0.008 n=5+5)

name                                 old allocs/op  new allocs/op  delta
GetReplicaSetsWithSameController-48      15.0 ± 0%       2.0 ± 0%  -86.67%  (p=0.008 n=5+5)
```
2021-05-26 18:12:07 +08:00
Aldo Culquicondor
d8aad7944c Remove unused util CreatePods
And rename CreatePodsWithControllerRef to simply CreatePods
2021-05-20 20:27:21 +00:00
Kubernetes Prow Robot
86fdf7b56e
Merge pull request #99487 from chymy/fix-staticcheck0226
Fix staticcheck failures for pkg/controller/replicaset and pkg/kubelet/dockershim
2021-04-08 14:28:17 -07:00
Kubernetes Prow Robot
e7dc0df323
Merge pull request #97650 from ialidzhikov/cleanup/redundant-imports
Clean up some redundant imports
2021-04-08 14:27:22 -07:00
chymy
c28be0baab Fix staticcheck failures for pkg/controller/replicaset and pkg/kubelet/dockershim 2021-03-11 22:16:05 -05:00
Aldo Culquicondor
a8d105ab72 Logarithmic timestamp comparison for ReplicSet downscaling
Change-Id: I0657ea0ce41b98fdee1a5307b5826a10deaff98c
2021-03-05 15:58:26 -05:00
Supriya Premkumar
e52e5e486c
Adds ineffassign to GO linter script.
Changes:
 - Enables ineffassign check in the verify scripts.
 - Fixes lint errs.
2021-03-03 08:28:10 -08:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
chymy
d2868af029 Fix pkg/controller/replicaset/replica_set_test.go variable reference error
Signed-off-by: chymy <chang.min1@zte.com.cn>
2021-02-26 03:30:06 -05:00
ialidzhikov
1b74f28ed8 Clean up some redundant imports
Signed-off-by: ialidzhikov <i.alidjikov@gmail.com>
2021-01-02 01:09:22 +02:00
knight42
e89e72b637
test: ensure WaitForCacheSync is called after starting sharedInformerFacotry
Signed-off-by: knight42 <anonymousknight96@gmail.com>
2020-09-15 16:02:35 +08:00
Kobayashi Daisuke
4ae11dac2e Replace StartLogging(klog.Infof) with StartStructuredLogging(0) 2020-06-15 17:48:35 +09:00
tahsinrahman
78318c7a26 Migrate to log calls to klog.InfoS and klog.ErroS for pkg/controller 2020-06-05 13:23:01 +08:00
KeZhang
884f94ad92 Do not swallow NotFound error for DeletePod in dsc.manage 2020-06-04 16:41:38 +08:00
Davanum Srinivas
07d88617e5
Run hack/update-vendor.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:33 -04:00
Davanum Srinivas
442a69c3bd
switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:27 -04:00
Mike Danese
c58e69ec79 automated refactor 2020-03-05 14:59:46 -08:00
taesun_lee
79680b5d9b Fix pkg/controller typos in some error messages, comments etc
- applied review results by LuisSanchez
- Co-Authored-By: Luis Sanchez <sanchezl@redhat.com>

genernal -> general
iniital -> initial
initalObjects -> initialObjects
intentionaly -> intentionally
inforer -> informer
anotother -> another
triger -> trigger
mutli -> multi
Verifyies -> Verifies
valume -> volume
unexpect -> unexpected
unfulfiled -> unfulfilled
implenets -> implements
assignement -> assignment
expectataions -> expectations
nexpected -> unexpected
boundSatsified -> boundSatisfied
externel -> external
calcuates -> calculates
workes -> workers
unitialized -> uninitialized
afater -> after
Espected -> Expected
nodeMontiorGracePeriod -> NodeMonitorGracePeriod
estimateGrracefulTermination -> estimateGracefulTermination
secondrary -> secondary
ShouldRunDaemonPodOnUnscheduableNode -> ShouldRunDaemonPodOnUnschedulableNode
rrror -> error
expectatitons -> expectations
foud -> found
epackage -> package
succesfulJobs -> successfulJobs
namesapce -> namespace
ConfigMapResynce -> ConfigMapResync
2020-02-27 00:15:33 +09:00
Mike Danese
25651408ae generated: run refactor 2020-02-08 12:30:21 -05:00
Mike Danese
3aa59f7f30 generated: run refactor 2020-02-07 18:16:47 -08:00
Ted Yu
9cff345770 Do not swallow timeout in manageReplicas 2019-12-12 11:27:36 -08:00
Kubernetes Prow Robot
b2fb0f77ad
Merge pull request #82572 from tnozicka/fix-rs-expectations
Fix RS expectations for recreate case
2019-11-11 05:49:42 -08:00
Tomas Nozicka
ce52643f12 Update Bazel 2019-11-11 09:11:43 +01:00
Tomas Nozicka
6754b93f6b Fix RS informer handlers and handling expectations on delete 2019-11-11 09:11:43 +01:00
yuxiaobo
81e9f21f83 Correct spelling mistakes
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2019-11-06 20:25:19 +08:00
Kubernetes Prow Robot
6a19261e96
Merge pull request #84123 from smarterclayton/terminating_cause
Handle namespace deletion more gracefully in built-in controllers
2019-11-04 07:55:41 -08:00
wojtekt
7b6bcdf780 Autogenerated code 2019-10-24 20:21:00 +02:00
Clayton Coleman
2e8ace82eb
replicaset: Ignore namespace termination errors when creating pods
Instead of reporting an event or displaying an error, simply exit
when the namespace is being terminated. This reduces the amount of
controller churn on namespace shutdown. While we could technically
exit the entire processing loop early for very large replica sets,
we should wait for more evidence that is an issue before changing
that logic substantially.
2019-10-20 18:39:00 -04:00
Miciah Masters
980b6406b2 Prefer to delete doubled-up pods of a ReplicaSet
When scaling down a ReplicaSet, delete doubled up replicas first, where a
"doubled up replica" is defined as one that is on the same node as an
active replica belonging to a related ReplicaSet.  ReplicaSets are
considered "related" if they have a common controller (typically a
Deployment).

The intention of this change is to make a rolling update of a Deployment
scale down the old ReplicaSet as it scales up the new ReplicaSet by
deleting pods from the old ReplicaSet that are colocated with ready pods of
the new ReplicaSet.  This change in the behavior of rolling updates can be
combined with pod affinity rules to preserve the locality of a Deployment's
pods over rollout.

A specific scenario that benefits from this change is when a Deployment's
pods are exposed by a Service that has type "LoadBalancer" and external
traffic policy "Local".  In this scenario, the load balancer uses health
checks to determine whether it should forward traffic for the Service to a
particular node.  If the node has no local endpoints for the Service, the
health check will fail for that node.  Eventually, the load balancer will
stop forwarding traffic to that node.  In the meantime, the service proxy
drops traffic for that Service.  Thus, in order to reduce risk of dropping
traffic during a rolling update, it is desirable preserve node locality of
endpoints.

* pkg/controller/controller_utils.go (ActivePodsWithRanks): New type to
sort pods using a given ranking.
* pkg/controller/controller_utils_test.go (TestSortingActivePodsWithRanks):
New test for ActivePodsWithRanks.
* pkg/controller/replicaset/replica_set.go
(getReplicaSetsWithSameController): New method.  Given a ReplicaSet, return
all ReplicaSets that have the same owner.
(manageReplicas): Call getIndirectlyRelatedPods, and pass its result to
getPodsToDelete.
(getIndirectlyRelatedPods): New method.  Given a ReplicaSet, return all
pods that are owned by any ReplicaSet with the same owner.
(getPodsToDelete): Add an argument for related pods.  Use related pods and
the new getPodsRankedByRelatedPodsOnSameNode function to take into account
whether a pod is doubled up when sorting pods for deletion.
(getPodsRankedByRelatedPodsOnSameNode): New function.  Return an
ActivePodsWithRanks value that wraps the given slice of pods and computes
ranks where each pod's rank is equal to the number of active related pods
that are colocated on the same node.
* pkg/controller/replicaset/replica_set_test.go (newReplicaSet): Set
OwnerReferences on the ReplicaSet.
(newPod): Set a unique UID on the pod.
(byName): New type to sort pods by name.
(TestGetReplicaSetsWithSameController): New test for
getReplicaSetsWithSameController.
(TestRelatedPodsLookup): New test for getIndirectlyRelatedPods.
(TestGetPodsToDelete): Augment the "various pod phases and conditions, diff
= len(pods)" test case to ensure that scale-down still selects doubled-up
pods if there are not enough other pods to scale down.  Add a "various pod
phases and conditions, diff = len(pods), relatedPods empty" test case to
verify that getPodsToDelete works even if related pods could not be
determined.  Add a "ready and colocated with another ready pod vs not
colocated, diff < len(pods)" test case to verify that a doubled-up pod gets
preferred for deletion.  Augment the "various pod phases and conditions,
diff < len(pods)" test case to ensure that not-ready pods are preferred
over ready but doubled-up pods.
* pkg/controller/replicaset/BUILD: Regenerate.
* test/e2e/apps/deployment.go
(testRollingUpdateDeploymentWithLocalTrafficLoadBalancer): New end-to-end
test.  Create a deployment with a rolling update strategy and affinity
rules and a load balancer with "Local" external traffic policy, and verify
that set of nodes with local endponts for the service remains unchanged
during rollouts.
(setAffinity): New helper, used by
testRollingUpdateDeploymentWithLocalTrafficLoadBalancer.
* test/e2e/framework/service/jig.go (GetEndpointNodes): Factor building the
set of node names out...
(GetEndpointNodeNames): ...into this new method.
2019-10-17 11:52:32 -04:00
Miciah Masters
865c3c5670 TestGetPodsToDelete: Use field names in test cases
* pkg/controller/replicaset/replica_set_test.go (TestGetPodsToDelete): Use
explicit field names in declarations of test cases.
2019-10-17 11:50:09 -04:00