mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
prevent initializing the same flag more than once
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
parent
be42dcfd73
commit
a889cc7f79
@ -28,8 +28,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/test/e2e_node/system"
|
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,10 +43,6 @@ var deleteInstances = flag.Bool("delete-instances", true, "If true, delete any i
|
|||||||
var buildOnly = flag.Bool("build-only", false, "If true, build e2e_node_test.tar.gz and exit.")
|
var buildOnly = flag.Bool("build-only", false, "If true, build e2e_node_test.tar.gz and exit.")
|
||||||
var gubernator = flag.Bool("gubernator", false, "If true, output Gubernator link to view logs")
|
var gubernator = flag.Bool("gubernator", false, "If true, output Gubernator link to view logs")
|
||||||
var ginkgoFlags = flag.String("ginkgo-flags", "", "Passed to ginkgo to specify additional flags such as --skip=.")
|
var ginkgoFlags = flag.String("ginkgo-flags", "", "Passed to ginkgo to specify additional flags such as --skip=.")
|
||||||
var systemSpecName = flag.String("system-spec-name", "", fmt.Sprintf("The name of the system spec used for validating the image in the node conformance test. The specs are at %s. If unspecified, the default built-in spec (system.DefaultSpec) will be used.", system.SystemSpecPath))
|
|
||||||
var extraEnvs = flag.String("extra-envs", "", "The extra environment variables needed for node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2")
|
|
||||||
var runtimeConfig = flag.String("runtime-config", "", "The runtime configuration for the API server on the node e2e tests.. Format: a list of key=value pairs, e.g., env1=val1,env2=val2")
|
|
||||||
var kubeletConfigFile = flag.String("kubelet-config-file", "", "The KubeletConfiguration file that should be applied to the kubelet")
|
|
||||||
var (
|
var (
|
||||||
arc Archive
|
arc Archive
|
||||||
)
|
)
|
||||||
@ -60,6 +54,14 @@ type Archive struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getFlag(name string) string {
|
||||||
|
lookup := flag.Lookup(name)
|
||||||
|
if lookup == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return lookup.Value.String()
|
||||||
|
}
|
||||||
|
|
||||||
func RunRemoteTestSuite(testSuite TestSuite) {
|
func RunRemoteTestSuite(testSuite TestSuite) {
|
||||||
// Listen for SIGINT and ignore the first one. In case SIGINT is sent to this
|
// Listen for SIGINT and ignore the first one. In case SIGINT is sent to this
|
||||||
// process and all its children, we ignore it here, while our children ssh connections
|
// process and all its children, we ignore it here, while our children ssh connections
|
||||||
@ -78,7 +80,9 @@ func RunRemoteTestSuite(testSuite TestSuite) {
|
|||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
if *buildOnly {
|
if *buildOnly {
|
||||||
// Build the archive and exit
|
// Build the archive and exit
|
||||||
CreateTestArchive(testSuite, *systemSpecName, *kubeletConfigFile)
|
CreateTestArchive(testSuite,
|
||||||
|
getFlag("system-spec-name"),
|
||||||
|
getFlag("kubelet-config-file"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,9 +101,9 @@ func RunRemoteTestSuite(testSuite TestSuite) {
|
|||||||
DeleteInstances: *deleteInstances,
|
DeleteInstances: *deleteInstances,
|
||||||
Cleanup: *cleanup,
|
Cleanup: *cleanup,
|
||||||
TestArgs: *testArgs,
|
TestArgs: *testArgs,
|
||||||
ExtraEnvs: *extraEnvs,
|
ExtraEnvs: getFlag("extra-envs"),
|
||||||
RuntimeConfig: *runtimeConfig,
|
RuntimeConfig: getFlag("runtime-config"),
|
||||||
SystemSpecName: *systemSpecName,
|
SystemSpecName: getFlag("system-spec-name"),
|
||||||
}
|
}
|
||||||
|
|
||||||
var sshRunner Runner
|
var sshRunner Runner
|
||||||
@ -197,7 +201,11 @@ func callGubernator(gubernator bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Archive) getArchive(suite TestSuite) (string, error) {
|
func (a *Archive) getArchive(suite TestSuite) (string, error) {
|
||||||
a.Do(func() { a.path, a.err = CreateTestArchive(suite, *systemSpecName, *kubeletConfigFile) })
|
a.Do(func() {
|
||||||
|
a.path, a.err = CreateTestArchive(suite,
|
||||||
|
getFlag("system-spec-name"),
|
||||||
|
getFlag("kubelet-config-file"))
|
||||||
|
})
|
||||||
return a.path, a.err
|
return a.path, a.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,11 +63,9 @@ func (a *args) Set(value string) error {
|
|||||||
|
|
||||||
// kubeletArgs is the override kubelet args specified by the test runner.
|
// kubeletArgs is the override kubelet args specified by the test runner.
|
||||||
var kubeletArgs args
|
var kubeletArgs args
|
||||||
var kubeletConfigFile string
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.Var(&kubeletArgs, "kubelet-flags", "Kubelet flags passed to kubelet, this will override default kubelet flags in the test. Flags specified in multiple kubelet-flags will be concatenate. Deprecated, see: --kubelet-config-file.")
|
flag.Var(&kubeletArgs, "kubelet-flags", "Kubelet flags passed to kubelet, this will override default kubelet flags in the test. Flags specified in multiple kubelet-flags will be concatenate. Deprecated, see: --kubelet-config-file.")
|
||||||
flag.StringVar(&kubeletConfigFile, "kubelet-config-file", "./kubeletconfig.yaml", "The base KubeletConfiguration to use when setting up the kubelet. This configuration will then be minimially modified to support requirements from the test suite.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunKubelet starts kubelet and waits for termination signal. Once receives the
|
// RunKubelet starts kubelet and waits for termination signal. Once receives the
|
||||||
@ -176,6 +174,11 @@ func (e *E2EServices) startKubelet(featureGates map[string]bool) (*server, error
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kubeletConfigFile := "./kubeletconfig.yaml"
|
||||||
|
lookup := flag.Lookup("kubelet-config-file")
|
||||||
|
if lookup != nil {
|
||||||
|
kubeletConfigFile = lookup.Value.String()
|
||||||
|
}
|
||||||
kc, err := baseKubeConfiguration(kubeletConfigFile)
|
kc, err := baseKubeConfiguration(kubeletConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to load base kubelet configuration: %w", err)
|
return nil, fmt.Errorf("failed to load base kubelet configuration: %w", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user