Commit 2326e2ba authored by Clayton Coleman's avatar Clayton Coleman

Split controller manager options from init

Make defaults and flags clearly distinct from initialization code.
parent ab6edd81
...@@ -19,19 +19,20 @@ limitations under the License. ...@@ -19,19 +19,20 @@ limitations under the License.
package main package main
import ( import (
controllermgr "k8s.io/kubernetes/cmd/kube-controller-manager/app" "k8s.io/kubernetes/cmd/kube-controller-manager/app"
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
) )
// NewKubeControllerManager creates a new hyperkube Server object that includes the // NewKubeControllerManager creates a new hyperkube Server object that includes the
// description and flags. // description and flags.
func NewKubeControllerManager() *Server { func NewKubeControllerManager() *Server {
s := controllermgr.NewCMServer() s := options.NewCMServer()
hks := Server{ hks := Server{
SimpleUsage: "controller-manager", SimpleUsage: "controller-manager",
Long: "A server that runs a set of active components. This includes replication controllers, service endpoints and nodes.", Long: "A server that runs a set of active components. This includes replication controllers, service endpoints and nodes.",
Run: func(_ *Server, args []string) error { Run: func(_ *Server, args []string) error {
return s.Run(args) return app.Run(s)
}, },
} }
s.AddFlags(hks.Flags()) s.AddFlags(hks.Flags())
......
...@@ -23,6 +23,8 @@ import ( ...@@ -23,6 +23,8 @@ import (
"fmt" "fmt"
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
//Cloud providers //Cloud providers
_ "k8s.io/kubernetes/pkg/cloudprovider/providers" _ "k8s.io/kubernetes/pkg/cloudprovider/providers"
...@@ -43,7 +45,7 @@ import ( ...@@ -43,7 +45,7 @@ import (
) )
// ProbeRecyclableVolumePlugins collects all persistent volume plugins into an easy to use list. // ProbeRecyclableVolumePlugins collects all persistent volume plugins into an easy to use list.
func ProbeRecyclableVolumePlugins(flags VolumeConfigFlags) []volume.VolumePlugin { func ProbeRecyclableVolumePlugins(flags options.VolumeConfigFlags) []volume.VolumePlugin {
allPlugins := []volume.VolumePlugin{} allPlugins := []volume.VolumePlugin{}
// The list of plugins to probe is decided by this binary, not // The list of plugins to probe is decided by this binary, not
...@@ -86,7 +88,7 @@ func ProbeRecyclableVolumePlugins(flags VolumeConfigFlags) []volume.VolumePlugin ...@@ -86,7 +88,7 @@ func ProbeRecyclableVolumePlugins(flags VolumeConfigFlags) []volume.VolumePlugin
// The beta implementation of provisioning allows 1 implied provisioner per cloud, until we allow configuration of many. // The beta implementation of provisioning allows 1 implied provisioner per cloud, until we allow configuration of many.
// We explicitly map clouds to volume plugins here which allows us to configure many later without backwards compatibility issues. // We explicitly map clouds to volume plugins here which allows us to configure many later without backwards compatibility issues.
// Not all cloudproviders have provisioning capability, which is the reason for the bool in the return to tell the caller to expect one or not. // Not all cloudproviders have provisioning capability, which is the reason for the bool in the return to tell the caller to expect one or not.
func NewVolumeProvisioner(cloud cloudprovider.Interface, flags VolumeConfigFlags) (volume.ProvisionableVolumePlugin, error) { func NewVolumeProvisioner(cloud cloudprovider.Interface, flags options.VolumeConfigFlags) (volume.ProvisionableVolumePlugin, error) {
switch { switch {
case cloud == nil && flags.EnableHostPathProvisioning: case cloud == nil && flags.EnableHostPathProvisioning:
return getProvisionablePluginFromVolumePlugins(host_path.ProbeVolumePlugins(volume.VolumeConfig{})) return getProvisionablePluginFromVolumePlugins(host_path.ProbeVolumePlugins(volume.VolumeConfig{}))
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"runtime" "runtime"
"k8s.io/kubernetes/cmd/kube-controller-manager/app" "k8s.io/kubernetes/cmd/kube-controller-manager/app"
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
"k8s.io/kubernetes/pkg/healthz" "k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/version/verflag" "k8s.io/kubernetes/pkg/version/verflag"
...@@ -39,7 +40,7 @@ func init() { ...@@ -39,7 +40,7 @@ func init() {
func main() { func main() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
s := app.NewCMServer() s := options.NewCMServer()
s.AddFlags(pflag.CommandLine) s.AddFlags(pflag.CommandLine)
util.InitFlags() util.InitFlags()
...@@ -48,7 +49,7 @@ func main() { ...@@ -48,7 +49,7 @@ func main() {
verflag.PrintAndExitIfRequested() verflag.PrintAndExitIfRequested()
if err := s.Run(pflag.CommandLine.Args()); err != nil { if err := app.Run(s); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err) fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1) os.Exit(1)
} }
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"time" "time"
kubecontrollermanager "k8s.io/kubernetes/cmd/kube-controller-manager/app" kubecontrollermanager "k8s.io/kubernetes/cmd/kube-controller-manager/app"
"k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
"k8s.io/kubernetes/contrib/mesos/pkg/node" "k8s.io/kubernetes/contrib/mesos/pkg/node"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
...@@ -58,14 +59,14 @@ import ( ...@@ -58,14 +59,14 @@ import (
// CMServer is the main context object for the controller manager. // CMServer is the main context object for the controller manager.
type CMServer struct { type CMServer struct {
*kubecontrollermanager.CMServer *options.CMServer
UseHostPortEndpoints bool UseHostPortEndpoints bool
} }
// NewCMServer creates a new CMServer with a default config. // NewCMServer creates a new CMServer with a default config.
func NewCMServer() *CMServer { func NewCMServer() *CMServer {
s := &CMServer{ s := &CMServer{
CMServer: kubecontrollermanager.NewCMServer(), CMServer: options.NewCMServer(),
} }
s.CloudProvider = mesos.ProviderName s.CloudProvider = mesos.ProviderName
s.UseHostPortEndpoints = true s.UseHostPortEndpoints = true
......
...@@ -21,8 +21,8 @@ import ( ...@@ -21,8 +21,8 @@ import (
"time" "time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
cmapp "k8s.io/kubernetes/cmd/kube-controller-manager/app" cmoptions "k8s.io/kubernetes/cmd/kube-controller-manager/app/options"
"k8s.io/kubernetes/cmd/kubelet/app/options" kubeletoptions "k8s.io/kubernetes/cmd/kubelet/app/options"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
) )
...@@ -46,8 +46,8 @@ func Test_nodeWithUpdatedStatus(t *testing.T) { ...@@ -46,8 +46,8 @@ func Test_nodeWithUpdatedStatus(t *testing.T) {
} }
} }
cm := cmapp.NewCMServer() cm := cmoptions.NewCMServer()
kubecfg := options.NewKubeletServer() kubecfg := kubeletoptions.NewKubeletServer()
assert.True(t, kubecfg.NodeStatusUpdateFrequency*3 < cm.NodeMonitorGracePeriod) // sanity check for defaults assert.True(t, kubecfg.NodeStatusUpdateFrequency*3 < cm.NodeMonitorGracePeriod) // sanity check for defaults
n := testNode(0, api.ConditionTrue, "KubeletReady") n := testNode(0, api.ConditionTrue, "KubeletReady")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment