Commit 24216fe0 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #26958 from resouer/util-line

Automatic merge from submit-queue Refactoring runner resource container linedelimiter to it's own pkg Continuing my work ref #15634 Anyone is ok to review this fix.
parents 48bd6368 e0ab7601
...@@ -39,7 +39,6 @@ import ( ...@@ -39,7 +39,6 @@ import (
"k8s.io/kubernetes/pkg/proxy/iptables" "k8s.io/kubernetes/pkg/proxy/iptables"
"k8s.io/kubernetes/pkg/proxy/userspace" "k8s.io/kubernetes/pkg/proxy/userspace"
"k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/configz" "k8s.io/kubernetes/pkg/util/configz"
utildbus "k8s.io/kubernetes/pkg/util/dbus" utildbus "k8s.io/kubernetes/pkg/util/dbus"
"k8s.io/kubernetes/pkg/util/exec" "k8s.io/kubernetes/pkg/util/exec"
...@@ -47,6 +46,7 @@ import ( ...@@ -47,6 +46,7 @@ import (
utilnet "k8s.io/kubernetes/pkg/util/net" utilnet "k8s.io/kubernetes/pkg/util/net"
nodeutil "k8s.io/kubernetes/pkg/util/node" nodeutil "k8s.io/kubernetes/pkg/util/node"
"k8s.io/kubernetes/pkg/util/oom" "k8s.io/kubernetes/pkg/util/oom"
"k8s.io/kubernetes/pkg/util/resourcecontainer"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"github.com/golang/glog" "github.com/golang/glog"
...@@ -158,7 +158,7 @@ func NewProxyServerDefault(config *options.ProxyServerConfig) (*ProxyServer, err ...@@ -158,7 +158,7 @@ func NewProxyServerDefault(config *options.ProxyServerConfig) (*ProxyServer, err
if config.ResourceContainer != "" { if config.ResourceContainer != "" {
// Run in its own container. // Run in its own container.
if err := util.RunInResourceContainer(config.ResourceContainer); err != nil { if err := resourcecontainer.RunInResourceContainer(config.ResourceContainer); err != nil {
glog.Warningf("Failed to start in resource-only container %q: %v", config.ResourceContainer, err) glog.Warningf("Failed to start in resource-only container %q: %v", config.ResourceContainer, err)
} else { } else {
glog.V(2).Infof("Running in resource-only container %q", config.ResourceContainer) glog.V(2).Infof("Running in resource-only container %q", config.ResourceContainer)
......
...@@ -62,7 +62,6 @@ import ( ...@@ -62,7 +62,6 @@ import (
"k8s.io/kubernetes/pkg/kubelet/network" "k8s.io/kubernetes/pkg/kubelet/network"
"k8s.io/kubernetes/pkg/kubelet/server" "k8s.io/kubernetes/pkg/kubelet/server"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types" kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/util"
utilconfig "k8s.io/kubernetes/pkg/util/config" utilconfig "k8s.io/kubernetes/pkg/util/config"
"k8s.io/kubernetes/pkg/util/configz" "k8s.io/kubernetes/pkg/util/configz"
"k8s.io/kubernetes/pkg/util/crypto" "k8s.io/kubernetes/pkg/util/crypto"
...@@ -71,6 +70,7 @@ import ( ...@@ -71,6 +70,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/mount"
nodeutil "k8s.io/kubernetes/pkg/util/node" nodeutil "k8s.io/kubernetes/pkg/util/node"
"k8s.io/kubernetes/pkg/util/oom" "k8s.io/kubernetes/pkg/util/oom"
"k8s.io/kubernetes/pkg/util/rlimit"
"k8s.io/kubernetes/pkg/util/runtime" "k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/version" "k8s.io/kubernetes/pkg/version"
...@@ -688,7 +688,7 @@ func RunKubelet(kcfg *KubeletConfig) error { ...@@ -688,7 +688,7 @@ func RunKubelet(kcfg *KubeletConfig) error {
return fmt.Errorf("failed to create kubelet: %v", err) return fmt.Errorf("failed to create kubelet: %v", err)
} }
util.ApplyRLimitForSelf(kcfg.MaxOpenFiles) rlimit.RlimitNumFiles(kcfg.MaxOpenFiles)
// TODO(dawnchen): remove this once we deprecated old debian containervm images. // TODO(dawnchen): remove this once we deprecated old debian containervm images.
// This is a workaround for issue: https://github.com/opencontainers/runc/issues/726 // This is a workaround for issue: https://github.com/opencontainers/runc/issues/726
......
...@@ -48,6 +48,7 @@ import ( ...@@ -48,6 +48,7 @@ import (
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/ui" "k8s.io/kubernetes/pkg/ui"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/async"
"k8s.io/kubernetes/pkg/util/crypto" "k8s.io/kubernetes/pkg/util/crypto"
utilnet "k8s.io/kubernetes/pkg/util/net" utilnet "k8s.io/kubernetes/pkg/util/net"
utilruntime "k8s.io/kubernetes/pkg/util/runtime" utilruntime "k8s.io/kubernetes/pkg/util/runtime"
...@@ -221,7 +222,7 @@ type GenericAPIServer struct { ...@@ -221,7 +222,7 @@ type GenericAPIServer struct {
PublicReadWritePort int PublicReadWritePort int
ServiceReadWriteIP net.IP ServiceReadWriteIP net.IP
ServiceReadWritePort int ServiceReadWritePort int
masterServices *util.Runner masterServices *async.Runner
ExtraServicePorts []api.ServicePort ExtraServicePorts []api.ServicePort
ExtraEndpointPorts []api.EndpointPort ExtraEndpointPorts []api.EndpointPort
......
...@@ -41,7 +41,7 @@ import ( ...@@ -41,7 +41,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl/resource" "k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime/serializer" "k8s.io/kubernetes/pkg/runtime/serializer"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util/strings"
) )
func initTestErrorHandler(t *testing.T) { func initTestErrorHandler(t *testing.T) {
...@@ -801,7 +801,7 @@ func Example_printServiceWithNamespacesAndLabels() { ...@@ -801,7 +801,7 @@ func Example_printServiceWithNamespacesAndLabels() {
Status: api.ServiceStatus{}, Status: api.ServiceStatus{},
}}, }},
} }
ld := util.NewLineDelimiter(os.Stdout, "|") ld := strings.NewLineDelimiter(os.Stdout, "|")
defer ld.Flush() defer ld.Flush()
mapper, _ := f.Object(false) mapper, _ := f.Object(false)
......
...@@ -31,7 +31,7 @@ import ( ...@@ -31,7 +31,7 @@ import (
"k8s.io/kubernetes/pkg/registry/service" "k8s.io/kubernetes/pkg/registry/service"
servicecontroller "k8s.io/kubernetes/pkg/registry/service/ipallocator/controller" servicecontroller "k8s.io/kubernetes/pkg/registry/service/ipallocator/controller"
portallocatorcontroller "k8s.io/kubernetes/pkg/registry/service/portallocator/controller" portallocatorcontroller "k8s.io/kubernetes/pkg/registry/service/portallocator/controller"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util/async"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
utilnet "k8s.io/kubernetes/pkg/util/net" utilnet "k8s.io/kubernetes/pkg/util/net"
"k8s.io/kubernetes/pkg/util/runtime" "k8s.io/kubernetes/pkg/util/runtime"
...@@ -68,7 +68,7 @@ type Controller struct { ...@@ -68,7 +68,7 @@ type Controller struct {
PublicServicePort int PublicServicePort int
KubernetesServiceNodePort int KubernetesServiceNodePort int
runner *util.Runner runner *async.Runner
} }
// Start begins the core controller loops that must exist for bootstrapping // Start begins the core controller loops that must exist for bootstrapping
...@@ -95,7 +95,7 @@ func (c *Controller) Start() { ...@@ -95,7 +95,7 @@ func (c *Controller) Start() {
glog.Errorf("Unable to perform initial Kubernetes service initialization: %v", err) glog.Errorf("Unable to perform initial Kubernetes service initialization: %v", err)
} }
c.runner = util.NewRunner(c.RunKubernetesNamespaces, c.RunKubernetesService, repairClusterIPs.RunUntil, repairNodePorts.RunUntil) c.runner = async.NewRunner(c.RunKubernetesNamespaces, c.RunKubernetesService, repairClusterIPs.RunUntil, repairNodePorts.RunUntil)
c.runner.Start() c.runner.Start()
} }
......
...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and ...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package util package async
import ( import (
"sync" "sync"
......
...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and ...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package util package async
import ( import (
"fmt" "fmt"
......
...@@ -16,11 +16,10 @@ See the License for the specific language governing permissions and ...@@ -16,11 +16,10 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package util package resourcecontainer
import ( import (
"os" "os"
"syscall"
"github.com/opencontainers/runc/libcontainer/cgroups/fs" "github.com/opencontainers/runc/libcontainer/cgroups/fs"
"github.com/opencontainers/runc/libcontainer/configs" "github.com/opencontainers/runc/libcontainer/configs"
...@@ -43,7 +42,3 @@ func RunInResourceContainer(containerName string) error { ...@@ -43,7 +42,3 @@ func RunInResourceContainer(containerName string) error {
return manager.Apply(os.Getpid()) return manager.Apply(os.Getpid())
} }
func ApplyRLimitForSelf(maxOpenFiles uint64) {
syscall.Setrlimit(syscall.RLIMIT_NOFILE, &syscall.Rlimit{Max: maxOpenFiles, Cur: maxOpenFiles})
}
...@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and ...@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package util package resourcecontainer
import ( import (
"errors" "errors"
...@@ -25,7 +25,3 @@ import ( ...@@ -25,7 +25,3 @@ import (
func RunInResourceContainer(containerName string) error { func RunInResourceContainer(containerName string) error {
return errors.New("resource-only containers unsupported in this platform") return errors.New("resource-only containers unsupported in this platform")
} }
func ApplyRLimitForSelf(maxOpenFiles uint64) error {
return errors.New("SetRLimit unsupported in this platform")
}
// +build linux
/*
Copyright 2016 The Kubernetes Authors.
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 rlimit
import (
"syscall"
)
func RlimitNumFiles(maxOpenFiles uint64) {
syscall.Setrlimit(syscall.RLIMIT_NOFILE, &syscall.Rlimit{Max: maxOpenFiles, Cur: maxOpenFiles})
}
// +build !linux
/*
Copyright 2016 The Kubernetes Authors.
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 rlimit
import (
"errors"
)
func RlimitNumFiles(maxOpenFiles uint64) error {
return errors.New("SetRLimit unsupported in this platform")
}
...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and ...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package util package strings
import ( import (
"bytes" "bytes"
......
...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and ...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package util package strings
import ( import (
"fmt" "fmt"
......
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