mirror of https://github.com/k3s-io/k3s
Merge pull request #57965 from xiangpengzhao/cleanup-feature-gates
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Update test framework featuregates type **What this PR does / why we need it**: A cleanup following #53025 and #57962. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: ref: #53025 and #57962. **Special notes for your reviewer**: but yeah, not sure if it's worthy to do this :) **Release note**: ```release-note NONE ```pull/6/head
commit
829ada8e30
|
@ -137,6 +137,7 @@ go_library(
|
||||||
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/authentication/serviceaccount:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/authentication/serviceaccount:go_default_library",
|
||||||
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||||
|
"//vendor/k8s.io/apiserver/pkg/util/flag:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/discovery:go_default_library",
|
"//vendor/k8s.io/client-go/discovery:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/discovery/cached:go_default_library",
|
"//vendor/k8s.io/client-go/discovery/cached:go_default_library",
|
||||||
"//vendor/k8s.io/client-go/dynamic:go_default_library",
|
"//vendor/k8s.io/client-go/dynamic:go_default_library",
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/onsi/ginkgo/config"
|
"github.com/onsi/ginkgo/config"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
utilflag "k8s.io/apiserver/pkg/util/flag"
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
|
@ -105,8 +106,8 @@ type TestContextType struct {
|
||||||
LogexporterGCSPath string
|
LogexporterGCSPath string
|
||||||
// If the garbage collector is enabled in the kube-apiserver and kube-controller-manager.
|
// If the garbage collector is enabled in the kube-apiserver and kube-controller-manager.
|
||||||
GarbageCollectorEnabled bool
|
GarbageCollectorEnabled bool
|
||||||
// FeatureGates is a set of key=value pairs that describe feature gates for alpha/experimental features.
|
// featureGates is a map of feature names to bools that enable or disable alpha/experimental features.
|
||||||
FeatureGates string
|
FeatureGates map[string]bool
|
||||||
// Node e2e specific test context
|
// Node e2e specific test context
|
||||||
NodeTestContextType
|
NodeTestContextType
|
||||||
// Monitoring solution that is used in current cluster.
|
// Monitoring solution that is used in current cluster.
|
||||||
|
@ -205,7 +206,7 @@ func RegisterCommonFlags() {
|
||||||
flag.StringVar(&TestContext.Host, "host", "", fmt.Sprintf("The host, or apiserver, to connect to. Will default to %s if this argument and --kubeconfig are not set", defaultHost))
|
flag.StringVar(&TestContext.Host, "host", "", fmt.Sprintf("The host, or apiserver, to connect to. Will default to %s if this argument and --kubeconfig are not set", defaultHost))
|
||||||
flag.StringVar(&TestContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
|
flag.StringVar(&TestContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
|
||||||
flag.StringVar(&TestContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
|
flag.StringVar(&TestContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
|
||||||
flag.StringVar(&TestContext.FeatureGates, "feature-gates", "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
|
flag.Var(utilflag.NewMapStringBool(&TestContext.FeatureGates), "feature-gates", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
|
||||||
flag.StringVar(&TestContext.Viper, "viper-config", "e2e", "The name of the viper config i.e. 'e2e' will read values from 'e2e.json' locally. All e2e parameters are meant to be configurable by viper.")
|
flag.StringVar(&TestContext.Viper, "viper-config", "e2e", "The name of the viper config i.e. 'e2e' will read values from 'e2e.json' locally. All e2e parameters are meant to be configurable by viper.")
|
||||||
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker/rkt/remote).")
|
flag.StringVar(&TestContext.ContainerRuntime, "container-runtime", "docker", "The container runtime of cluster VM instances (docker/rkt/remote).")
|
||||||
flag.StringVar(&TestContext.ContainerRuntimeEndpoint, "container-runtime-endpoint", "unix:///var/run/dockershim.sock", "The container runtime endpoint of cluster VM instances.")
|
flag.StringVar(&TestContext.ContainerRuntimeEndpoint, "container-runtime-endpoint", "unix:///var/run/dockershim.sock", "The container runtime endpoint of cluster VM instances.")
|
||||||
|
|
|
@ -115,7 +115,7 @@ func (e *E2EServices) startKubelet() (*server, error) {
|
||||||
glog.Info("Starting kubelet")
|
glog.Info("Starting kubelet")
|
||||||
|
|
||||||
// set feature gates so we can check which features are enabled and pass the appropriate flags
|
// set feature gates so we can check which features are enabled and pass the appropriate flags
|
||||||
utilfeature.DefaultFeatureGate.Set(framework.TestContext.FeatureGates)
|
utilfeature.DefaultFeatureGate.SetFromMap(framework.TestContext.FeatureGates)
|
||||||
|
|
||||||
// Build kubeconfig
|
// Build kubeconfig
|
||||||
kubeconfigPath, err := createKubeconfigCWD()
|
kubeconfigPath, err := createKubeconfigCWD()
|
||||||
|
@ -265,9 +265,9 @@ func (e *E2EServices) startKubelet() (*server, error) {
|
||||||
|
|
||||||
// Apply test framework feature gates by default. This could also be overridden
|
// Apply test framework feature gates by default. This could also be overridden
|
||||||
// by kubelet-flags.
|
// by kubelet-flags.
|
||||||
if framework.TestContext.FeatureGates != "" {
|
if len(framework.TestContext.FeatureGates) > 0 {
|
||||||
cmdArgs = append(cmdArgs, "--feature-gates", framework.TestContext.FeatureGates)
|
cmdArgs = append(cmdArgs, "--feature-gates", utilflag.NewMapStringBool(&framework.TestContext.FeatureGates).String())
|
||||||
utilflag.NewMapStringBool(&kc.FeatureGates).Set(framework.TestContext.FeatureGates)
|
kc.FeatureGates = framework.TestContext.FeatureGates
|
||||||
}
|
}
|
||||||
|
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
|
||||||
|
|
|
@ -108,7 +108,7 @@ func (e *E2EServices) Stop() {
|
||||||
func RunE2EServices() {
|
func RunE2EServices() {
|
||||||
// Populate global DefaultFeatureGate with value from TestContext.FeatureGates.
|
// Populate global DefaultFeatureGate with value from TestContext.FeatureGates.
|
||||||
// This way, statically-linked components see the same feature gate config as the test context.
|
// This way, statically-linked components see the same feature gate config as the test context.
|
||||||
utilfeature.DefaultFeatureGate.Set(framework.TestContext.FeatureGates)
|
utilfeature.DefaultFeatureGate.SetFromMap(framework.TestContext.FeatureGates)
|
||||||
e := newE2EServices()
|
e := newE2EServices()
|
||||||
if err := e.run(); err != nil {
|
if err := e.run(); err != nil {
|
||||||
glog.Fatalf("Failed to run e2e services: %v", err)
|
glog.Fatalf("Failed to run e2e services: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue