kubernetes: Node Status Error Handling in Kubelet

What happened?

The node’s Ready condition is True,

Conditions:
  Type                                 Status    LastHeartbeatTime                 LastTransitionTime                Reason                               Message
  ----                                 ------    -----------------                 ------------------                ------                               -------
  Ready                                True      Mon, 18 Sep 2023 14:13:43 +0800   Sun, 17 Sep 2023 07:57:37 +0800   KubeletReady                         kubelet is posting ready status

but node.status.addresses is empty. This indicates an issue populating the addresses field.

node status status: allocatable: cpu: "15" ephemeral-storage: "152933498761" hugepages-1Gi: "0" hugepages-2Mi: "0" memory: 30031224Ki pods: "200" capacity: cpu: "16" ephemeral-storage: 153525Mi hugepages-1Gi: "0" hugepages-2Mi: "0" memory: 32591224Ki pods: "200" conditions: - lastHeartbeatTime: "2023-09-18T06:13:43Z" lastTransitionTime: "2023-09-16T23:57:37Z" message: kubelet is posting ready status reason: KubeletReady status: "True" type: Ready

which is then causing cascading issues with pod scheduling and status reporting:

Pods scheduled on the node fail with a “CreateContainerConfigError” due to the pod not having the node’s IP address available(pod access status.hostIP by downward API)

ipamd-hwg2q                                       0/1     CreateContainerConfigError   0                  3h14m   <none>         10.29.20.162   <none>           <none>

This is because pod.status.hostIP is empty.

status: conditions: - lastProbeTime: null lastTransitionTime: "2023-09-18T03:26:47Z" status: "True" type: Initialized - lastProbeTime: null lastTransitionTime: "2023-09-18T03:26:47Z" message: 'containers with unready status: [ipamd]' reason: ContainersNotReady status: "False" type: Ready - lastProbeTime: null lastTransitionTime: "2023-09-18T03:26:47Z" message: 'containers with unready status: [ipamd]' reason: ContainersNotReady status: "False" type: ContainersReady - lastProbeTime: null lastTransitionTime: "2023-09-18T03:26:47Z" status: "True" type: PodScheduled containerStatuses: - image: registry.tce.com/ipam/ipamd:0.1.0-20230428-221008-74c66c6.rhel.amd64 imageID: "" lastState: {} name: ipamd ready: false restartCount: 0 started: false state: waiting: message: 'host IP unknown; known addresses: []' reason: CreateContainerConfigError phase: Pending qosClass: Burstable startTime: "2023-09-18T03:26:47Z"

In the kubelet logs, we see an error about failing to start containers.

