move KubeletConfiguration out of componentconfig API group
This commit is contained in:
@@ -35,8 +35,8 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apis/componentconfig"
|
||||
v1alpha1 "k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
||||
kubeletconfigv1alpha1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1alpha1"
|
||||
stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
|
||||
kubeletmetrics "k8s.io/kubernetes/pkg/kubelet/metrics"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
@@ -81,7 +81,7 @@ func getNodeSummary() (*stats.Summary, error) {
|
||||
}
|
||||
|
||||
// Returns the current KubeletConfiguration
|
||||
func getCurrentKubeletConfig() (*componentconfig.KubeletConfiguration, error) {
|
||||
func getCurrentKubeletConfig() (*kubeletconfig.KubeletConfiguration, error) {
|
||||
resp := pollConfigz(5*time.Minute, 5*time.Second)
|
||||
kubeCfg, err := decodeConfigz(resp)
|
||||
if err != nil {
|
||||
@@ -93,8 +93,8 @@ func getCurrentKubeletConfig() (*componentconfig.KubeletConfiguration, error) {
|
||||
// Must be called within a Context. Allows the function to modify the KubeletConfiguration during the BeforeEach of the context.
|
||||
// The change is reverted in the AfterEach of the context.
|
||||
// Returns true on success.
|
||||
func tempSetCurrentKubeletConfig(f *framework.Framework, updateFunction func(initialConfig *componentconfig.KubeletConfiguration)) {
|
||||
var oldCfg *componentconfig.KubeletConfiguration
|
||||
func tempSetCurrentKubeletConfig(f *framework.Framework, updateFunction func(initialConfig *kubeletconfig.KubeletConfiguration)) {
|
||||
var oldCfg *kubeletconfig.KubeletConfiguration
|
||||
BeforeEach(func() {
|
||||
configEnabled, err := isKubeletConfigEnabled(f)
|
||||
framework.ExpectNoError(err)
|
||||
@@ -103,7 +103,7 @@ func tempSetCurrentKubeletConfig(f *framework.Framework, updateFunction func(ini
|
||||
framework.ExpectNoError(err)
|
||||
clone, err := scheme.Scheme.DeepCopy(oldCfg)
|
||||
framework.ExpectNoError(err)
|
||||
newCfg := clone.(*componentconfig.KubeletConfiguration)
|
||||
newCfg := clone.(*kubeletconfig.KubeletConfiguration)
|
||||
updateFunction(newCfg)
|
||||
framework.ExpectNoError(setKubeletConfiguration(f, newCfg))
|
||||
} else {
|
||||
@@ -132,7 +132,7 @@ func isKubeletConfigEnabled(f *framework.Framework) (bool, error) {
|
||||
// Creates or updates the configmap for KubeletConfiguration, waits for the Kubelet to restart
|
||||
// with the new configuration. Returns an error if the configuration after waiting for restartGap
|
||||
// doesn't match what you attempted to set, or if the dynamic configuration feature is disabled.
|
||||
func setKubeletConfiguration(f *framework.Framework, kubeCfg *componentconfig.KubeletConfiguration) error {
|
||||
func setKubeletConfiguration(f *framework.Framework, kubeCfg *kubeletconfig.KubeletConfiguration) error {
|
||||
const (
|
||||
restartGap = 40 * time.Second
|
||||
pollInterval = 5 * time.Second
|
||||
@@ -217,16 +217,16 @@ func pollConfigz(timeout time.Duration, pollInterval time.Duration) *http.Respon
|
||||
return resp
|
||||
}
|
||||
|
||||
// Decodes the http response from /configz and returns a componentconfig.KubeletConfiguration (internal type).
|
||||
func decodeConfigz(resp *http.Response) (*componentconfig.KubeletConfiguration, error) {
|
||||
// Decodes the http response from /configz and returns a kubeletconfig.KubeletConfiguration (internal type).
|
||||
func decodeConfigz(resp *http.Response) (*kubeletconfig.KubeletConfiguration, error) {
|
||||
// This hack because /configz reports the following structure:
|
||||
// {"componentconfig": {the JSON representation of v1alpha1.KubeletConfiguration}}
|
||||
// {"kubeletconfig": {the JSON representation of kubeletconfigv1alpha1.KubeletConfiguration}}
|
||||
type configzWrapper struct {
|
||||
ComponentConfig v1alpha1.KubeletConfiguration `json:"componentconfig"`
|
||||
ComponentConfig kubeletconfigv1alpha1.KubeletConfiguration `json:"kubeletconfig"`
|
||||
}
|
||||
|
||||
configz := configzWrapper{}
|
||||
kubeCfg := componentconfig.KubeletConfiguration{}
|
||||
kubeCfg := kubeletconfig.KubeletConfiguration{}
|
||||
|
||||
contentsBytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
@@ -247,7 +247,7 @@ func decodeConfigz(resp *http.Response) (*componentconfig.KubeletConfiguration,
|
||||
}
|
||||
|
||||
// creates a configmap containing kubeCfg in kube-system namespace
|
||||
func createConfigMap(f *framework.Framework, internalKC *componentconfig.KubeletConfiguration) (*v1.ConfigMap, error) {
|
||||
func createConfigMap(f *framework.Framework, internalKC *kubeletconfig.KubeletConfiguration) (*v1.ConfigMap, error) {
|
||||
cmap := makeKubeletConfigMap(internalKC)
|
||||
cmap, err := f.ClientSet.Core().ConfigMaps("kube-system").Create(cmap)
|
||||
if err != nil {
|
||||
@@ -257,11 +257,11 @@ func createConfigMap(f *framework.Framework, internalKC *componentconfig.Kubelet
|
||||
}
|
||||
|
||||
// constructs a ConfigMap, populating one of its keys with the KubeletConfiguration. Uses GenerateName.
|
||||
func makeKubeletConfigMap(internalKC *componentconfig.KubeletConfiguration) *v1.ConfigMap {
|
||||
externalKC := &v1alpha1.KubeletConfiguration{}
|
||||
func makeKubeletConfigMap(internalKC *kubeletconfig.KubeletConfiguration) *v1.ConfigMap {
|
||||
externalKC := &kubeletconfigv1alpha1.KubeletConfiguration{}
|
||||
api.Scheme.Convert(internalKC, externalKC, nil)
|
||||
|
||||
encoder, err := newJSONEncoder(componentconfig.GroupName)
|
||||
encoder, err := newJSONEncoder(kubeletconfig.GroupName)
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
data, err := runtime.Encode(encoder, externalKC)
|
||||
|
Reference in New Issue
Block a user