diff --git a/cmd/kubelet/kubelet.go b/cmd/kubelet/kubelet.go index dfabdaaf3d5..666621fec0c 100644 --- a/cmd/kubelet/kubelet.go +++ b/cmd/kubelet/kubelet.go @@ -68,6 +68,7 @@ var ( clusterDomain = flag.String("cluster_domain", "", "Domain for this cluster. If set, kubelet will configure all containers to search this domain in addition to the host's search domains") masterServiceNamespace = flag.String("master_service_namespace", api.NamespaceDefault, "The namespace from which the kubernetes master services should be injected into pods") clusterDNS = util.IP(nil) + reallyCrashForTesting = flag.Bool("really_crash_for_testing", false, "If true, crash with panics more often.") ) func init() { @@ -96,6 +97,7 @@ func setupRunOnce() { func main() { util.InitFlags() util.InitLogs() + util.ReallyCrash = *reallyCrashForTesting defer util.FlushLogs() rand.Seed(time.Now().UTC().UnixNano()) diff --git a/hack/test-cmd.sh b/hack/test-cmd.sh index dc992a75dc2..49522982876 100755 --- a/hack/test-cmd.sh +++ b/hack/test-cmd.sh @@ -51,9 +51,19 @@ CTLRMGR_PORT=${CTLRMGR_PORT:-10252} kube::log::status "Running kubectl with no options" "${KUBE_OUTPUT_HOSTBIN}/kubectl" -# Start kubelet -kube::log::status "Starting kubelet" +kube::log::status "Starting kubelet in masterless mode" "${KUBE_OUTPUT_HOSTBIN}/kubelet" \ + --really_crash_for_testing=true \ + --root_dir=/tmp/kubelet.$$ \ + --address="127.0.0.1" \ + --port="$KUBELET_PORT" 1>&2 & +KUBELET_PID=$! +kube::util::wait_for_url "http://127.0.0.1:${KUBELET_PORT}/healthz" "kubelet: " +kill ${KUBELET_PID} 1>&2 2>/dev/null + +kube::log::status "Starting kubelet in masterful mode" +"${KUBE_OUTPUT_HOSTBIN}/kubelet" \ + --really_crash_for_testing=true \ --root_dir=/tmp/kubelet.$$ \ --etcd_servers="http://${ETCD_HOST}:${ETCD_PORT}" \ --hostname_override="127.0.0.1" \ diff --git a/pkg/client/cache/listwatch.go b/pkg/client/cache/listwatch.go index 75ac25d73c4..f6e724e2a3f 100644 --- a/pkg/client/cache/listwatch.go +++ b/pkg/client/cache/listwatch.go @@ -24,7 +24,7 @@ import ( ) // ListWatch knows how to list and watch a set of apiserver resources. It satisfies the ListerWatcher interface. -// It is a convenience function for users of NewReflector, etc. +// It is a convenience function for users of NewReflector, etc. Client must not be nil. type ListWatch struct { Client *client.Client FieldSelector labels.Selector diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 40a2cb84b7f..db080995225 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -93,7 +93,9 @@ func NewMainKubelet( } serviceStore := cache.NewStore() - cache.NewReflector(&cache.ListWatch{kubeClient, labels.Everything(), "services", api.NamespaceAll}, &api.Service{}, serviceStore).Run() + if kubeClient != nil { + cache.NewReflector(&cache.ListWatch{kubeClient, labels.Everything(), "services", api.NamespaceAll}, &api.Service{}, serviceStore).Run() + } serviceLister := &cache.StoreToServiceLister{serviceStore} klet := &Kubelet{