aks-engine icon indicating copy to clipboard operation
aks-engine copied to clipboard

K8s Windows 1803 pod creation fails with "HNS failed with error : Element not found"

Open brobichaud opened this issue 8 years ago • 39 comments

Is this a request for help?: Yes

Is this an ISSUE or FEATURE REQUEST? (choose one): Issue

What version of acs-engine?: 22.1

Orchestrator and version (e.g. Kubernetes, DC/OS, Swarm) Kubernetes

What happened: I have a cluster w/ k8s 10.8.1 running Windows v1803 nodes. All was well for 6 days with a dozen of my pods deployed, then suddenly I start seeing the error below when deploying new versions of a pod:

Failed create pod sandbox: rpc error: code = Unknown desc = NetworkPlugin cni failed to set up pod "dev-fossil-api-777f779f74-fhx88_default" network: Failed to create endpoint: HNS failed with error : Element not found.

I noticed these errors are only seen when k8s tries to schedule new pods on a specific node. I have 2 Windows nodes, one is fine the other exhibits this problem.

Since this seems network related I looked at the ipconfig /all results on each node and do not see a pattern. Here is the output in case it's useful.

First node exhibiting the problem:

Windows IP Configuration
   Host Name . . . . . . . . . . . . : 13832k8s9000
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : i2fxeuipe3wuzilxz3jq1ieqbb.cx.internal.cloudapp.net

