From e5b988393dde7ff6d2fc4561a7f7aa4300b7c98f Mon Sep 17 00:00:00 2001 From: Joe Beda Date: Fri, 21 Nov 2014 14:31:40 -0800 Subject: [PATCH] Fix 32bit build --- .../controller-manager.go | 21 +++++++++++++++---- pkg/standalone/standalone.go | 14 +++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/cmd/kube-controller-manager/controller-manager.go b/cmd/kube-controller-manager/controller-manager.go index 8d523ec0faa..ceb7e487e4b 100644 --- a/cmd/kube-controller-manager/controller-manager.go +++ b/cmd/kube-controller-manager/controller-manager.go @@ -22,6 +22,7 @@ package main import ( "flag" + "math" "net" "net/http" "strconv" @@ -50,8 +51,8 @@ var ( minionRegexp = flag.String("minion_regexp", "", "If non empty, and -cloud_provider is specified, a regular expression for matching minion VMs.") machineList util.StringList // TODO: Discover these by pinging the host machines, and rip out these flags. - nodeMilliCPU = flag.Int("node_milli_cpu", 1000, "The amount of MilliCPU provisioned on each node") - nodeMemory = flag.Int("node_memory", 3*1024*1024*1024, "The amount of memory (in bytes) provisioned on each node") + nodeMilliCPU = flag.Int64("node_milli_cpu", 1000, "The amount of MilliCPU provisioned on each node") + nodeMemory = flag.Int64("node_memory", 3*1024*1024*1024, "The amount of memory (in bytes) provisioned on each node") ) func init() { @@ -89,6 +90,18 @@ func main() { glog.Fatalf("Invalid API configuration: %v", err) } + if int64(int(*nodeMilliCPU)) != *nodeMilliCPU { + glog.Warningf("node_milli_cpu is too big for platform. Clamping: %d -> %d", + *nodeMilliCPU, math.MaxInt32) + *nodeMilliCPU = math.MaxInt32 + } + + if int64(int(*nodeMemory)) != *nodeMemory { + glog.Warningf("node_memory is too big for platform. Clamping: %d -> %d", + *nodeMemory, math.MaxInt32) + *nodeMemory = math.MaxInt32 + } + go http.ListenAndServe(net.JoinHostPort(address.String(), strconv.Itoa(*port)), nil) endpoints := service.NewEndpointController(kubeClient) @@ -100,8 +113,8 @@ func main() { cloud := cloudprovider.InitCloudProvider(*cloudProvider, *cloudConfigFile) nodeResources := &api.NodeResources{ Capacity: api.ResourceList{ - resources.CPU: util.NewIntOrStringFromInt(*nodeMilliCPU), - resources.Memory: util.NewIntOrStringFromInt(*nodeMemory), + resources.CPU: util.NewIntOrStringFromInt(int(*nodeMilliCPU)), + resources.Memory: util.NewIntOrStringFromInt(int(*nodeMemory)), }, } minionController := minionControllerPkg.NewMinionController(cloud, *minionRegexp, machineList, nodeResources, kubeClient) diff --git a/pkg/standalone/standalone.go b/pkg/standalone/standalone.go index 839276ed158..7eb28d10ec5 100644 --- a/pkg/standalone/standalone.go +++ b/pkg/standalone/standalone.go @@ -18,6 +18,7 @@ package standalone import ( "fmt" + "math" "net" "net/http" "os" @@ -112,9 +113,18 @@ func RunScheduler(cl *client.Client) { // RunControllerManager starts a controller func RunControllerManager(machineList []string, cl *client.Client, nodeMilliCPU, nodeMemory int64) { - if int64(int(nodeMilliCPU)) != nodeMilliCPU || int64(int(nodeMemory)) != nodeMemory { - glog.Fatalf("Overflow, nodeCPU or nodeMemory too large for the platform") + if int64(int(nodeMilliCPU)) != nodeMilliCPU { + glog.Warningf("node_milli_cpu is too big for platform. Clamping: %d -> %d", + nodeMilliCPU, math.MaxInt32) + nodeMilliCPU = math.MaxInt32 } + + if int64(int(nodeMemory)) != nodeMemory { + glog.Warningf("node_memory is too big for platform. Clamping: %d -> %d", + nodeMemory, math.MaxInt32) + nodeMemory = math.MaxInt32 + } + nodeResources := &api.NodeResources{ Capacity: api.ResourceList{ resources.CPU: util.NewIntOrStringFromInt(int(nodeMilliCPU)),