Change:
} } <ins> func TestMakeMountsEtcHostsFile(t *testing.T) { testPod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Namespace:   "test-ns", Name:        "test-pod-name", Annotations: map[string]string{}, }, Spec: v1.PodSpec{ EnableServiceLinks: ptr.To(false), // to avoid errors with kl.makeEnvironmentVariables }, } testContainer := v1.Container{ Name:  "test-container", Image: "img", } tests := []struct { name        string podFn       func(pod *v1.Pod) containerFn func(container *v1.Container) podVolumes  kubecontainer.VolumeMap podIPs      []string want        bool // check if mounts the /etc/host file wantErr     bool }{ { name:   "pod with network", podIPs: []string{"192.168.0.1"}, want:   true, }, { name: "pod with network but no IPs", want: false, }, { name: "pod with host network", podFn: func(pod *v1.Pod) { pod.Spec.HostNetwork = true }, podIPs: []string{"192.168.0.1"}, want:   true, }, { name: "pod with host network but no IPs", podFn: func(pod *v1.Pod) { pod.Spec.HostNetwork = true }, want: true, }, { name: "pod with network already mounting the hosts file", containerFn: func(container *v1.Container) { container.VolumeMounts = []v1.VolumeMount{ { Name:      "etchosts", MountPath: etcHostsPath, }, } }, podVolumes: kubecontainer.VolumeMap{ "etchosts": kubecontainer.VolumeInfo{Mounter: &stubVolume{path: "/mnt/disk"}}, }, podIPs: []string{"192.168.0.1"}, want:   false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { fhu := hostutil.NewFakeHostUtil(nil) fsp := &subpath.FakeSubpath{} pod := testPod.DeepCopy() if tt.podFn != nil { tt.podFn(pod) } container := testContainer.DeepCopy() if tt.containerFn != nil { tt.containerFn(container) } mounts, _, err := makeMounts(pod, t.TempDir(), container, "fakepodname", "fakedomain", tt.podIPs, tt.podVolumes, fhu, fsp, nil, false, nil) if err != nil { t.Fatalf("unexpected error: %v", err) } got := false for _, mount := range mounts { if mount.Name == "k8s-managed-etc-hosts" { got = true break } } if got != tt.want { t.Errorf("/etc/hosts file mounted: got = %v, want %v", got, tt.want) } }) } } </ins> func TestMakeBlockVolumes(t *testing.T) { testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) defer testKubelet.Cleanup()

Discussion:
When the node network is not yet connected, start kubelet and create static pod like this The created container file does not contain the configuration of hostAliases. The created container file should contain the configuration of hostAliases. kubelet service. static pod with configuration of hostAliases. network, like . kubelet service. created container file does not contain the configuration of hostAliases. No response <details</details<details</details<details</details<detailskubeadm </details<detailscontainerd 1.6.4 </details<details</details
/sig node
23 is EOL please check if this is happening in a supported release, latest supported is 1.25
You might want to set up a dependency on network from kubelet (assuming you're using systemd), so that it doesn't start until network is ready. Also, could you reproduce this on a later version (eg. 1.27)? /triage needs-information
The kubelet systemd configuration file already declares a network-online target dependency, but it doesn't seem to work. Looks like additional dependencies are required such as NetworkManager-wait-online.service. I think the best way is that kubelet is compatible with this scenario. Also, I also tested on 1.27 and the problem is still reproducible.
Is there any progress in dealing with this issue?
I haven't been working on this, not sure if anyone is actively looking into it.
did you try adding this dependency? Did it work?
NetworkManager-wait-online.service only waits for 60s. If the network is still abnormal after 60s, the problem will still occur.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules: After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closed You can: Mark this issue as fresh with Close this issue with Offer to help out with [Issue Triage][1] Please send feedback to sig-contributor-experience at . /lifecycle stale [1]:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules: After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closed You can: Mark this issue as fresh with Close this issue with Offer to help out with [Issue Triage][1] Please send feedback to sig-contributor-experience at . /lifecycle rotten [1]:
/remove-lifecycle rotten
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules: After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closed You can: Mark this issue as fresh with Close this issue with Offer to help out with [Issue Triage][1] Please send feedback to sig-contributor-experience at . /lifecycle stale [1]:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules: After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closed You can: Mark this issue as fresh with Close this issue with Offer to help out with [Issue Triage][1] Please send feedback to sig-contributor-experience at . /lifecycle rotten [1]:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues according to the following rules: After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closed You can: Reopen this issue with Mark this issue as fresh with Offer to help out with [Issue Triage][1] Please send feedback to sig-contributor-experience at . /close not-planned [1]:
Closing this issue, marking it as "Not Planned". <detailsIn response to : The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

After 90d of inactivity, is applied After 30d of inactivity since was applied, is applied After 30d of inactivity since was applied, the issue is closedReopen this issue with Mark this issue as fresh with Offer to help out with [Issue Triage][1] Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/reopen /remove-lifecycle rotten
Reopened this issue. <detailsIn response to : /reopen /remove-lifecycle rotten Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/sig network The kubelet wait for the PodIPs to be present to mount the etc hosts files however, it does not check if the pod is host network. If the Pod is using hostNetwork, then it seems the PodIPs are ignored so it seems legit to mount the aliases independently of PodIPs if the pod is using host network /assign /sig network /triage accepted
/remove-sig node