mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
kubelet/cni: hook network plugin Status() up to CNI network discovery
Ensure that the plugin returns NotReady status until there is a CNI network available which can be used to set up pods. Fixes: https://github.com/kubernetes/kubernetes/issues/43014
This commit is contained in:
parent
948e3754f8
commit
193abffdbe
@ -20,7 +20,6 @@ go_library(
|
|||||||
"//vendor:github.com/containernetworking/cni/libcni",
|
"//vendor:github.com/containernetworking/cni/libcni",
|
||||||
"//vendor:github.com/containernetworking/cni/pkg/types",
|
"//vendor:github.com/containernetworking/cni/pkg/types",
|
||||||
"//vendor:github.com/golang/glog",
|
"//vendor:github.com/golang/glog",
|
||||||
"//vendor:k8s.io/apimachinery/pkg/util/wait",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,12 +21,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/containernetworking/cni/libcni"
|
"github.com/containernetworking/cni/libcni"
|
||||||
cnitypes "github.com/containernetworking/cni/pkg/types"
|
cnitypes "github.com/containernetworking/cni/pkg/types"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/componentconfig"
|
"k8s.io/kubernetes/pkg/apis/componentconfig"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/network"
|
"k8s.io/kubernetes/pkg/kubelet/network"
|
||||||
@ -147,13 +145,9 @@ func (plugin *cniNetworkPlugin) Init(host network.Host, hairpinMode componentcon
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.host = host
|
plugin.host = host
|
||||||
|
|
||||||
// sync network config from pluginDir periodically to detect network config updates
|
plugin.syncNetworkConfig()
|
||||||
go wait.Forever(func() {
|
|
||||||
plugin.syncNetworkConfig()
|
|
||||||
}, 10*time.Second)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +183,14 @@ func (plugin *cniNetworkPlugin) Name() string {
|
|||||||
return CNIPluginName
|
return CNIPluginName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (plugin *cniNetworkPlugin) Status() error {
|
||||||
|
// sync network config from pluginDir periodically to detect network config updates
|
||||||
|
plugin.syncNetworkConfig()
|
||||||
|
|
||||||
|
// Can't set up pods if we don't have any CNI network configs yet
|
||||||
|
return plugin.checkInitialized()
|
||||||
|
}
|
||||||
|
|
||||||
func (plugin *cniNetworkPlugin) SetUpPod(namespace string, name string, id kubecontainer.ContainerID, annotations map[string]string) error {
|
func (plugin *cniNetworkPlugin) SetUpPod(namespace string, name string, id kubecontainer.ContainerID, annotations map[string]string) error {
|
||||||
if err := plugin.checkInitialized(); err != nil {
|
if err := plugin.checkInitialized(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user