-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanly execute scheduler and kubecontrollermanager via cobra command #18139
Changes from all commits
615bc39
55e11f9
3e101d5
cf77b57
e8bfdb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
package start | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/golang/glog" | ||
"github.com/spf13/pflag" | ||
|
||
kerrors "k8s.io/apimachinery/pkg/util/errors" | ||
schedulerapp "k8s.io/kubernetes/plugin/cmd/kube-scheduler/app" | ||
_ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider" | ||
|
||
cmdflags "github.com/openshift/origin/pkg/cmd/util/flags" | ||
) | ||
|
||
func newScheduler(kubeconfigFile, schedulerConfigFile string, schedulerArgs map[string][]string) (*schedulerapp.Options, error) { | ||
func computeSchedulerArgs(kubeconfigFile, schedulerConfigFile string, schedulerArgs map[string][]string) []string { | ||
cmdLineArgs := map[string][]string{} | ||
// deep-copy the input args to avoid mutation conflict. | ||
for k, v := range schedulerArgs { | ||
|
@@ -35,35 +34,23 @@ func newScheduler(kubeconfigFile, schedulerConfigFile string, schedulerArgs map[ | |
cmdLineArgs["port"] = []string{"-1"} | ||
} | ||
|
||
// resolve arguments | ||
schedulerOptions, err := schedulerapp.NewOptions() | ||
if err != nil { | ||
return nil, err | ||
} | ||
if err := schedulerOptions.ReallyApplyDefaults(); err != nil { | ||
return nil, err | ||
} | ||
if err := cmdflags.Resolve(cmdLineArgs, func(fs *pflag.FlagSet) { | ||
schedulerapp.AddFlags(schedulerOptions, fs) | ||
}); len(err) > 0 { | ||
return nil, kerrors.NewAggregate(err) | ||
args := []string{} | ||
for key, value := range cmdLineArgs { | ||
for _, token := range value { | ||
args = append(args, fmt.Sprintf("--%s=%v", key, token)) | ||
} | ||
} | ||
if err := schedulerOptions.Complete(); err != nil { | ||
return nil, err | ||
} | ||
|
||
return schedulerOptions, nil | ||
return args | ||
} | ||
|
||
func runEmbeddedScheduler(kubeconfigFile, schedulerConfigFile string, cmdLineArgs map[string][]string) { | ||
// TODO we need a real identity for this. Right now it's just using the loopback connection like it used to. | ||
schedulerOptions, err := newScheduler(kubeconfigFile, schedulerConfigFile, cmdLineArgs) | ||
if err != nil { | ||
glog.Fatal(err) | ||
} | ||
// this does a second leader election, but doing the second leader election will allow us to move out process in | ||
// 3.8 if we so choose. | ||
if err := schedulerOptions.Run(); err != nil { | ||
cmd := schedulerapp.NewSchedulerCommand() | ||
args := computeSchedulerArgs(kubeconfigFile, schedulerConfigFile, cmdLineArgs) | ||
if err := cmd.ParseFlags(args); err != nil { | ||
glog.Fatal(err) | ||
} | ||
glog.Infof("`kube-scheduler %v`", args) | ||
cmd.Run(nil, nil) | ||
glog.Fatalf("`kube-scheduler %v` exited", args) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as above. |
||
time.Sleep(10 * time.Second) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Because we can't re-init, we need to die. And if we loop, we'll want to know why