9月 18 09:22:21 tcs-10-29-20-162 kubelet[8663]: E0918 09:22:21.028249 8663 kuberuntime_manager.go:934] container &Container{Name:ipamd,Image:registry.tce.com/ipam/ipamd:0.1.0-20230428-221008-74c66c6.rhel.amd64,Command:[/ipamd],Args:[--node-name=$(NODE_NAME) --metric-server=:27997 --v=2 --ip-family-policy=dual-stack],WorkingDir:,Ports:[]ContainerPort{},Env:[]EnvVar{EnvVar{Name:NODE_NAME,Value:,ValueFrom:&EnvVarSource{FieldRef:&ObjectFieldSelector{APIVersion:v1,FieldPath:spec.nodeName,},ResourceFieldRef:nil,ConfigMapKeyRef:nil,SecretKeyRef:nil,},},EnvVar{Name:POD_NAME,Value:,ValueFrom:&EnvVarSource{FieldRef:&ObjectFieldSelector{APIVersion:v1,FieldPath:metadata.name,},ResourceFieldRef:nil,ConfigMapKeyRef:nil,SecretKeyRef:nil,},},EnvVar{Name:POD_NAMESPACE,Value:,ValueFrom:&EnvVarSource{FieldRef:&ObjectFieldSelector{APIVersion:v1,FieldPath:metadata.namespace,},ResourceFieldRef:nil,ConfigMapKeyRef:nil,SecretKeyRef:nil,},},EnvVar{Name:HOST_IP,Value:,ValueFrom:&EnvVarSource{FieldRef:&ObjectFieldSelector{APIVersion:v1,FieldPath:status.hostIP,},ResourceFieldRef:nil,ConfigMapKeyRef:nil,SecretKeyRef:nil,},},},Resources:ResourceRequirements{Limits:ResourceList{cpu: {{500 -3} {<nil>} 500m DecimalSI},memory: {{536870912 0} {<nil>} BinarySI},},Requests:ResourceList{cpu: {{0 0} {<nil>} 0 DecimalSI},memory: {{0 0} {<nil>} 0 DecimalSI},},},VolumeMounts:[]VolumeMount{VolumeMount{Name:cilium-run,ReadOnly:false,MountPath:/var/run/cilium,SubPath:,MountPropagation:nil,SubPathExpr:,},VolumeMount{Name:kube-api-access-8t6j7,ReadOnly:true,MountPath:/var/run/secrets/kubernetes.io/serviceaccount,SubPath:,MountPropagation:nil,SubPathExpr:,},},LivenessProbe:nil,ReadinessProbe:nil,Lifecycle:nil,TerminationMessagePath:/dev/termination-log,ImagePullPolicy:IfNotPresent,SecurityContext:nil,Stdin:false,StdinOnce:false,TTY:false,EnvFrom:[]EnvFromSource{},TerminationMessagePolicy:File,VolumeDevices:[]VolumeDevice{},StartupProbe:nil,} start failed in pod ipamd-mfkfz_kube-system(cccf6134-af35-4d35-8ba0-fa5205d7ebb5): CreateContainerConfigError: host IP unknown; known addresses: [] 9月 18 09:22:21 tcs-10-29-20-162 kubelet[8663]: E0918 09:22:21.028286 8663 pod_workers.go:951] "Error syncing pod, skipping" err="failed to \"StartContainer\" for \"ipamd\" with CreateContainerConfigError: \"host IP unknown; known addresses: []\"" pod="kube-system/ipamd-mfkfz" podUID=cccf6134-af35-4d35-8ba0-fa5205d7ebb5

kubectl logs does not work properly for the same reason - no IP address for the node.

# kubectl  -n kube-system logs -f <running-pod>
Error from server: no preferred addresses found; known addresses: []
kubectl logs -v 8 I0918 14:18:12.329857 3930520 round_trippers.go:432] GET https://kubernetes-apiserver.kube-system.svc.global.shanxi.tcs.internal:6443/api/v1/namespaces/kube-system/pods/csi-driver-localpv-plugin-m6s2g/log?container=plugin&follow=true&tailLines=10 I0918 14:18:12.329899 3930520 round_trippers.go:438] Request Headers: I0918 14:18:12.329915 3930520 round_trippers.go:442] Accept: application/json, */* I0918 14:18:12.329925 3930520 round_trippers.go:442] User-Agent: kubectl/v1.22.0 (linux/amd64) kubernetes/7e39abe I0918 14:18:12.334232 3930520 round_trippers.go:457] Response Status: 500 Internal Server Error in 4 milliseconds I0918 14:18:12.334253 3930520 round_trippers.go:460] Response Headers: I0918 14:18:12.334259 3930520 round_trippers.go:463] Cache-Control: no-cache, private I0918 14:18:12.334271 3930520 round_trippers.go:463] Content-Type: application/json I0918 14:18:12.334278 3930520 round_trippers.go:463] Content-Length: 142 I0918 14:18:12.334289 3930520 round_trippers.go:463] Date: Mon, 18 Sep 2023 06:18:12 GMT I0918 14:18:12.334300 3930520 round_trippers.go:463] Audit-Id: 523cc374-3ce9-409b-ab88-5bf8a0b65d81 I0918 14:18:12.334327 3930520 request.go:1181] Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"no preferred addresses found; known addresses: []","code":500} I0918 14:18:12.334718 3930520 helpers.go:217] server response object: [{ "metadata": {}, "status": "Failure", "message": "no preferred addresses found; known addresses: []", "code": 500 }] F0918 14:18:12.334750 3930520 helpers.go:116] Error from server: no preferred addresses found; known addresses: [] goroutine 1 [running]: k8s.io/kubernetes/vendor/k8s.io/klog/v2.stacks(0x1) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/klog/v2/klog.go:1026 +0x8a k8s.io/kubernetes/vendor/k8s.io/klog/v2.(*loggingT).output(0x317ada0, 0x3, {0x0, 0x0}, 0xc00081e460, 0x2, {0x26a8e17, 0xc000500000}, 0xc0005c2e50, 0x0) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/klog/v2/klog.go:975 +0x63d k8s.io/kubernetes/vendor/k8s.io/klog/v2.(*loggingT).printDepth(0x0, 0x0, {0x0, 0x0}, {0x0, 0x0}, 0x0, {0xc0005c2e50, 0x1, 0x1}) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/klog/v2/klog.go:735 +0x1ba k8s.io/kubernetes/vendor/k8s.io/klog/v2.FatalDepth(...) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/klog/v2/klog.go:1500 k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/util.fatal({0xc0003d6320, 0x44}, 0xc0001de140) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/util/helpers.go:94 +0x145 k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/util.checkErr({0x204c620, 0xc0001de140}, 0x1eda4b8) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/util/helpers.go:189 +0x84f k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/util.CheckErr(...) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/util/helpers.go:116 k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/logs.NewCmdLogs.func1(0xc00047e280, {0xc00068c6e0, 0x1, 0xa}) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/logs/logs.go:159 +0x125 k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc00047e280, {0xc00068c5a0, 0xa, 0xa}) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:856 +0x5f8 k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc0003e4a00) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:960 +0x3ad k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(...) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:897 main.main() _output/local/go/src/k8s.io/kubernetes/cmd/kubectl/kubectl.go:49 +0x1c9

