Rename package deviceplugin => devicemanager.

pull/6/head
Connor Doyle 2017-12-05 12:28:23 -06:00 committed by Connor Doyle
parent 0a20e10199
commit e5667cf426
14 changed files with 53 additions and 59 deletions

View File

@ -123,7 +123,7 @@ go_library(
"//pkg/apis/core/v1/helper:go_default_library", "//pkg/apis/core/v1/helper:go_default_library",
"//pkg/apis/core/v1/helper/qos:go_default_library", "//pkg/apis/core/v1/helper/qos:go_default_library",
"//pkg/kubelet/cadvisor:go_default_library", "//pkg/kubelet/cadvisor:go_default_library",
"//pkg/kubelet/cm/deviceplugin:go_default_library", "//pkg/kubelet/cm/devicemanager:go_default_library",
"//pkg/kubelet/cm/util:go_default_library", "//pkg/kubelet/cm/util:go_default_library",
"//pkg/kubelet/events:go_default_library", "//pkg/kubelet/events:go_default_library",
"//pkg/kubelet/metrics:go_default_library", "//pkg/kubelet/metrics:go_default_library",
@ -219,7 +219,7 @@ filegroup(
":package-srcs", ":package-srcs",
"//pkg/kubelet/cm/cpumanager:all-srcs", "//pkg/kubelet/cm/cpumanager:all-srcs",
"//pkg/kubelet/cm/cpuset:all-srcs", "//pkg/kubelet/cm/cpuset:all-srcs",
"//pkg/kubelet/cm/deviceplugin:all-srcs", "//pkg/kubelet/cm/devicemanager:all-srcs",
"//pkg/kubelet/cm/util:all-srcs", "//pkg/kubelet/cm/util:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],

View File

@ -45,7 +45,7 @@ import (
internalapi "k8s.io/kubernetes/pkg/kubelet/apis/cri" internalapi "k8s.io/kubernetes/pkg/kubelet/apis/cri"
"k8s.io/kubernetes/pkg/kubelet/cadvisor" "k8s.io/kubernetes/pkg/kubelet/cadvisor"
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager" "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager"
"k8s.io/kubernetes/pkg/kubelet/cm/deviceplugin" "k8s.io/kubernetes/pkg/kubelet/cm/devicemanager"
cmutil "k8s.io/kubernetes/pkg/kubelet/cm/util" cmutil "k8s.io/kubernetes/pkg/kubelet/cm/util"
"k8s.io/kubernetes/pkg/kubelet/config" "k8s.io/kubernetes/pkg/kubelet/config"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
@ -129,7 +129,7 @@ type containerManagerImpl struct {
// Interface for QoS cgroup management // Interface for QoS cgroup management
qosContainerManager QOSContainerManager qosContainerManager QOSContainerManager
// Interface for exporting and allocating devices reported by device plugins. // Interface for exporting and allocating devices reported by device plugins.
devicePluginManager deviceplugin.Manager deviceManager devicemanager.Manager
// Interface for CPU affinity management. // Interface for CPU affinity management.
cpuManager cpumanager.Manager cpuManager cpumanager.Manager
} }
@ -265,9 +265,9 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
glog.Infof("Creating device plugin manager: %t", devicePluginEnabled) glog.Infof("Creating device plugin manager: %t", devicePluginEnabled)
if devicePluginEnabled { if devicePluginEnabled {
cm.devicePluginManager, err = deviceplugin.NewManagerImpl() cm.deviceManager, err = devicemanager.NewManagerImpl()
} else { } else {
cm.devicePluginManager, err = deviceplugin.NewManagerStub() cm.deviceManager, err = devicemanager.NewManagerStub()
} }
if err != nil { if err != nil {
return nil, err return nil, err
@ -586,8 +586,8 @@ func (cm *containerManagerImpl) Start(node *v1.Node,
close(stopChan) close(stopChan)
}, time.Second, stopChan) }, time.Second, stopChan)
// Starts device plugin manager. // Starts device manager.
if err := cm.devicePluginManager.Start(deviceplugin.ActivePodsFunc(activePods), sourcesReady); err != nil { if err := cm.deviceManager.Start(devicemanager.ActivePodsFunc(activePods), sourcesReady); err != nil {
return err return err
} }
return nil return nil
@ -612,7 +612,7 @@ func (cm *containerManagerImpl) GetResources(pod *v1.Pod, container *v1.Containe
opts := &kubecontainer.RunContainerOptions{} opts := &kubecontainer.RunContainerOptions{}
// Allocate should already be called during predicateAdmitHandler.Admit(), // Allocate should already be called during predicateAdmitHandler.Admit(),
// just try to fetch device runtime information from cached state here // just try to fetch device runtime information from cached state here
devOpts := cm.devicePluginManager.GetDeviceRunContainerOptions(pod, container) devOpts := cm.deviceManager.GetDeviceRunContainerOptions(pod, container)
if devOpts == nil { if devOpts == nil {
return opts, nil return opts, nil
} }
@ -623,7 +623,7 @@ func (cm *containerManagerImpl) GetResources(pod *v1.Pod, container *v1.Containe
} }
func (cm *containerManagerImpl) UpdatePluginResources(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error { func (cm *containerManagerImpl) UpdatePluginResources(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error {
return cm.devicePluginManager.Allocate(node, attrs) return cm.deviceManager.Allocate(node, attrs)
} }
func (cm *containerManagerImpl) SystemCgroupsLimit() v1.ResourceList { func (cm *containerManagerImpl) SystemCgroupsLimit() v1.ResourceList {
@ -888,5 +888,5 @@ func (cm *containerManagerImpl) GetCapacity() v1.ResourceList {
} }
func (cm *containerManagerImpl) GetDevicePluginResourceCapacity() (v1.ResourceList, v1.ResourceList, []string) { func (cm *containerManagerImpl) GetDevicePluginResourceCapacity() (v1.ResourceList, v1.ResourceList, []string) {
return cm.devicePluginManager.GetCapacity() return cm.deviceManager.GetCapacity()
} }

View File

@ -1,10 +1,4 @@
package(default_visibility = ["//visibility:public"]) load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
@ -16,7 +10,8 @@ go_library(
"pod_devices.go", "pod_devices.go",
"types.go", "types.go",
], ],
importpath = "k8s.io/kubernetes/pkg/kubelet/cm/deviceplugin", importpath = "k8s.io/kubernetes/pkg/kubelet/cm/devicemanager",
visibility = ["//visibility:public"],
deps = [ deps = [
"//pkg/apis/core/v1/helper:go_default_library", "//pkg/apis/core/v1/helper:go_default_library",
"//pkg/kubelet/apis/deviceplugin/v1alpha:go_default_library", "//pkg/kubelet/apis/deviceplugin/v1alpha:go_default_library",
@ -36,19 +31,6 @@ go_library(
], ],
) )
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
go_test( go_test(
name = "go_default_test", name = "go_default_test",
srcs = [ srcs = [
@ -56,7 +38,7 @@ go_test(
"manager_test.go", "manager_test.go",
], ],
embed = [":go_default_library"], embed = [":go_default_library"],
importpath = "k8s.io/kubernetes/pkg/kubelet/cm/deviceplugin", importpath = "k8s.io/kubernetes/pkg/kubelet/cm/devicemanager",
deps = [ deps = [
"//pkg/kubelet/apis/deviceplugin/v1alpha:go_default_library", "//pkg/kubelet/apis/deviceplugin/v1alpha:go_default_library",
"//pkg/kubelet/lifecycle:go_default_library", "//pkg/kubelet/lifecycle:go_default_library",
@ -72,3 +54,17 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/util/uuid:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
], ],
) )
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package deviceplugin package devicemanager
import ( import (
"log" "log"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package deviceplugin package devicemanager
import ( import (
"fmt" "fmt"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package deviceplugin package devicemanager
import ( import (
"path" "path"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package deviceplugin package devicemanager
import ( import (
"encoding/json" "encoding/json"
@ -187,13 +187,13 @@ func (m *ManagerImpl) removeContents(dir string) error {
} }
const ( const (
// kubeletDevicePluginCheckpoint is the file name of device plugin checkpoint // kubeletDeviceManagerCheckpoint is the file name of device plugin checkpoint
kubeletDevicePluginCheckpoint = "kubelet_internal_checkpoint" kubeletDeviceManagerCheckpoint = "kubelet_internal_checkpoint"
) )
// checkpointFile returns device plugin checkpoint file path. // checkpointFile returns device plugin checkpoint file path.
func (m *ManagerImpl) checkpointFile() string { func (m *ManagerImpl) checkpointFile() string {
return filepath.Join(m.socketdir, kubeletDevicePluginCheckpoint) return filepath.Join(m.socketdir, kubeletDeviceManagerCheckpoint)
} }
// Start starts the Device Plugin Manager amd start initialization of // Start starts the Device Plugin Manager amd start initialization of
@ -456,9 +456,9 @@ func (m *ManagerImpl) writeCheckpoint() error {
if err != nil { if err != nil {
return err return err
} }
err = m.store.Write(kubeletDevicePluginCheckpoint, dataJSON) err = m.store.Write(kubeletDeviceManagerCheckpoint, dataJSON)
if err != nil { if err != nil {
return fmt.Errorf("failed to write deviceplugin checkpoint file %q: %v", kubeletDevicePluginCheckpoint, err) return fmt.Errorf("failed to write deviceplugin checkpoint file %q: %v", kubeletDeviceManagerCheckpoint, err)
} }
return nil return nil
} }
@ -466,14 +466,14 @@ func (m *ManagerImpl) writeCheckpoint() error {
// Reads device to container allocation information from disk, and populates // Reads device to container allocation information from disk, and populates
// m.allocatedDevices accordingly. // m.allocatedDevices accordingly.
func (m *ManagerImpl) readCheckpoint() error { func (m *ManagerImpl) readCheckpoint() error {
content, err := m.store.Read(kubeletDevicePluginCheckpoint) content, err := m.store.Read(kubeletDeviceManagerCheckpoint)
if err != nil { if err != nil {
if err == utilstore.ErrKeyNotFound { if err == utilstore.ErrKeyNotFound {
return nil return nil
} }
return fmt.Errorf("failed to read checkpoint file %q: %v", kubeletDevicePluginCheckpoint, err) return fmt.Errorf("failed to read checkpoint file %q: %v", kubeletDeviceManagerCheckpoint, err)
} }
glog.V(4).Infof("Read checkpoint file %s\n", kubeletDevicePluginCheckpoint) glog.V(4).Infof("Read checkpoint file %s\n", kubeletDeviceManagerCheckpoint)
var data checkpointData var data checkpointData
if err := json.Unmarshal(content, &data); err != nil { if err := json.Unmarshal(content, &data); err != nil {
return fmt.Errorf("failed to unmarshal deviceplugin checkpoint data: %v", err) return fmt.Errorf("failed to unmarshal deviceplugin checkpoint data: %v", err)
@ -611,7 +611,7 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
continue continue
} }
startRPCTime := time.Now() startRPCTime := time.Now()
// devicePluginManager.Allocate involves RPC calls to device plugin, which // Manager.Allocate involves RPC calls to device plugin, which
// could be heavy-weight. Therefore we want to perform this operation outside // could be heavy-weight. Therefore we want to perform this operation outside
// mutex lock. Note if Allocate call fails, we may leave container resources // mutex lock. Note if Allocate call fails, we may leave container resources
// partially allocated for the failed container. We rely on updateAllocatedDevices() // partially allocated for the failed container. We rely on updateAllocatedDevices()

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package deviceplugin package devicemanager
import ( import (
"k8s.io/api/core/v1" "k8s.io/api/core/v1"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package deviceplugin package devicemanager
import ( import (
"flag" "flag"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package deviceplugin package devicemanager
import ( import (
"github.com/golang/glog" "github.com/golang/glog"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package deviceplugin package devicemanager
import ( import (
"k8s.io/api/core/v1" "k8s.io/api/core/v1"

View File

@ -1,10 +1,6 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load( load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
@ -28,6 +24,7 @@ go_library(
"//conditions:default": [], "//conditions:default": [],
}), }),
importpath = "k8s.io/kubernetes/test/e2e_node", importpath = "k8s.io/kubernetes/test/e2e_node",
visibility = ["//visibility:public"],
deps = [ deps = [
"//pkg/api/v1/pod:go_default_library", "//pkg/api/v1/pod:go_default_library",
"//pkg/features:go_default_library", "//pkg/features:go_default_library",
@ -38,7 +35,7 @@ go_library(
"//pkg/kubelet/apis/kubeletconfig/scheme:go_default_library", "//pkg/kubelet/apis/kubeletconfig/scheme:go_default_library",
"//pkg/kubelet/apis/kubeletconfig/v1alpha1:go_default_library", "//pkg/kubelet/apis/kubeletconfig/v1alpha1:go_default_library",
"//pkg/kubelet/apis/stats/v1alpha1:go_default_library", "//pkg/kubelet/apis/stats/v1alpha1:go_default_library",
"//pkg/kubelet/cm/deviceplugin:go_default_library", "//pkg/kubelet/cm/devicemanager:go_default_library",
"//pkg/kubelet/metrics:go_default_library", "//pkg/kubelet/metrics:go_default_library",
"//pkg/kubelet/remote:go_default_library", "//pkg/kubelet/remote:go_default_library",
"//test/e2e/common:go_default_library", "//test/e2e/common:go_default_library",
@ -210,4 +207,5 @@ filegroup(
"//test/e2e_node/system:all-srcs", "//test/e2e_node/system:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"],
) )

View File

@ -34,7 +34,7 @@ import (
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1alpha" pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1alpha"
dp "k8s.io/kubernetes/pkg/kubelet/cm/deviceplugin" dm "k8s.io/kubernetes/pkg/kubelet/cm/devicemanager"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -69,7 +69,7 @@ var _ = framework.KubeDescribe("Device Plugin [Feature:DevicePlugin] [Serial] [D
socketPath := pluginapi.DevicePluginPath + "dp." + fmt.Sprintf("%d", time.Now().Unix()) socketPath := pluginapi.DevicePluginPath + "dp." + fmt.Sprintf("%d", time.Now().Unix())
dp1 := dp.NewDevicePluginStub(devs, socketPath) dp1 := dm.NewDevicePluginStub(devs, socketPath)
dp1.SetAllocFunc(stubAllocFunc) dp1.SetAllocFunc(stubAllocFunc)
err := dp1.Start() err := dp1.Start()
framework.ExpectNoError(err) framework.ExpectNoError(err)
@ -107,7 +107,7 @@ var _ = framework.KubeDescribe("Device Plugin [Feature:DevicePlugin] [Serial] [D
framework.WaitForAllNodesSchedulable(f.ClientSet, framework.TestContext.NodeSchedulableTimeout) framework.WaitForAllNodesSchedulable(f.ClientSet, framework.TestContext.NodeSchedulableTimeout)
By("Re-Register resources") By("Re-Register resources")
dp1 = dp.NewDevicePluginStub(devs, socketPath) dp1 = dm.NewDevicePluginStub(devs, socketPath)
dp1.SetAllocFunc(stubAllocFunc) dp1.SetAllocFunc(stubAllocFunc)
err = dp1.Start() err = dp1.Start()
framework.ExpectNoError(err) framework.ExpectNoError(err)