Alpha feature integration

This commit is contained in:
Renaud Gaubert 2017-08-18 15:17:43 -07:00 committed by Jiaying Zhang
parent f7f4515e43
commit 7a8ad491ef
4 changed files with 40 additions and 11 deletions

View File

@ -73,6 +73,13 @@ const (
// Works only with Docker Container Runtime.
Accelerators utilfeature.Feature = "Accelerators"
// owner: @vishh
// alpha: v1.8
//
// Enables support for Device Plugins
// Only Nvidia GPUs are supported as of v1.8.
DevicePlugins utilfeature.Feature = "DevicePlugins"
// owner: @gmarek
// alpha: v1.6
//
@ -155,6 +162,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
ExperimentalHostUserNamespaceDefaultingGate: {Default: false, PreRelease: utilfeature.Beta},
ExperimentalCriticalPodAnnotation: {Default: false, PreRelease: utilfeature.Alpha},
Accelerators: {Default: false, PreRelease: utilfeature.Alpha},
DevicePlugins: {Default: false, PreRelease: utilfeature.Alpha},
TaintBasedEvictions: {Default: false, PreRelease: utilfeature.Alpha},
RotateKubeletServerCertificate: {Default: false, PreRelease: utilfeature.Alpha},
RotateKubeletClientCertificate: {Default: true, PreRelease: utilfeature.Beta},

View File

@ -17,6 +17,8 @@ limitations under the License.
package deviceplugin
import (
"os"
"path"
"testing"
"time"
@ -25,11 +27,14 @@ import (
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1alpha1"
)
const (
socket = "/tmp/mock.sock"
var (
esocketName = "mock.sock"
)
func TestNewEndpoint(t *testing.T) {
wd, _ := os.Getwd()
socket := path.Join(wd, esocketName)
devs := []*pluginapi.Device{
{ID: "ADeviceId", Health: pluginapi.Healthy},
}
@ -39,6 +44,9 @@ func TestNewEndpoint(t *testing.T) {
}
func TestList(t *testing.T) {
wd, _ := os.Getwd()
socket := path.Join(wd, esocketName)
devs := []*pluginapi.Device{
{ID: "ADeviceId", Health: pluginapi.Healthy},
}
@ -62,6 +70,9 @@ func TestList(t *testing.T) {
}
func TestListAndWatch(t *testing.T) {
wd, _ := os.Getwd()
socket := path.Join(wd, esocketName)
devs := []*pluginapi.Device{
{ID: "ADeviceId", Health: pluginapi.Healthy},
{ID: "AnotherDeviceId", Health: pluginapi.Healthy},

View File

@ -17,6 +17,8 @@ limitations under the License.
package deviceplugin
import (
"os"
"path"
"testing"
"github.com/stretchr/testify/require"
@ -25,19 +27,25 @@ import (
)
const (
msocket = "/tmp/server.sock"
msocketName = "/tmp/server.sock"
)
func TestNewManagerImpl(t *testing.T) {
wd, _ := os.Getwd()
socket := path.Join(wd, msocketName)
_, err := NewManagerImpl("", func(n string, a, u, r []*pluginapi.Device) {})
require.Error(t, err)
_, err = NewManagerImpl(msocket, func(n string, a, u, r []*pluginapi.Device) {})
_, err = NewManagerImpl(socket, func(n string, a, u, r []*pluginapi.Device) {})
require.NoError(t, err)
}
func TestNewManagerImplStart(t *testing.T) {
_, err := NewManagerImpl(msocket, func(n string, a, u, r []*pluginapi.Device) {})
wd, _ := os.Getwd()
socket := path.Join(wd, msocketName)
_, err := NewManagerImpl(socket, func(n string, a, u, r []*pluginapi.Device) {})
require.NoError(t, err)
}

View File

@ -754,13 +754,15 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
return nil, err
}
devicePluginHdlr, err := cm.NewDevicePluginHandler()
if err != nil {
return nil, err
if utilfeature.DefaultFeatureGate.Enabled(features.DevicePlugins) {
devicePluginHdlr, err := cm.NewDevicePluginHandler()
if err != nil {
return nil, err
}
klet.containerManager.SetDevicePluginHandler(devicePluginHdlr)
}
klet.containerManager.SetDevicePluginHandler(devicePluginHdlr)
// If the experimentalMounterPathFlag is set, we do not want to
// check node capabilities since the mount path is not the default
if len(kubeCfg.ExperimentalMounterPath) != 0 {