Commit Graph

2432 Commits

Author SHA1 Message Date
Dan Winship
4381973a44 Revert (most of) "Issue 70020; Flush Conntrack entities for SCTP"
This commit did not actually work; in between when it was first
written and tested, and when it merged, the code in
pkg/proxy/endpoints.go was changed to only add UDP endpoints to the
"stale endpoints"/"stale services" lists, and so checking for "either
UDP or SCTP" rather than just UDP when processing those lists had no
effect.

This reverts most of commit aa8521df66
(but leaves the changes related to
ipvs.IsRsGracefulTerminationNeeded() since that actually did have the
effect it meant to have).
2023-03-14 12:18:58 -04:00
Dan Winship
eaa0791b56 copy pkg/proxy OWNERS to pkg/util/conntrack 2023-03-13 11:20:36 -04:00
Kubernetes Prow Robot
fa294f3e4e
Merge pull request #115527 from sondinht/ipvs_sh
Ipvs: Enable Source Port hash flag for "mh" method.
2023-02-14 04:25:30 -08:00
Lars Ekman
50cfd6ca80 Add uablrek in pkg/util/ipvs/OWNERS 2023-02-13 19:11:21 +01:00
Son Dinh
4f75949bcb Ipvs: Add a new FlagSourceHash to "mh" distribution method.
With the flag, ipvs uses both source IP and source port (instead of
only source IP) to distribute new connections evently to endpoints
that avoids sending all connections from the same client (i.e. same
source IP) to one single endpoint.

User can explicitly set sessionAffinity in service spec to keep all
connections from a source IP to end up on the same endpoint if needed.

Change-Id: I42f950c0840ac06a4ee68a7bbdeab0fc5505c71f
2023-02-11 20:51:02 +11:00
Artem Minyaylov
f573e14942 Update k8s.io/utils to latest version
Update all usages of FakeExec to pointer to avoid copying the mutex
2023-02-04 11:05:22 -08:00
Dan Winship
f994ae2521 Move GetHostname() from k/k/pkg/util/node to k/component-helpers/node/util
In fact, this actually uses pkg/util/node's GetHostname() but takes
the unit tests from cmd/kubeadm/app/util's private fork of that
function since they were more extensive. (Of course the fact that
kubeadm had a private fork of this function is a strong argument for
moving it to component-helpers.)
2023-01-27 18:24:38 -05:00
HirazawaUi
488b34eeb2 delete unused functions in pkg/util directory 2023-01-16 17:22:35 +08:00
Lars Ekman
90c03dcf9a gofmt 2022-12-23 12:34:31 +01:00
Lars Ekman
4ef7726c4e Remove obsolete test case 2022-12-23 11:46:45 +01:00
Lars Ekman
cf214d0738 Clean-up un-used code 2022-12-23 10:54:51 +01:00
Kubernetes Prow Robot
112a7a590c
Merge pull request #110723 from yangjunmyfm192085/fixklog
Fix incorrect log information and log structure
2022-12-16 19:17:41 -08:00
cncal
2670042dde fix wrong statement in unittest of BoundedFrequencyRunner 2022-11-15 17:36:26 +08:00
Michal Wozniak
4e732e20d0 Do not revert the pod condition if there might be running containers, skip condition update instead. 2022-11-07 16:22:29 +01:00
Kubernetes Prow Robot
3edbebe348
Merge pull request #110268 from danwinship/minimize-iptables-changes
minimize iptables-restore input
2022-11-01 18:06:46 -07:00
Kubernetes Prow Robot
4c657e5014
Merge pull request #110403 from claudiubelu/unittests-3
unittests: Fixes unit tests for Windows (part 3)
2022-10-31 15:52:44 -07:00
Kubernetes Prow Robot
36dd5f2846
Merge pull request #113191 from saltbo/refa-remove-unused-ipconfig
Remove the unused pkg/util/ipconfig
2022-10-23 19:22:25 -07:00
JunYang
856146e67e Fix incorrect log information
Update pkg/util/iptables/iptables.go

Co-authored-by: Dan Winship <danwinship@redhat.com>

Update pkg/util/iptables/iptables.go

Co-authored-by: Dan Winship <danwinship@redhat.com>

Update pkg/util/iptables/iptables.go

Co-authored-by: Dan Winship <danwinship@redhat.com>