Ethernet adapter vEthernet (Ethernet 2):
   Connection-specific DNS Suffix  . : i2fxeuipe3wuzilxz3jq1ieqbb.cx.internal.cloudapp.net
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   Physical Address. . . . . . . . . : 00-0D-3A-03-52-90
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::5542:5b81:1f86:875c%6(Preferred)
   IPv4 Address. . . . . . . . . . . : 10.240.0.34(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.240.0.0
   Lease Obtained. . . . . . . . . . : Tuesday, October 16, 2018 1:37:01 AM
   Lease Expires . . . . . . . . . . : Friday, November 22, 2154 8:29:19 AM
   Default Gateway . . . . . . . . . : 10.240.0.1
   DHCP Server . . . . . . . . . . . : 168.63.129.16
   DHCPv6 IAID . . . . . . . . . . . : 218107194
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-23-38-4F-57-00-15-5D-1C-3A-59
   DNS Servers . . . . . . . . . . . : 168.63.129.16
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter vEthernet (nat):
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
   Physical Address. . . . . . . . . : 00-15-5D-3D-2D-76
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::8d3:f1d2:1e7:4805%10(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.22.176.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 201332061
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-23-38-4F-57-00-15-5D-1C-3A-59
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Node that is working fine:

Windows IP Configuration
   Host Name . . . . . . . . . . . . : 13832k8s9001
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : i2fxeuipe3wuzilxz3jq1ieqbb.cx.internal.cloudapp.net

Ethernet adapter vEthernet (Ethernet 2):
   Connection-specific DNS Suffix  . : i2fxeuipe3wuzilxz3jq1ieqbb.cx.internal.cloudapp.net
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   Physical Address. . . . . . . . . : 00-0D-3A-03-5A-E5
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::c71:f557:2367:787%8(Preferred)
   IPv4 Address. . . . . . . . . . . : 10.240.0.65(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.240.0.0
   Lease Obtained. . . . . . . . . . : Monday, October 15, 2018 9:14:07 PM
   Lease Expires . . . . . . . . . . : Friday, November 22, 2154 11:38:39 PM
   Default Gateway . . . . . . . . . : 10.240.0.1
   DHCP Server . . . . . . . . . . . : 168.63.129.16
   DHCPv6 IAID . . . . . . . . . . . : 218107194
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-23-38-4F-61-00-15-5D-1C-3A-59
   DNS Servers . . . . . . . . . . . : 168.63.129.16
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter vEthernet (nat):
   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
   Physical Address. . . . . . . . . : 00-15-5D-3D-2D-76
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter vEthernet (nat) 2:
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #3
   Physical Address. . . . . . . . . : 00-15-5D-0D-0F-74
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::934:49c5:45af:a7%7(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.29.96.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 318772573
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-23-38-4F-61-00-15-5D-1C-3A-59
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

Second node exhibiting the problem:

Windows IP Configuration
   Host Name . . . . . . . . . . . . : 13832k8s9002
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : i2fxeuipe3wuzilxz3jq1ieqbb.cx.internal.cloudapp.net

Ethernet adapter vEthernet (Ethernet 2):
   Connection-specific DNS Suffix  . : i2fxeuipe3wuzilxz3jq1ieqbb.cx.internal.cloudapp.net
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #9
   Physical Address. . . . . . . . . : 00-0D-3A-04-8A-BB
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::3cf5:3c5c:b63e:d6c4%11(Preferred)
   IPv4 Address. . . . . . . . . . . : 10.240.0.96(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.240.0.0
   Lease Obtained. . . . . . . . . . : Monday, October 15, 2018 9:19:12 PM
   Lease Expires . . . . . . . . . . : Friday, November 22, 2154 3:59:03 AM
   Default Gateway . . . . . . . . . : 10.240.0.1
   DHCP Server . . . . . . . . . . . : 168.63.129.16
   DHCPv6 IAID . . . . . . . . . . . : 150998330
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-23-51-17-95-00-15-5D-1C-3A-59
   DNS Servers . . . . . . . . . . . : 168.63.129.16
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter vEthernet (nat):
   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter
   Physical Address. . . . . . . . . : 00-15-5D-3D-2D-76
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter vEthernet (nat) 2:
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   Physical Address. . . . . . . . . : 00-15-5D-20-BF-B7
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::57a:4521:f014:b58c%8(Preferred)
   IPv4 Address. . . . . . . . . . . : 172.17.224.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 268440925
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-23-51-17-95-00-15-5D-1C-3A-59
   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   NetBIOS over Tcpip. . . . . . . . : Enabled

What you expected to happen: For the pods to be created on any Windows node in the cluster.

How to reproduce it (as minimally and precisely as possible): I have a cluster that exhibits this now and can easily repro it. But I do not have steps to repro it on a new cluster, it feels random-ish.

Anything else we need to know: Since I have no idea what causes this or how to fix it my only recourse was to taint the affected node so k8s stops trying to schedule to it. I then scaled my cluster up to get a new node on which I can deploy, and stopped the affected node. Since then the new node worked fine for a few days and then exhibited the same problem. I now have two tainted nodes turned off.

I'm very willing to work with someone that can help me debug this.

brobichaud avatar Oct 16 '18 17:10 brobichaud

@jhowardmsft @madhanrm @dineshgovindasamy Guys, could it be related to HNS along with docker 1.13 as well?

sharmasushant avatar Oct 16 '18 17:10 sharmasushant

Please collect the logs using https://github.com/Microsoft/SDN/blob/master/Kubernetes/windows/debug/collectlogs.ps1 Also provide c:\k\azure-vnet.log

I suspect this to be the out of sync issue - ie Azure CNI going out of sync with HNS.

madhanrm avatar Oct 16 '18 17:10 madhanrm

OK, ran the diagnostics and gathered azure-vnet.log on one of the affected nodes. They are attached. diags.zip azure-vnet.log

brobichaud avatar Oct 16 '18 18:10 brobichaud

BTW, on the sig-windows slack channel someone else has seen the same problem. He said the following:

What I found was that I have two network adapters and that the CNI was trying to attach to the non l2 network adapter. I just reset the HNS network and it started working correctly.

I haven't tried that as I don't know how to reset the HNS network.

brobichaud avatar Oct 16 '18 18:10 brobichaud

@sharmasushant can you add code in Azure CNI, to check if the network exists, before creating an endpoint. If not, can you re-create the network.

On host restart or Kubelet restart kubeletstart.ps1 would attempt to cleanup the HNS Network and remove the json files. If the json files stick around, then azure cni might think that the network is available, and might try creating an endpoint using it, and ending up with this issue.

madhanrm avatar Oct 16 '18 19:10 madhanrm

I don't see the error described in this issue in azure-vnet.log

From the diag logs. The network named azure is missing & hence endpoint creation fails. The azure-vnet.json would confirm, if you see an entry for network.

Name Type ID AddressPrefix


ext L2Bridge 24a89481-38bb-4bf2-b6c0-52fdd0019708
nat nat c5419986-8ac2-48bf-b86c-1d7c47059705

madhanrm avatar Oct 16 '18 19:10 madhanrm

@madhanrm Is this what happened here? Or is this comment about general goodness?

@saiyan86 can you please take up this change? Lets check for network existence while creating an endpoint.

@madhanrm please understand that this adds overhead to endpoint creation, and we would like to avoid this. Should we track the issue where you cleanup HNS but not able to remove the state as a bug?

sharmasushant avatar Oct 16 '18 19:10 sharmasushant

If needed I can repro the problem on this node by removing the taint.

Separately, is there a way I can manually fix this problem so I can repair my cluster?

brobichaud avatar Oct 16 '18 19:10 brobichaud

Try to stop Kubelet service, see if any azure-vnet.json file exist, if yes, delete them, and then start the Kubelet service

madhanrm avatar Oct 16 '18 19:10 madhanrm

@sharmasushant Going forward with RS5 & using the v2 HNS RPC apis, it is mandatory to Open the network (to make sure it exists) & Create endpoint on that network.

Just making sure the network exists is not going to cost much for v1 apis

madhanrm avatar Oct 16 '18 19:10 madhanrm

@madhanrm what's the correct way to stop the kubelet? using "sc stop kubelet" results in the error:

[SC] ControlService FAILED 1051: A stop control has been sent to a service that other running services are dependent on.

brobichaud avatar Oct 16 '18 19:10 brobichaud

Stop-Service Kubelet -Force

<del azure-vnet.json file, if exist>

Start-Service kubelet

madhanrm avatar Oct 16 '18 19:10 madhanrm

OK, that let me stop and start the kubelet. But after doing that I am now seeing this error when I try to schedule a pod:

Failed create pod sandbox: rpc error: code = Unknown desc = NetworkPlugin cni failed to set up pod "dev-madras-resolver-677d758ddb-87qvw_default" network: Failed to allocate pool: Failed to delegate: Failed to allocate pool: No available address pools

Also, I do not see a new azure-vnet.json being created in c:\k. But I do see an azure-vnet.json.lock. Here is azure-vnet.log: azure-vnet.log

brobichaud avatar Oct 16 '18 19:10 brobichaud

Can you try deleting below 2 files, while stopping kubelet

<del azure-vnet.json file, if exist> <del azure-vnet-ipam.json file, if exist>

madhanrm avatar Oct 16 '18 20:10 madhanrm

Please delete the lock files as well.

madhanrm avatar Oct 16 '18 20:10 madhanrm

Ahhh, that did the trick nicely. Thank you so much for saving my cluster. :-)

Is there anything I have done to trigger this? I'm wondering why others have not seen it.

And more importantly, is there anything I can do to avoid this? I know how to fix it now, but it's surely a pain.

brobichaud avatar Oct 16 '18 21:10 brobichaud

@madhanrm you are a life saver!!!

tonyschollum avatar Oct 17 '18 08:10 tonyschollum

My Windows node crashed again just now, after I created a new pod. All pods on that node became error. After the advice above, seems kubelet hang. PS C:\k> type kubelet.log NetworkPlugin azure, starting kubelet. Ok. c1666c807871 Cleaning up old HNS network found PS C:\k>

Some logs here. https://github.com/zhiweiv/apcs/blob/master/azure-vnet-ipam.log https://github.com/zhiweiv/apcs/blob/master/azure-vnet.log https://github.com/zhiweiv/apcs/blob/master/kubelet.log https://github.com/zhiweiv/apcs/blob/master/dir.txt

I am using acs engine 0.23.1, k8s 1.12.1

zhiweiv avatar Oct 17 '18 12:10 zhiweiv

@zhiweiv can you also provide the kubelet.err.log ?

madhanrm avatar Oct 17 '18 17:10 madhanrm

Hi @madhanrm

I am unable to connect to the problematic Windows node after reboot, seems same issue with #4001 I decide to keep watching other Windows nodes, if issue occur again, I will paste new information here.

Thanks

zhiweiv avatar Oct 18 '18 04:10 zhiweiv