Create hostNetwork pods even if network plugin not ready
This commit is contained in:
parent
714f816a34
commit
ad6d842a65
@ -1505,6 +1505,12 @@ func (kl *Kubelet) rejectPod(pod *api.Pod, reason, message string) {
|
|||||||
// can be admitted, a brief single-word reason and a message explaining why
|
// can be admitted, a brief single-word reason and a message explaining why
|
||||||
// the pod cannot be admitted.
|
// the pod cannot be admitted.
|
||||||
func (kl *Kubelet) canAdmitPod(pods []*api.Pod, pod *api.Pod) (bool, string, string) {
|
func (kl *Kubelet) canAdmitPod(pods []*api.Pod, pod *api.Pod) (bool, string, string) {
|
||||||
|
if rs := kl.runtimeState.networkErrors(); len(rs) != 0 {
|
||||||
|
if !podUsesHostNetwork(pod) {
|
||||||
|
return false, "NetworkNotReady", fmt.Sprintf("Network is not ready: %v", rs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// the kubelet will invoke each pod admit handler in sequence
|
// the kubelet will invoke each pod admit handler in sequence
|
||||||
// if any handler rejects, the pod is rejected.
|
// if any handler rejects, the pod is rejected.
|
||||||
// TODO: move out of disk check into a pod admitter
|
// TODO: move out of disk check into a pod admitter
|
||||||
@ -1541,7 +1547,7 @@ func (kl *Kubelet) syncLoop(updates <-chan kubetypes.PodUpdate, handler SyncHand
|
|||||||
defer housekeepingTicker.Stop()
|
defer housekeepingTicker.Stop()
|
||||||
plegCh := kl.pleg.Watch()
|
plegCh := kl.pleg.Watch()
|
||||||
for {
|
for {
|
||||||
if rs := kl.runtimeState.errors(); len(rs) != 0 {
|
if rs := kl.runtimeState.runtimeErrors(); len(rs) != 0 {
|
||||||
glog.Infof("skipping pod synchronization - %v", rs)
|
glog.Infof("skipping pod synchronization - %v", rs)
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
continue
|
continue
|
||||||
|
@ -552,7 +552,8 @@ func (kl *Kubelet) setNodeReadyCondition(node *api.Node) {
|
|||||||
// ref: https://github.com/kubernetes/kubernetes/issues/16961
|
// ref: https://github.com/kubernetes/kubernetes/issues/16961
|
||||||
currentTime := unversioned.NewTime(kl.clock.Now())
|
currentTime := unversioned.NewTime(kl.clock.Now())
|
||||||
var newNodeReadyCondition api.NodeCondition
|
var newNodeReadyCondition api.NodeCondition
|
||||||
if rs := kl.runtimeState.errors(); len(rs) == 0 {
|
rs := append(kl.runtimeState.runtimeErrors(), kl.runtimeState.networkErrors()...)
|
||||||
|
if len(rs) == 0 {
|
||||||
newNodeReadyCondition = api.NodeCondition{
|
newNodeReadyCondition = api.NodeCondition{
|
||||||
Type: api.NodeReady,
|
Type: api.NodeReady,
|
||||||
Status: api.ConditionTrue,
|
Status: api.ConditionTrue,
|
||||||
|
@ -83,6 +83,7 @@ func TestRunOnce(t *testing.T) {
|
|||||||
kubeClient: &fake.Clientset{},
|
kubeClient: &fake.Clientset{},
|
||||||
hostname: testKubeletHostname,
|
hostname: testKubeletHostname,
|
||||||
nodeName: testKubeletHostname,
|
nodeName: testKubeletHostname,
|
||||||
|
runtimeState: newRuntimeState(time.Second),
|
||||||
}
|
}
|
||||||
kb.containerManager = cm.NewStubContainerManager()
|
kb.containerManager = cm.NewStubContainerManager()
|
||||||
|
|
||||||
|
@ -68,16 +68,13 @@ func (s *runtimeState) setInitError(err error) {
|
|||||||
s.initError = err
|
s.initError = err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *runtimeState) errors() []string {
|
func (s *runtimeState) runtimeErrors() []string {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
defer s.RUnlock()
|
defer s.RUnlock()
|
||||||
var ret []string
|
var ret []string
|
||||||
if s.initError != nil {
|
if s.initError != nil {
|
||||||
ret = append(ret, s.initError.Error())
|
ret = append(ret, s.initError.Error())
|
||||||
}
|
}
|
||||||
if s.networkError != nil {
|
|
||||||
ret = append(ret, s.networkError.Error())
|
|
||||||
}
|
|
||||||
if !s.lastBaseRuntimeSync.Add(s.baseRuntimeSyncThreshold).After(time.Now()) {
|
if !s.lastBaseRuntimeSync.Add(s.baseRuntimeSyncThreshold).After(time.Now()) {
|
||||||
ret = append(ret, "container runtime is down")
|
ret = append(ret, "container runtime is down")
|
||||||
}
|
}
|
||||||
@ -87,6 +84,16 @@ func (s *runtimeState) errors() []string {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *runtimeState) networkErrors() []string {
|
||||||
|
s.RLock()
|
||||||
|
defer s.RUnlock()
|
||||||
|
var ret []string
|
||||||
|
if s.networkError != nil {
|
||||||
|
ret = append(ret, s.networkError.Error())
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
func newRuntimeState(
|
func newRuntimeState(
|
||||||
runtimeSyncThreshold time.Duration,
|
runtimeSyncThreshold time.Duration,
|
||||||
) *runtimeState {
|
) *runtimeState {
|
||||||
|
Loading…
Reference in New Issue
Block a user