mirror of https://github.com/k3s-io/k3s
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.pull/6/head
commit
24216fe02f
|
@ -39,7 +39,6 @@ import (
|
|||
"k8s.io/kubernetes/pkg/proxy/iptables"
|
||||
"k8s.io/kubernetes/pkg/proxy/userspace"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/configz"
|
||||
utildbus "k8s.io/kubernetes/pkg/util/dbus"
|
||||
"k8s.io/kubernetes/pkg/util/exec"
|
||||
|
@ -47,6 +46,7 @@ import (
|
|||
utilnet "k8s.io/kubernetes/pkg/util/net"
|
||||
nodeutil "k8s.io/kubernetes/pkg/util/node"
|
||||
"k8s.io/kubernetes/pkg/util/oom"
|
||||
"k8s.io/kubernetes/pkg/util/resourcecontainer"
|
||||
"k8s.io/kubernetes/pkg/util/wait"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
@ -158,7 +158,7 @@ func NewProxyServerDefault(config *options.ProxyServerConfig) (*ProxyServer, err
|
|||
|
||||
if config.ResourceContainer != "" {
|
||||
// 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)
|
||||
} else {
|
||||
glog.V(2).Infof("Running in resource-only container %q", config.ResourceContainer)
|
||||
|
|
|
@ -62,7 +62,6 @@ import (
|
|||
"k8s.io/kubernetes/pkg/kubelet/network"
|
||||
"k8s.io/kubernetes/pkg/kubelet/server"
|
||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
utilconfig "k8s.io/kubernetes/pkg/util/config"
|
||||
"k8s.io/kubernetes/pkg/util/configz"
|
||||
"k8s.io/kubernetes/pkg/util/crypto"
|
||||
|
@ -71,6 +70,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
nodeutil "k8s.io/kubernetes/pkg/util/node"
|
||||
"k8s.io/kubernetes/pkg/util/oom"
|
||||
"k8s.io/kubernetes/pkg/util/rlimit"
|
||||
"k8s.io/kubernetes/pkg/util/runtime"
|
||||
"k8s.io/kubernetes/pkg/util/wait"
|
||||
"k8s.io/kubernetes/pkg/version"
|
||||
|
@ -688,7 +688,7 @@ func RunKubelet(kcfg *KubeletConfig) error {
|
|||
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.
|
||||
// This is a workaround for issue: https://github.com/opencontainers/runc/issues/726
|
||||
|
|
|
@ -48,6 +48,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/ui"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/async"
|
||||
"k8s.io/kubernetes/pkg/util/crypto"
|
||||
utilnet "k8s.io/kubernetes/pkg/util/net"
|
||||
utilruntime "k8s.io/kubernetes/pkg/util/runtime"
|
||||
|
@ -221,7 +222,7 @@ type GenericAPIServer struct {
|
|||
PublicReadWritePort int
|
||||
ServiceReadWriteIP net.IP
|
||||
ServiceReadWritePort int
|
||||
masterServices *util.Runner
|
||||
masterServices *async.Runner
|
||||
ExtraServicePorts []api.ServicePort
|
||||
ExtraEndpointPorts []api.EndpointPort
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/kubectl/resource"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/runtime/serializer"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/strings"
|
||||
)
|
||||
|
||||
func initTestErrorHandler(t *testing.T) {
|
||||
|
@ -801,7 +801,7 @@ func Example_printServiceWithNamespacesAndLabels() {
|
|||
Status: api.ServiceStatus{},
|
||||
}},
|
||||
}
|
||||
ld := util.NewLineDelimiter(os.Stdout, "|")
|
||||
ld := strings.NewLineDelimiter(os.Stdout, "|")
|
||||
defer ld.Flush()
|
||||
|
||||
mapper, _ := f.Object(false)
|
||||
|
|
|
@ -31,7 +31,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/registry/service"
|
||||
servicecontroller "k8s.io/kubernetes/pkg/registry/service/ipallocator/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"
|
||||
utilnet "k8s.io/kubernetes/pkg/util/net"
|
||||
"k8s.io/kubernetes/pkg/util/runtime"
|
||||
|
@ -68,7 +68,7 @@ type Controller struct {
|
|||
PublicServicePort int
|
||||
KubernetesServiceNodePort int
|
||||
|
||||
runner *util.Runner
|
||||
runner *async.Runner
|
||||
}
|
||||
|
||||
// Start begins the core controller loops that must exist for bootstrapping
|
||||
|
@ -95,7 +95,7 @@ func (c *Controller) Start() {
|
|||
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()
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
package async
|
||||
|
||||
import (
|
||||
"sync"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
package async
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -16,11 +16,10 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
package resourcecontainer
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups/fs"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
|
@ -43,7 +42,3 @@ func RunInResourceContainer(containerName string) error {
|
|||
|
||||
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
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
package resourcecontainer
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -25,7 +25,3 @@ import (
|
|||
func RunInResourceContainer(containerName string) error {
|
||||
return errors.New("resource-only containers unsupported in this platform")
|
||||
}
|
||||
|
||||
func ApplyRLimitForSelf(maxOpenFiles uint64) error {
|
||||
return errors.New("SetRLimit unsupported in this platform")
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
// +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})
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
// +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
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
package strings
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package util
|
||||
package strings
|
||||
|
||||
import (
|
||||
"fmt"
|
Loading…
Reference in New Issue