Only pods in running phase are vallid for status (#2093)
This commit is contained in:
parent
1f79333789
commit
9bb9011e57
3 changed files with 37 additions and 0 deletions
|
@ -1,5 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright 2018 The Kubernetes Authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
echo "Generating self-signed cert"
|
echo "Generating self-signed cert"
|
||||||
mkdir -p /certs
|
mkdir -p /certs
|
||||||
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 \
|
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 \
|
||||||
|
|
|
@ -260,6 +260,11 @@ func (s *statusSync) runningAddresses() ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pod := range pods.Items {
|
for _, pod := range pods.Items {
|
||||||
|
// only Running pods are valid
|
||||||
|
if pod.Status.Phase != apiv1.PodRunning {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
name := k8s.GetNodeIPOrName(s.Client, pod.Spec.NodeName, s.UseNodeInternalIP)
|
name := k8s.GetNodeIPOrName(s.Client, pod.Spec.NodeName, s.UseNodeInternalIP)
|
||||||
if !sliceutils.StringInSlice(name, addrs) {
|
if !sliceutils.StringInSlice(name, addrs) {
|
||||||
addrs = append(addrs, name)
|
addrs = append(addrs, name)
|
||||||
|
|
|
@ -66,6 +66,21 @@ func buildSimpleClientSet() *testclient.Clientset {
|
||||||
Spec: apiv1.PodSpec{
|
Spec: apiv1.PodSpec{
|
||||||
NodeName: "foo_node_2",
|
NodeName: "foo_node_2",
|
||||||
},
|
},
|
||||||
|
Status: apiv1.PodStatus{
|
||||||
|
Phase: apiv1.PodRunning,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "foo1-unknown",
|
||||||
|
Namespace: apiv1.NamespaceDefault,
|
||||||
|
},
|
||||||
|
Spec: apiv1.PodSpec{
|
||||||
|
NodeName: "foo_node_1",
|
||||||
|
},
|
||||||
|
Status: apiv1.PodStatus{
|
||||||
|
Phase: apiv1.PodUnknown,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
@ -87,6 +102,9 @@ func buildSimpleClientSet() *testclient.Clientset {
|
||||||
Spec: apiv1.PodSpec{
|
Spec: apiv1.PodSpec{
|
||||||
NodeName: "foo_node_2",
|
NodeName: "foo_node_2",
|
||||||
},
|
},
|
||||||
|
Status: apiv1.PodStatus{
|
||||||
|
Phase: apiv1.PodRunning,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
&apiv1.ServiceList{Items: []apiv1.Service{
|
&apiv1.ServiceList{Items: []apiv1.Service{
|
||||||
|
|
Loading…
Reference in a new issue