goroutine 6 [chan receive]: k8s.io/kubernetes/vendor/k8s.io/klog/v2.(*loggingT).flushDaemon(0x0) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/klog/v2/klog.go:1169 +0x6a created by k8s.io/kubernetes/vendor/k8s.io/klog/v2.init.0 /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/klog/v2/klog.go:420 +0xfb

goroutine 15 [select]: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0x0, {0x204c920, 0xc000520000}, 0x1, 0xc0000a8b40) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:167 +0x13b k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil(0x0, 0x12a05f200, 0x0, 0x0, 0x0) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133 +0x89 k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.Until(0x0, 0x0, 0x0) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:90 +0x25 created by k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/util/logs.InitLogs /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/util/logs/logs.go:51 +0xaf

goroutine 23 [IO wait]: internal/poll.runtime_pollWait(0x7fe1ff723dd8, 0x72) /usr/local/go/src/runtime/netpoll.go:234 +0x89 internal/poll.(*pollDesc).wait(0xc0009e3d80, 0xc000e36000, 0x0) /usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x32 internal/poll.(*pollDesc).waitRead(…) /usr/local/go/src/internal/poll/fd_poll_runtime.go:89 internal/poll.(*FD).Read(0xc0009e3d80, {0xc000e36000, 0x446e, 0x446e}) /usr/local/go/src/internal/poll/fd_unix.go:167 +0x25a net.(*netFD).Read(0xc0009e3d80, {0xc000e36000, 0xc000e36049, 0xa8}) /usr/local/go/src/net/fd_posix.go:56 +0x29 net.(*conn).Read(0xc00011a010, {0xc000e36000, 0x612d59, 0xc0006137f0}) /usr/local/go/src/net/net.go:183 +0x45 crypto/tls.(*atLeastReader).Read(0xc0008bcc60, {0xc000e36000, 0x0, 0x409bcd}) /usr/local/go/src/crypto/tls/conn.go:777 +0x3d bytes.(*Buffer).ReadFrom(0xc000555e78, {0x204a780, 0xc0008bcc60}) /usr/local/go/src/bytes/buffer.go:204 +0x98 crypto/tls.(*Conn).readFromUntil(0xc000555c00, {0x204e060, 0xc00011a010}, 0x400) /usr/local/go/src/crypto/tls/conn.go:799 +0xe5 crypto/tls.(*Conn).readRecordOrCCS(0xc000555c00, 0x0) /usr/local/go/src/crypto/tls/conn.go:606 +0x112 crypto/tls.(*Conn).readRecord(…) /usr/local/go/src/crypto/tls/conn.go:574 crypto/tls.(*Conn).Read(0xc000555c00, {0xc000305000, 0x1000, 0x8bce60}) /usr/local/go/src/crypto/tls/conn.go:1277 +0x16f bufio.(*Reader).Read(0xc0003769c0, {0xc0000fe740, 0x9, 0x8cae22}) /usr/local/go/src/bufio/bufio.go:227 +0x1b4 io.ReadAtLeast({0x204a580, 0xc0003769c0}, {0xc0000fe740, 0x9, 0x9}, 0x9) /usr/local/go/src/io/io.go:328 +0x9a io.ReadFull(…) /usr/local/go/src/io/io.go:347 k8s.io/kubernetes/vendor/golang.org/x/net/http2.readFrameHeader({0xc0000fe740, 0x9, 0xc001dac030}, {0x204a580, 0xc0003769c0}) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/golang.org/x/net/http2/frame.go:237 +0x6e k8s.io/kubernetes/vendor/golang.org/x/net/http2.(*Framer).ReadFrame(0xc0000fe700) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/golang.org/x/net/http2/frame.go:498 +0x95 k8s.io/kubernetes/vendor/golang.org/x/net/http2.(*clientConnReadLoop).run(0xc000613f98) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/golang.org/x/net/http2/transport.go:2101 +0x130 k8s.io/kubernetes/vendor/golang.org/x/net/http2.(*ClientConn).readLoop(0xc0003e2600) /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/golang.org/x/net/http2/transport.go:1997 +0x6f created by k8s.io/kubernetes/vendor/golang.org/x/net/http2.(*Transport).newClientConn /data/__qci/root-workspaces/__qci-pipeline-10464151-1/_output/local/go/src/k8s.io/kubernetes/vendor/golang.org/x/net/http2/transport.go:725 +0xac5