Update pkg/util/iptables/iptables.go

Co-authored-by: Dan Winship <danwinship@redhat.com>

Update pkg/util/iptables/iptables.go

Co-authored-by: Dan Winship <danwinship@redhat.com>

Update pkg/util/iptables/iptables.go

Co-authored-by: Dan Winship <danwinship@redhat.com>

Update pkg/util/iptables/iptables.go

Co-authored-by: Dan Winship <danwinship@redhat.com>

Update pkg/util/iptables/iptables.go

Co-authored-by: Dan Winship <danwinship@redhat.com>
2022-10-24 08:36:52 +08:00
Claudiu Belu
9f95b7b18c unittests: Fixes unit tests for Windows (part 3)
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- paths not properly joined (filepath.Join should be used).
- Proxy Mode IPVS not supported on Windows.
- DeadlineExceeded can occur when trying to read data from an UDP
  socket. This can be used to detect whether the port was closed or not.
- In Windows, with long file name support enabled, file names can have
  up to 32,767 characters. In this case, the error
  windows.ERROR_FILENAME_EXCED_RANGE will be encountered instead.
- files not closed, which means that they cannot be removed / renamed.
- time.Now() is not as precise on Windows, which means that 2
  consecutive calls may return the same timestamp.
- path.Base() will return the same path. filepath.Base() should be used
  instead.
- path.Join() will always join the paths with a / instead of the OS
  specific separator. filepath.Join() should be used instead.
2022-10-21 19:25:48 +03:00
saltbo
cc90e819bc
refactor: replace the ioutil by the os and io
Signed-off-by: saltbo <saltbo@foxmail.com>
2022-10-20 15:13:28 +08:00
saltbo
266404ec8c
refactor: remove the unused pkg/util/ipconfig
Signed-off-by: saltbo <saltbo@foxmail.com>
2022-10-20 14:21:42 +08:00
Amim Knabben
7df6c02288 Remove Linux and Windows Kube-proxy Userspace mode 2022-10-05 16:59:02 -03:00
Dan Winship
818de5a545 proxy/iptables: Add metric for partial sync failures, add test 2022-09-26 16:31:42 -04:00
Mengjiao Liu
1b9e4eb073 Improve test readability by fixing previous code variables that could easily be changed and
improve unit test coverage in `pkg/util/taints/taints_test.go`
2022-09-16 17:23:35 +08:00
Mengjiao Liu
3ee0eea45c Remove unused functions in pkg/util/taints/ 2022-09-14 11:13:03 +08:00
Kubernetes Prow Robot
baf6014e0c
Merge pull request #112182 from dcbw/pkg-util-ipset-sig-net-approvers
pkg/util/ipset: add sig-network to reviewers/approvers
2022-09-01 20:08:04 -07:00
Kubernetes Prow Robot
9924814270
Merge pull request #108460 from Nordix/issue-72236
Prevent host access on VIP addresses in proxy-mode=ipvs
2022-09-01 12:59:18 -07:00
Dan Williams
24cf5e51a5 pkg/util/ipset: add sig-network to reviewers/approvers
Signed-off-by: Dan Williams <dcbw@redhat.com>
2022-09-01 11:35:11 -05:00
Aaron Crickenberger
cb98449156 pkg/util/coverage: update fakeTestDeps impl
testing.testDeps has had more methods added so fakeTestDeps needs to
follow suit
2022-08-25 17:23:49 -07:00
lojies
89fdd8858b code cleanup: omit comparison to bool constant 2022-08-17 14:46:32 +08:00
Michal Wozniak
04fcbd721c Introduction of a pod condition type indicating disruption. Its reason field indicates the reason:
- PreemptionByKubeScheduler (Pod preempted by kube-scheduler)
- DeletionByTaintManager (Pod deleted by taint manager due to NoExecute taint)
- EvictionByEvictionAPI (Pod evicted by Eviction API)
- DeletionByPodGC (an orphaned Pod deleted by PodGC)PreemptedByScheduler (Pod preempted by kube-scheduler)
2022-08-02 11:12:16 +02:00
Davanum Srinivas
a9593d634c
Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-07-26 13:14:05 -04:00
jianfei.zhang
49e7a7b51d fix:handle error and remove Redundant type conversion
Signed-off-by: jianfei.zhang <jianfei.zhang@daocloud.io>
2022-07-19 11:30:46 +08:00
Kubernetes Prow Robot
a3f777603b
Merge pull request #110825 from zhoumingcheng/master-unit-v4
add unit test coverage for pkg/util/node and Remove duplicate testcases for func TestGetNodeHostIPs
2022-07-10 20:55:46 -07:00
zhoumingcheng
673930e384 update test func for pkg/util/node
Signed-off-by: zhoumingcheng <zhoumingcheng@beyondcent.com>
2022-07-07 10:45:45 +08:00
zhoumingcheng
509c487fe8 add unit test coverage for pkg/util/slice
Signed-off-by: zhoumingcheng <zhoumingcheng@beyondcent.com>
2022-06-30 15:21:37 +08:00
Kubernetes Prow Robot
0d9ed2c3e7
Merge pull request #110328 from danwinship/iptables-counters
Stop trying to "preserve" iptables counters that are always 0
2022-06-29 08:06:06 -07:00
Dan Winship
7c27cf0b9b Simplify iptables-save parsing
We don't need to parse out the counter values from the iptables-save
output (since they are always 0 for the chains we care about). Just
parse the chain names themselves.

