2504 Commits

Author SHA1 Message Date
Dan Winship
8c98dee1ed Add utiliptables.NewDualStack
Basically all callers want dual-stack-if-possible, so simplify that.

Also, tweak the startup-time checking in kubelet to treat "no iptables
support" as interesting but not an error.
2025-03-08 10:14:17 -05:00
Dan Winship
b031258969 Improve utiliptables error handling when there's no iptables binary
If `iptables --version` failed, utiliptables.New() would log a warning
and assume that the problem was that you had an implausibly ancient
version of iptables installed. Change it to instead assume that the
problem is that you don't have iptables installed at all (and don't
log anything; the caller will discover this later).
2025-03-08 10:11:16 -05:00
Dan Winship
f1d0eb4fe4 Add a unit test for utiliptables.New() 2025-03-08 10:11:16 -05:00
Dan Winship
9c98d29795 Remove exec arg from utiliptables.New
It was there so you could mock the results via a FakeExec, but these
days any unit tests outside of pkg/util/iptables that want to mock
iptables results use a FakeIPTables instead of a real
utiliptables.Interface with a FakeExec.
2025-03-08 10:11:15 -05:00
Kubernetes Prow Robot
0eaee48ecb Merge pull request #130569 from dims/update-to-latest-cadvisor-v0.52.0
Update to latest cadvisor @ v0.52.1 and new opencontainer/cgroups and drops opencontainers/runc
2025-03-07 17:09:51 -08:00
Kubernetes Prow Robot
1c9840c58e Merge pull request #130243 from rata/revert-userns-kernel-check
Revert userns kernel check
2025-03-07 02:35:44 -08:00
Davanum Srinivas
5ecddb6571 update to latest cadvisor @ v0.52.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2025-03-05 06:36:39 -05:00
Kubernetes Prow Robot
47dbade7f4 Merge pull request #130245 from marosset/windows-unit-tests-pkg-util-filesystem-fixes
Fixing k8s.io/kubernetes/pkg/util/filesystem unit tests for Windows
2025-03-03 16:59:41 -08:00
Mark Rossetti
5eb37b073c Fixing k8s.io/kubernetes/pkg/util/filesystem unit tests for Windows
Signed-off-by: Mark Rossetti <marosset@microsoft.com>
2025-02-27 13:50:24 -08:00
mansikulkarni96
dfc8b271cf [kubelet] Make use of os.ModeSocket info 2025-02-21 18:02:25 -05:00
Kubernetes Prow Robot
b84cb65f93 Merge pull request #129370 from andyzhangx/adopt-go1.23-behavior-change
fix: adopt go1.23 behavior change in mount point parsing on Windows#2
2025-02-21 12:50:26 -08:00
Rodrigo Campos
7deb49e3a6 Revert "Enforce the Minimum Kernel Version 6.3 for UserNamespacesSupport feature"
This reverts commit 8597b343fa.

I wrote in the Kubernetes documentation:

	In practice this means you need at least Linux 6.3, as tmpfs started
	supporting idmap mounts in that version. This is usually needed as
	several Kubernetes features use tmpfs (the service account token that is
	mounted by default uses a tmpfs, Secrets use a tmpfs, etc.)

The check is wrong for several reasons:
	* Pods can use userns before 6.3, they will just need to be
	  careful to not use a tmpfs (like a serviceaccount). MOST users
	  will probably need 6.3, but it is possible to use earlier kernel
	  versions. 5.19 probably works fine and with improvements in
          the runtime 5.12 can probably be supported too.
	* Several distros backport changes and the recommended way is
	  usually to try the syscall instead of testing kernel versions.
	  I expect support for simple fs like tmpfs will be backported
	  in several distros, but with this check it can generate confusion.
	* Today a clear error is shown when the pod is created, so it's
	  unlikely a user will not understand why it fails.
	* Returning an error if utilkernel fails to understand what
	  kernel version is running is also too strict (as we are
	  logging a warning even if it is not the expected version)
	* We are switching to enabled by default, which will log a
	  warning on every user that runs on an older than 6.3 kernel,
	  adding noise to the logs.

