kubernetes: podLogsDir validation of default value breaks on windows

What happened?

Kubelet: a custom root directory for pod logs (instead of default /var/log/pods) can be specified using the podLogsDir key in kubelet configuration. (https://github.com/kubernetes/kubernetes/pull/112957, @mxpv) [SIG API Machinery, Node, Scalability and Testing]

podLogsDir is not added in cmd/kubelet/app/options/options.go so I can’t use this flag when running kubelet v1.30.0-beta.0.

also, when I ran it in windows (it’s fine when I ran it in linux), I got invalid configuration: pod logs path \"/var/log/pods\" must be absolute path, invalid configuration: pod logs path \"/var/log/pods\" must be normalized. Notice there are unexpected \ before quotes.

What did you expect to happen?

I should be able to run kubelet with --pod-logs-dir. If I don’t use this flag, it should correctly use default value.

How can we reproduce it (as minimally and precisely as possible)?

run newest kubelet on windows node with some necessary parameters

./kubelet --version
> Kubernetes v1.30.0-beta.0

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
# paste output here

Cloud provider

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 32 (29 by maintainers)

Most upvoted comments

@HuShaoRu It is intentional that it is an option only added to the config file (https://github.com/kubernetes/kubernetes/issues/124076#issuecomment-2022722888).

But those details helped, I am now able to reproduce your scenario. It would be helpful if you shared the command line you do run (minus any sensitive info).

with 1.30, Running with the bare minimal kubelet command line args we get:

.\kubelet.exe --cgroups-per-qos=false --enforce-node-allocatable=""
Flag --cgroups-per-qos has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
Flag --enforce-node-allocatable has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
config path: /var/log/pods
invalid configuration: pod logs path /var/log/pods must be absolute path

with 1.29, It starts up:

Flag --cgroups-per-qos has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
Flag --enforce-node-allocatable has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
I0402 08:32:30.934592   35592 server_windows.go:40] "Kubelet is running as" login name="" dispaly name="James Sturtevant"
E0402 08:32:30.937452   35592 server.go:268] "kubelet running with insufficient permissions" err="kubelet needs to run with elevated permissions!"
I0402 08:32:30.938048   35592 server.go:468] "Kubelet version" kubeletVersion="v1.29.0-alpha.1.121+00c6d9329ecfbd"
I0402 08:32:30.938597   35592 server.go:470] "Golang settings" GOGC="" GOMAXPROCS="" GOTRACEBACK=""
I0402 08:32:30.938827   35592 init_windows.go:82] "Creating a Windows job object and adding kubelet process to it" windowsPriorityClass="NORMAL_PRIORITY_CLASS"

So there are two issues:

  1. when there is no config file present it is not possible start kubelet with command line options any more
  2. when using the config, the pod log path, now goes through the resolveRelativePaths code path and filepath.IsAbs(*path) which it is treating it like a relative path which could end up putting the path somewhere not expected.

For 1) I can see it going either way. In this case the default provided should be respected, but at some future release we might need to say that the config is required.

validateKubeletOSConfiguration

this is related to my open PR here:

the kubelet on Windows should not throw errors with the defaults (which are Linux defaults).

Turns out there are some failing and flaky tests in the Windows unit tests. I am hoping we can disable them for now and keep enabling them as they are fixed, so that we can run the passing tests by default.

Should we consider running the Windows unit test by default for all PRs?

+1