Also, all of the callers of GetChainLines() pass it input that
contains only a single table, so just assume that, rather than
carefully parsing only a single table's worth of the input.
2022-06-28 08:39:32 -04:00
Dan Winship
4988699c2f Use dedent to fix GetChainLines() tests
The test was calling GetChainLines() on invalid pseudo-iptables-save
output where most of the lines were indented. GetChainLines() happened
to still parse this "correctly", but it would be better to be testing
it on actually-correct data.
2022-06-28 08:39:32 -04:00
zhoumingcheng
8dfb7af374 update unit test for pkg/util/node
Remove duplicate testcases for func TestGetNodeHostIPs

Signed-off-by: zhoumingcheng <zhoumingcheng@beyondcent.com>
2022-06-28 17:40:04 +08:00
zhoumingcheng
540ec51196 add unit test coverage for pkg/util/node
Signed-off-by: zhoumingcheng <zhoumingcheng@beyondcent.com>
2022-06-28 16:07:30 +08:00
21kyu
df168d5b5c Change reflect.Ptr to reflect.Pointer 2022-06-26 01:23:43 +09:00
Lars Ekman
c1e5a9e6f0 Prevent host access on VIP addresses in proxy-mode=ipvs 2022-06-24 08:33:58 +02:00
Kubernetes Prow Robot
dc4e91a875
Merge pull request #109844 from danwinship/iptables-tests-new
improve parsing in iptables unit tests
2022-06-10 14:27:44 -07:00
Dan Winship
913f4bc0ba pkg/util/iptables/testing: Fix FakeIPTables
FakeIPTables barely implemented any of the iptables interface, and the
main part that it did implement, it implemented incorrectly. Fix it:

- Implement EnsureChain, DeleteChain, EnsureRule, and DeleteRule, not
  just SaveInto/Restore/RestoreAll.

- Restore/RestoreAll now correctly merge the provided state with the
  existing state, rather than simply overwriting it.

- SaveInto now returns the table that was requested, rather than just
  echoing back the Restore/RestoreAll.
2022-05-09 11:29:08 -04:00
Dan Winship
10a72a9e03 pkg/util/iptables/testing: Add IPTables dump-parsing helpers 2022-05-09 11:29:06 -04:00
Dan Winship
f2fa1033d0 pkg/util/iptables/testing: Add better IPTables rule-parsing helpers
There were previously some strange iptables-rule-parsing functions
that were only used by two unit tests in pkg/proxy/ipvs. Get rid of
them and replace them with some much better iptables-rule-parsing
functions.
2022-05-09 11:19:26 -04:00
Benjamin Elder
830456e027 correct coverage MainStart argument order 2022-05-05 14:00:21 -07:00
Benjamin Elder
5d8f6f1213 fix e2e coverage package for go 1.18 2022-04-27 10:05:51 -07:00
Ashutosh Kumar
c00975370a
Handle Non-graceful Node Shutdown (#108486)
Signed-off-by: Ashutosh Kumar <sonasingh46@gmail.com>

Co-authored-by: Ashutosh Kumar <sonasingh46@gmail.com>

Co-authored-by: xing-yang <xingyang105@gmail.com>
2022-03-26 09:23:21 -07:00