diff --git a/contrib/mesos/cmd/k8sm-redirfd/doc.go b/contrib/mesos/cmd/k8sm-redirfd/doc.go deleted file mode 100644 index fdfc3b67426..00000000000 --- a/contrib/mesos/cmd/k8sm-redirfd/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors All rights reserved. - -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. -*/ - -// This package main is used for testing the redirfd package. -// Inspired by http://skarnet.org/software/execline/redirfd.html. -// Usage: -// k8sm-redirfb [-n] [-b] {mode} {fd} {file} {prog...} -package main diff --git a/contrib/mesos/cmd/k8sm-redirfd/redirfd.go b/contrib/mesos/cmd/k8sm-redirfd/redirfd.go deleted file mode 100644 index afed9f9c44c..00000000000 --- a/contrib/mesos/cmd/k8sm-redirfd/redirfd.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors All rights reserved. - -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. -*/ - -package main - -import ( - "flag" - "fmt" - "os" - "os/exec" - "syscall" - - "k8s.io/kubernetes/contrib/mesos/pkg/redirfd" -) - -func main() { - nonblock := flag.Bool("n", false, "open file in non-blocking mode") - changemode := flag.Bool("b", false, "change mode of file after opening it: to non-blocking mode if the -n option was not given, to blocking mode if it was") - flag.Parse() - - args := flag.Args() - if len(args) < 4 { - fmt.Fprintf(os.Stderr, "expected {mode} {fd} {file} instead of: %v\n", args) - os.Exit(1) - } - - var mode redirfd.RedirectMode - switch m := args[0]; m { - case "r": - mode = redirfd.Read - case "w": - mode = redirfd.Write - case "u": - mode = redirfd.Update - case "a": - mode = redirfd.Append - case "c": - mode = redirfd.AppendExisting - case "x": - mode = redirfd.WriteNew - default: - fmt.Fprintf(os.Stderr, "unrecognized mode %q\n", mode) - os.Exit(1) - } - - fd, err := redirfd.ParseFileDescriptor(args[1]) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to parse file descriptor: %v\n", err) - os.Exit(1) - } - file := args[2] - - f, err := mode.Redirect(*nonblock, *changemode, fd, file) - if err != nil { - fmt.Fprintf(os.Stderr, "redirect failed: %q, %v\n", args[1], err) - os.Exit(1) - } - var pargs []string - if len(args) > 4 { - pargs = args[4:] - } - cmd := exec.Command(args[3], pargs...) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - switch fd { - case redirfd.Stdin: - cmd.Stdin = f - case redirfd.Stdout: - cmd.Stdout = f - case redirfd.Stderr: - cmd.Stderr = f - default: - cmd.ExtraFiles = []*os.File{f} - } - defer f.Close() - if err = cmd.Run(); err != nil { - exiterr := err.(*exec.ExitError) - state := exiterr.ProcessState - if state != nil { - sys := state.Sys() - if waitStatus, ok := sys.(syscall.WaitStatus); ok { - if waitStatus.Signaled() { - os.Exit(256 + int(waitStatus.Signal())) - } else { - os.Exit(waitStatus.ExitStatus()) - } - } - } - os.Exit(3) - } -} diff --git a/contrib/mesos/pkg/executor/service/service.go b/contrib/mesos/pkg/executor/service/service.go index 1862733a957..ac59d8fca73 100644 --- a/contrib/mesos/pkg/executor/service/service.go +++ b/contrib/mesos/pkg/executor/service/service.go @@ -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) }, diff --git a/contrib/mesos/target.sh b/contrib/mesos/target.sh index e305e81d6c1..02f0ad0a3b8 100644 --- a/contrib/mesos/target.sh +++ b/contrib/mesos/target.sh @@ -29,10 +29,7 @@ kube::contrib::mesos::server_targets() { # The set of test targets that we are building for all platforms # Used by hack/lib/golang.sh kube::contrib::mesos::test_targets() { - local -r targets=( - contrib/mesos/cmd/k8sm-redirfd - ) - echo "${targets[@]}" + true } # The set of source targets to include in the kube-build image