Remove redirfd executable and support in the executor

This commit is contained in:
Dr. Stefan Schimanski
2015-09-23 09:29:19 +02:00
parent 0f8adc5d53
commit 67d5b8a258
4 changed files with 4 additions and 166 deletions

View File

@@ -17,7 +17,6 @@ limitations under the License.
package service
import (
"io"
"math/rand"
"net"
"net/http"
@@ -30,11 +29,11 @@ import (
log "github.com/golang/glog"
bindings "github.com/mesos/mesos-go/executor"
"github.com/spf13/pflag"
"k8s.io/kubernetes/cmd/kubelet/app"
"k8s.io/kubernetes/contrib/mesos/pkg/executor"
"k8s.io/kubernetes/contrib/mesos/pkg/executor/config"
"k8s.io/kubernetes/contrib/mesos/pkg/hyperkube"
"k8s.io/kubernetes/contrib/mesos/pkg/redirfd"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/cache"
client "k8s.io/kubernetes/pkg/client/unversioned"
@@ -49,8 +48,6 @@ import (
utilio "k8s.io/kubernetes/pkg/util/io"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/oom"
"github.com/spf13/pflag"
)
const (
@@ -62,8 +59,6 @@ const (
type KubeletExecutorServer struct {
*app.KubeletServer
SuicideTimeout time.Duration
ShutdownFD int
ShutdownFIFO string
}
func NewKubeletExecutorServer() *KubeletExecutorServer {
@@ -77,7 +72,6 @@ func NewKubeletExecutorServer() *KubeletExecutorServer {
k.RootDirectory = pwd // mesos sandbox dir
}
k.Address = net.ParseIP(defaultBindingAddress())
k.ShutdownFD = -1 // indicates unspecified FD
return k
}
@@ -85,20 +79,6 @@ func NewKubeletExecutorServer() *KubeletExecutorServer {
func (s *KubeletExecutorServer) AddFlags(fs *pflag.FlagSet) {
s.KubeletServer.AddFlags(fs)
fs.DurationVar(&s.SuicideTimeout, "suicide-timeout", s.SuicideTimeout, "Self-terminate after this period of inactivity. Zero disables suicide watch.")
fs.IntVar(&s.ShutdownFD, "shutdown-fd", s.ShutdownFD, "File descriptor used to signal shutdown to external watchers, requires shutdown-fifo flag")
fs.StringVar(&s.ShutdownFIFO, "shutdown-fifo", s.ShutdownFIFO, "FIFO used to signal shutdown to external watchers, requires shutdown-fd flag")
}
// returns a Closer that should be closed to signal impending shutdown, but only if ShutdownFD
// and ShutdownFIFO were specified. if they are specified, then this func blocks until there's
// a reader on the FIFO stream.
func (s *KubeletExecutorServer) syncExternalShutdownWatcher() (io.Closer, error) {
if s.ShutdownFD == -1 || s.ShutdownFIFO == "" {
return nil, nil
}
// redirfd -w n fifo ... # (blocks until the fifo is read)
log.Infof("blocked, waiting for shutdown reader for FD %d FIFO at %s", s.ShutdownFD, s.ShutdownFIFO)
return redirfd.Write.Redirect(true, false, redirfd.FileDescriptor(s.ShutdownFD), s.ShutdownFIFO)
}
// Run runs the specified KubeletExecutorServer.
@@ -130,11 +110,6 @@ func (s *KubeletExecutorServer) Run(hks hyperkube.Interface, _ []string) error {
log.Infof("Using root directory: %v", s.RootDirectory)
credentialprovider.SetPreferredDockercfgPath(s.RootDirectory)
shutdownCloser, err := s.syncExternalShutdownWatcher()
if err != nil {
return err
}
cAdvisorInterface, err := cadvisor.New(s.CAdvisorPort)
if err != nil {
return err
@@ -241,7 +216,7 @@ func (s *KubeletExecutorServer) Run(hks hyperkube.Interface, _ []string) error {
kcfg.NodeName = kcfg.Hostname
err = app.RunKubelet(&kcfg, app.KubeletBuilder(func(kc *app.KubeletConfig) (app.KubeletBootstrap, *kconfig.PodConfig, error) {
return s.createAndInitKubelet(kc, hks, clientConfig, shutdownCloser)
return s.createAndInitKubelet(kc, hks, clientConfig)
}))
if err != nil {
return err
@@ -274,7 +249,6 @@ func (ks *KubeletExecutorServer) createAndInitKubelet(
kc *app.KubeletConfig,
hks hyperkube.Interface,
clientConfig *client.Config,
shutdownCloser io.Closer,
) (app.KubeletBootstrap, *kconfig.PodConfig, error) {
// TODO(k8s): block until all sources have delivered at least one update to the channel, or break the sync loop
@@ -363,14 +337,7 @@ func (ks *KubeletExecutorServer) createAndInitKubelet(
Docker: kc.DockerClient,
SuicideTimeout: ks.SuicideTimeout,
KubeletFinished: kubeletFinished,
ShutdownAlert: func() {
if shutdownCloser != nil {
if e := shutdownCloser.Close(); e != nil {
log.Warningf("failed to signal shutdown to external watcher: %v", e)
}
}
},
ExitFunc: os.Exit,
ExitFunc: os.Exit,
PodStatusFunc: func(_ executor.KubeletInterface, pod *api.Pod) (*api.PodStatus, error) {
return klet.GetRuntime().GetPodStatus(pod)
},