Fixes the ip address to namespace cache when pods reuse addresses
Fixes the ip address to namespace cache when pods reuse addresses

There's a cache that tracks which namespace IP addresses belong to.
However, the cache logic was not considering that Failed or Complete
pods (i.e. not running) could share an IP address with a Running pod.
So the cache code needed to be changed to only add items to the cache
when a pod was Running or Pending.  We also track the pod UID to make
sure that when we delete, we are deleting the entry for the pod that
was running.  So that if a stopped pod is edited, that entry doesn't
end up in the cache.

This is reproducible by setting the networkConfig hostSubnetLength to
3 in the master and node config on your cluster.  Then create two
namespaces, ns1 and ns2, a service in ns2 that has a selector that
matches both pods then create a pod that fails in one (have it run
"sleep 5; false", and set the restartPolicy to Never.  Once it has
failed, create a pod that runs correctly in the other (hello-openshift
is fine).  Then curling the service URL should work.  Remove the
failed pod and the curl will then fail.

The problem is that the cache sees the failed pod removal and removes
the ip from the ip->namespace cache.  But it should not have been
removed because the running pod put the entry in.

For bug:
  https://bugzilla.redhat.com/show_bug.cgi?id=1322942

Also-Authored-By: 8ea548d7adacb6e81ce31e1ecef22dcd9af8f64b@redhat.com

marun/origin,abutcher/origin,jeffvance/origin,jprukner/origin,hferentschik/origin,openshift/openshift-sdn,tnozicka/origin,knobunc/origin,imcsk8/origin,jpeeler/origin,coreydaley/origin,jpeeler/origin,knobunc/origin,sg00dwin/origin,bparees/origin,simo5/origin,tagoh/origin,ramr/origin,deads2k/origin,pravisankar/origin,soltysh/origin,liangxia/origin,detiber/origin,PI-Victor/origin,hferentschik/origin,akram/origin,sferich888/origin,csrwng/origin,tracyrankin/origin,rhuss/origin,sjug/origin,markllama/origin,jprukner/origin,mfojtik/origin,luciddreamz/origin,sdminonne/origin,tagoh/origin,simo5/origin,imcsk8/origin,bparees/origin,tdawson/origin,maxamillion/origin,wanghaoran1988/origin,liangxia/origin,pravisankar/origin,openshift/origin,bparees/origin,rootfs/origin,dgoodwin/origin,arilivigni/origin,dobbymoodge/origin,eparis/origin,danmcp/origin,ryanj/origin,pravisankar/origin,maleck13/origin,adelton/origin,juanvallejo/origin,hroyrh/origin,rajatchopra/origin,smarterclayton/origin,sallyom/origin,mdshuai/origin,luciddreamz/origin,pmorie/origin,ncdc/origin,rhamilto/origin,nhr/origin,sspeiche/origin,mfojtik/origin,pecameron/origin,tiwillia/origin,tagoh/origin,aveshagarwal/origin,pmorie/origin,tnozicka/origin,tracyrankin/origin,tnozicka/origin,inlandsee/origin,linzhaoming/origin,eparis/origin,anpingli/origin,luciddreamz/origin,JacobTanenbaum/origin,dcbw/origin,stevekuznetsov/origin,hroyrh/origin,danmcp/origin,goern/origin,ncdc/origin,chmouel/origin,elyscape/origin,linearregression/origin,chmouel/origin,linzhaoming/origin,aveshagarwal/origin,liangxia/origin,tagoh/origin,jim-minter/origin,goern/origin,adelton/origin,abutcher/origin,rhamilto/origin,tnozicka/origin,soltysh/origin,louyihua/origin,tracyrankin/origin,markllama/origin,PI-Victor/origin,danwinship/origin,jeremyeder/origin,PI-Victor/origin,tdawson/origin,danwinship/openshift-sdn,robertol/origin,mrogers950/origin,jeremyeder/origin,childsb/origin,jim-minter/origin,zhaosijun/origin,gashcrumb/origin,ryanj/origin,ryanj/origin,csrwng/origin,sg00dwin/origin,deads2k/origin,mrogers950/origin,ingvagabund/origin,detiber/origin,tagoh/origin,jpeeler/origin,wjiangjay/origin,sg00dwin/origin,maxamillion/origin,PI-Victor/origin,kargakis/origin,smarterclayton/origin,ravisantoshgudimetla/origin,jeremyeder/origin,wanghaoran1988/origin,knobunc/origin,matthyx/origin,wjiangjay/origin,jwhonce/origin,liggitt/openshift-sdn,linzhaoming/origin,PI-Victor/origin,legionus/origin,maxamillion/origin,sallyom/origin,sg00dwin/origin,knobunc/origin,jprukner/origin,mahak/origin,zhaosijun/origin,luciddreamz/origin,eparis/origin,mdshuai/origin,louyihua/origin,simo5/origin,ramr/origin,nhr/origin,linearregression/origin,markllama/origin,childsb/origin,tagoh/origin,danmcp/origin,robertol/origin,jwhonce/origin,php-coder/origin,pravisankar/origin,kargakis/origin,kargakis/origin,maxamillion/origin,ironcladlou/origin,juanvallejo/origin,dcbw/origin,mdshuai/origin,willmtemple/origin,rhuss/origin,jim-minter/origin,mdshuai/origin,childsb/origin,raffaelespazzoli/origin,jupierce/origin,elyscape/origin,juanvallejo/origin,miminar/origin,kargakis/origin,dobbymoodge/origin,dcbw/origin,jprukner/origin,danwinship/origin,wanghaoran1988/origin,danwinship/origin,ramr/origin,adelton/origin,openshift/openshift-sdn,simo5/origin,mrogers950/origin,louyihua/origin,deads2k/origin,liggitt/origin,jwhonce/origin,mdshuai/origin,willmtemple/origin,jpeeler/origin,JacobTanenbaum/origin,liggitt/origin,danmcp/origin,php-coder/origin,ryanj/origin,dgoodwin/origin,ravisantoshgudimetla/origin,louyihua/origin,php-coder/origin,goern/origin,PI-Victor/origin,gabemontero/origin,mdshuai/openshift-sdn,Miciah/origin,sdminonne/origin,gabemontero/origin,tdawson/origin,kargakis/origin,jwhonce/origin,legionus/origin,coreydaley/origin,rajatchopra/origin,miminar/origin,php-coder/origin,jeffvance/origin,ingvagabund/origin,markllama/origin,dcbw/origin,stevekuznetsov/origin,luciddreamz/origin,dobbymoodge/origin,sjug/origin,childsb/origin,wjiangjay/origin,xiuwang/origin,php-coder/origin,juanvallejo/origin,nak3/openshift-sdn,sferich888/origin,rrati/origin,dmage/origin,rrati/origin,liangxia/origin,mkumatag/origin,mdshuai/origin,maxamillion/origin,nak3/origin,juanvallejo/origin,jwhonce/origin,kargakis/origin,hferentschik/origin,sdminonne/origin,jupierce/origin,raffaelespazzoli/origin,willmtemple/origin,luciddreamz/origin,maleck13/origin,wjiangjay/origin,xiuwang/origin,robertol/origin,liggitt/origin,elyscape/origin,linzhaoming/origin,willmtemple/origin,ironcladlou/origin,rrati/origin,matthyx/origin,sspeiche/origin,ravisantoshgudimetla/origin,inlandsee/origin,aveshagarwal/origin,rootfs/origin,pweil-/origin,coreydaley/origin,mrogers950/origin,miminar/origin,miminar/origin,jprukner/origin,rootfs/origin,dmage/origin,sspeiche/origin,spadgett/origin,ryanj/origin,dmage/origin,enj/origin,enj/origin,mahak/origin,chmouel/origin,smarterclayton/origin,robertol/origin,hferentschik/origin,childsb/origin,nak3/origin,childsb/origin,gashcrumb/origin,tnozicka/origin,dinhxuanvu/origin,rajatchopra/origin,chmouel/origin,imcsk8/origin,dinhxuanvu/origin,dinhxuanvu/origin,gashcrumb/origin,jpeeler/origin,gashcrumb/origin,detiber/origin,pravisankar/origin,liggitt/origin,openshift/origin,inlandsee/origin,rhcarvalho/origin,ryanj/origin,mdshuai/openshift-sdn,imcsk8/origin,liangxia/origin,danwinship/openshift-sdn,mrogers950/origin,dgoodwin/origin,rhcarvalho/origin,aveshagarwal/origin,mkumatag/origin,pweil-/origin,rhcarvalho/origin,tiwillia/origin,jupierce/origin,mfojtik/origin,detiber/origin,tnozicka/origin,detiber/origin,csrwng/origin,rajatchopra/origin,jsafrane/origin,matthyx/origin,rrati/origin,rajatchopra/origin,marun/origin,jupierce/origin,gabemontero/origin,dobbymoodge/origin,mrogers950/origin,wjiangjay/origin,arilivigni/origin,ravisantoshgudimetla/origin,JacobTanenbaum/origin,akram/origin,wjiangjay/origin,jeremyeder/origin,arilivigni/origin,adelton/origin,rhuss/origin,miminar/origin,imcsk8/origin,danwinship/origin,marun/origin,marun/origin,nak3/openshift-sdn,nhr/origin,spadgett/origin,tiwillia/origin,goern/origin,thrasher-redhat/origin,sspeiche/origin,stevekuznetsov/origin,anpingli/origin,spadgett/origin,dgoodwin/origin,jsafrane/origin,thrasher-redhat/origin,rhuss/origin,smarterclayton/origin,xiuwang/origin,sjug/origin,spadgett/origin,rhuss/origin,danwinship/origin,zhaosijun/origin,tracyrankin/origin,pmorie/origin,jprukner/origin,rhcarvalho/origin,thrasher-redhat/origin,soltysh/origin,jeremyeder/origin,rrati/origin,imcsk8/origin,pmorie/origin,dgoodwin/origin,nak3/origin,liggitt/openshift-sdn,pmorie/origin,simo5/origin,elyscape/origin,nhr/origin,raffaelespazzoli/origin,legionus/origin,maleck13/origin,pweil-/origin,rajatchopra/origin,aveshagarwal/origin,arilivigni/origin,sallyom/origin,chlunde/origin,robertol/origin,spadgett/origin,danwinship/origin,hferentschik/origin,rootfs/origin,liggitt/origin,rhuss/origin,dmage/origin,louyihua/origin,ramr/origin,php-coder/origin,dobbymoodge/origin,matthyx/origin,rhamilto/origin,rhcarvalho/origin,markllama/origin,raffaelespazzoli/origin,abutcher/origin,dobbymoodge/origin,linzhaoming/origin,anpingli/origin,ncdc/origin,jsafrane/origin,dinhxuanvu/origin,wanghaoran1988/origin,ramr/origin,zhaosijun/origin,linearregression/origin,chlunde/origin,tdawson/origin,openshift/origin,chlunde/origin,hroyrh/origin,Miciah/origin,akram/origin,dcbw/origin,linearregression/origin,tiwillia/origin,Miciah/origin,jeffvance/origin,eparis/origin,abutcher/origin,enj/origin,smarterclayton/origin,dinhxuanvu/origin,mkumatag/origin,nhr/origin,elyscape/origin,adelton/origin,abutcher/origin,sferich888/origin,jeffvance/origin,inlandsee/origin,juanvallejo/origin,hferentschik/origin,mahak/origin,ravisantoshgudimetla/origin,thrasher-redhat/origin,ironcladlou/origin,wanghaoran1988/origin,matthyx/origin,miminar/origin,markllama/origin,rootfs/origin,legionus/origin,maleck13/origin,rhamilto/origin,liggitt/origin,ncdc/origin,ingvagabund/origin,liangxia/origin,chlunde/origin,jupierce/origin,legionus/origin,pecameron/origin,pecameron/origin,rhamilto/origin,stevekuznetsov/origin,robertol/origin,jwhonce/origin