For there reasons, let's just remove the hardcoded kernel version check.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2025-02-18 17:24:50 +01:00
andyzhangx
bb49a05fb5 fix: adopt go1.23 behavior change in mount point parsing on Windows
fix comments
2025-02-18 07:17:51 +00:00
Tim Allclair
a7340ff36c [windows] Don't chown existing directory in MkdirAll 2024-12-16 14:10:56 -08: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
Kubernetes Prow Robot
469524442f Merge pull request #126621 from my-git9/node-deadcode-remove
Remove deadcode in pkg/util/node
2024-11-08 16:38:45 +00:00
nikzayn
ab87218cf1 feat: support changes for net.ipv4.tcp_rmem and net.ipv4.tcp_wmem #125234
Signed-off-by: nikzayn <nikhilvaidyar1997@gmail.com>
2024-09-20 11:22:28 +08:00
Kubernetes Prow Robot
b005b40027 Merge pull request #125136 from mauri870/feature/wsl2-kernel-test
util: add test case for WSL kernel version parsing
2024-09-19 20:23:27 +01:00
xin.li
b24804faf8 remove deadcode in pkg/util/node
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-08-10 23:32:23 +08:00
Kubernetes Prow Robot
9c763a9c9f Merge pull request #126104 from cji/5321
Add funcs in pkg/filesystem/util to set file permissions on Windows and update container log dir perms
2024-07-16 10:33:05 -07:00
Mark Rossetti
b377dfba0c Add funcs in pkg/filesystem/util that can actually set file permissiosn
on Windows and update container log dir perms to 660 on Windows
2024-07-15 14:22:59 -07:00
Kubernetes Prow Robot
fe1840205c Merge pull request #125926 from MadhavJivrajani/bump-staticcheck-exclude-SA1006
[go1.23] hack: bump go-tools and exclude SA1006
2024-07-15 10:05:19 -07:00
Madhav Jivrajani
c5481b0413 .*: fix lint errors
Fix SA4032 and SA3000 which are flagged after bumping to go1.23rc1
and v0.5.0-rc1 of go-tools.

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
2024-07-15 15:03:15 +05:30
Dan Winship
505f6833d9 Require kernel 5.13 for nftables kube-proxy 2024-07-01 10:07:27 -04:00
Antonio Ojea
f36975b193 remove iptree from tree 2024-06-27 11:33:36 +00:00
Kubernetes Prow Robot
eb6840928d Merge pull request #124160 from Karthik-K-N/fix-buildconstraints
Add doc.go file without any buildconstraint to run tests on non linux platforms
2024-06-13 16:29:06 -07:00
Sascha Grunert
0c9949b6ec Move pkg/kubelet/kuberuntime/logs to k8s.io/cri-client staging
Particulary helpful to decouple cri-tools from k/k.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2024-05-30 15:13:22 +02:00
Mauri de Souza Meneguzzo
b8e5a3ed32 pkg/util/coverage: update fakeTestDeps methods
Go 1.23 changed the signature of the testDeps interface so we need to
add a blank implementation for InitRuntimeCoverage to fakeTestDeps.
2024-05-29 12:31:22 -03:00
Mauri de Souza Meneguzzo
7fcaaa5585 util: add test case for WSL kernel version parsing 2024-05-26 18:40:10 -03:00
Itamar Holder
2a174d09fa If the kernel version is at least 6.4, assume tmpfs noswap is supported
Signed-off-by: Itamar Holder <iholder@redhat.com>
2024-05-21 13:18:16 +03:00
Davanum Srinivas
8597b343fa Enforce the Minimum Kernel Version 6.3 for UserNamespacesSupport feature
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-05-07 16:01:42 -04:00
Kubernetes Prow Robot
7f67cb5960 Merge pull request #123969 from liangyuanpeng/cleanup_rand
cleanup: delete rand.Seed(time.Now().UnixNano()) and using global number generator.
2024-04-18 02:10:26 -07:00
Maksym Pavlenko
be4b7176dc Fix Abs path validation on Windows (#124084)
* Windows: Consider slash-prefixed paths as absolute

filepath.IsAbs does not consider "/" or "\" as absolute paths, even
though files can be addressed as such. [1][2]

Currently, there are some unit tests that are failing on Windows due to
this reason.

[1] https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#traditional-dos-paths
[2] https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#fully-qualified-vs-relative-paths

* Add test to verify IsAbs for windows

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

* Fix abs path validation on windows

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

* Skipp path clean check for podLogDir on windows

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

* Implement IsPathClean to validate path

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

* Add warn comment for IsAbs

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>

---------

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
Co-authored-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
2024-04-10 10:13:59 -07:00
Karthik K N
134e43c279 Add doc.go file without any buildconstraint to run tests on non linux systems 2024-04-03 12:30:59 +05:30
Lan Liang
dc992adad3 cleanup: delete rand.Seed(time.Now().UnixNano()) and using global number generator.
see https://tip.golang.org/doc/go1.20

Signed-off-by: Lan Liang <gcslyp@gmail.com>
2024-03-18 08:10:12 +00:00
Tim Hockin
6dbc754ed6 Retool typecheck to be simpler
Instead of walking paths ourselves, just let Go's packages library do
it.  This is a slight CLI change - it wants "./foo" rather than "foo".

This also flagged a few things which seem to be legit failures.
2024-02-29 22:07:00 -08:00
Jordan Liggitt
5dc92ada06 Implement authz config file reloading 2024-02-14 18:09:15 -05:00
Tim Allclair
01155f59c3 Merge pkg/util/config into pkg/kubelet/config 2024-01-30 11:57:35 -08:00
Tim Allclair
049261aca1 Delete unused config utilities 2024-01-30 11:46:18 -08:00
Kubernetes Prow Robot
56ee53faf5 Merge pull request #110601 from claudiubelu/path-filepath-update
Replaces path.Operation with filepath.Operation
2024-01-29 06:49:26 -08:00
Claudiu Belu
c65d9e4d59 Replaces path.Operation with filepath.Operation
The path module has a few different functions:
Clean, Split, Join, Ext, Dir, Base, IsAbs. These functions do not
take into account the OS-specific path separator, meaning that they
won't behave as intended on Windows.

For example, Dir is supposed to return all but the last element of the
path. For the path "C:\some\dir\somewhere", it is supposed to return
"C:\some\dir\", however, it returns ".".

Instead of these functions, the ones in filepath should be used instead.
2024-01-15 20:35:13 +00:00
Dan Winship
c1ce1e00ee Properly build-tag the Linux kube-proxy backend code
This had to be able to build on OS X before to make verify-typecheck
pass, but now that that's fixed we can tag the code properly as being
linux-only.
2023-12-18 20:20:51 -05:00
Kubernetes Prow Robot
b54e719509 Merge pull request #122111 from danwinship/proxy-chain-creation-cleanup
proxy chain creation cleanup
2023-12-14 06:17:40 +01:00
Kubernetes Prow Robot
d43e9a2654 Merge pull request #122093 from npolshakova/small-fix-getchainsfromtable
Fix error check in GetChainsFromTables
2023-12-14 06:17:31 +01:00
npolshakova
a82ee6d416 fix error check 2023-11-29 11:55:30 -05:00
Dan Winship
8acf185791 Use a generic Set for utiliptables.GetChainsFromTable 2023-11-29 11:12:27 -05:00
21kyu
fec63d5ea0 fix: use generic set in pkg/util/iptables 2023-11-08 15:21:59 +00:00
Antonio Ojea
d3386e171a add iptree radix tree util
A radix tree is required to optimize operations with subnets and
IP addresses.

Change-Id: I9fecc291efd39bdd7403c9675c047d6dee6018d2

Change-Id: I72c7bd5920a42bf35305443450c4ba97f857c492
2023-10-31 21:05:04 +00:00
Daman Arora
a375aa28ee pkg/proxy: move get kernel version out of ipvs proxier
Signed-off-by: Daman Arora <aroradaman@gmail.com>
2023-10-28 00:54:34 +05:30
Kubernetes Prow Robot
7824ac0f3e Merge pull request #114336 from claudiubelu/fixes-test-get-file-type
unittests: Fixes hostutil.GetFileType for Windows
2023-10-17 20:07:39 +02:00