In the kubelet logs, we see repeated errors about failing to set the node.status.addresses field.

9月 18 10:47:05 tcs-10-29-20-162 kubelet[8663]: E0918 10:47:05.349410    8663 kubelet_node_status.go:586] "Failed to set some node status fields" err="failed to validate secondaryNodeIP: node IP: \"fc00:0:1:6001::200\" not found in the host's network interfaces" node="10.29.20.162"

What did you expect to happen?

This occurs in the kubelet code here:

https://github.com/kubernetes/kubernetes/blob/a6c7f63b188e96fb73f0e6b3c5b277629be32889/pkg/kubelet/nodestatus/setters.go#L80-L95

The kubelet should not set itself to Ready or schedulable if it cannot properly populate the node status fields like status.addresses

Instead of just logging errors and continuing, the kubelet should return the error when setting node status fields like status.addresses.

https://github.com/kubernetes/kubernetes/blob/d3eb082568cc9353b397c8ca59cbe291670d9ddc/pkg/kubelet/kubelet_node_status.go#L707-L714

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

The kubelet enables dual stack but does not assign an IPv6 address to the interface.

Anything else we need to know?

!37846

Kubernetes version

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.0-alpha.0.3658+7e39abeecdbbc4-dirty", GitCommit:"7e39abeecdbbc4e26c14453b9e8cbac1afb31555", GitTreeState:"dirty", BuildDate:"2023-07-03T08:03:25Z", GoVersion:"go1.17.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.0-alpha.0.3620+197941c68e7775-dirty", GitCommit:"197941c68e77754c7908ab1a6875743097b0bc4a", GitTreeState:"dirty", BuildDate:"2023-05-06T09:43:39Z", GoVersion:"go1.17.10", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

Self Hosted

OS version

# On Linux:
$ cat /etc/os-release
NAME="Tencent Linux"
VERSION="2.4"
ID="tlinux"
ID_LIKE="rhel fedora centos"
VERSION_ID="2.4"
PRETTY_NAME="Tencent Linux 2.4"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:tlinux:linux:2"
HOME_URL="https://tlinux.qq.com/"
$ uname -a
Linux tcs-10-29-20-162 5.4.119-19-0008 #1 SMP Mon Sep 13 14:54:39 CST 2021 x86_64 x86_64 x86_64 GNU/Linux

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

Install tools

shell script

Container runtime (CRI) and version (if applicable)

# nerdctl version Client: Version: v1.2.0 OS/Arch: linux/amd64 Git commit: 5aee2f754a2f46d4c8ccbae25d56b43668ac4b62 buildctl: Version:

Server: containerd: Version: v1.6.9-tke.2-15-g0187b9b61 GitCommit: 0187b9b61fb7719271fcb5ddb212eae8ae4c22ad runc: Version: 1.1.3 GitCommit: v1.1.3-4-g720c880c

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

None

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

However, in my opinion, the ReadyCondition should not be considered as ready.

that is another thing, I put this up for discussion https://github.com/kubernetes/kubernetes/pull/120753