From 40deeda6539623d07098863172de5a54dac12314 Mon Sep 17 00:00:00 2001 From: Rakshit Gondwal Date: Wed, 17 Jan 2024 02:41:13 +0530 Subject: [PATCH 1/4] feat: image version matching Signed-off-by: Rakshit Gondwal --- pkg/common/args.go | 5 ++++- pkg/common/const.go | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/common/args.go b/pkg/common/args.go index b10e5bf..de821d7 100644 --- a/pkg/common/args.go +++ b/pkg/common/args.go @@ -28,6 +28,8 @@ import ( "sigs.k8s.io/hydrophone/pkg/log" ) +var containerImage string + // ArgConfig stores the argument passed when running the program type ArgConfig struct { // Focus set the E2E_FOCUS env var to run a specific test @@ -87,7 +89,7 @@ func InitArgs() (*ArgConfig, error) { flag.StringVar(&cfg.Focus, "focus", "", "focus runs a specific e2e test. e.g. - sig-auth. allows regular expressions.") flag.StringVar(&cfg.Skip, "skip", "", "skip specific tests. allows regular expressions.") - flag.StringVar(&cfg.ConformanceImage, "conformance-image", containerImage, + flag.StringVar(&cfg.ConformanceImage, "conformance-image", fmt.Sprintf("registry.k8s.io/conformance:%s", containerImage), "specify a conformance container image of your choice.") flag.StringVar(&cfg.BusyboxImage, "busybox-image", busyboxImage, "specify an alternate busybox container image.") @@ -128,6 +130,7 @@ func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config) { if err != nil { log.Fatal("Error fetching server version: ", err) } + containerImage = serverVersion.String() log.Printf("API endpoint : %s", config.Host) log.Printf("Server version : %#v", *serverVersion) diff --git a/pkg/common/const.go b/pkg/common/const.go index 4c8448e..2db6e9b 100644 --- a/pkg/common/const.go +++ b/pkg/common/const.go @@ -17,8 +17,6 @@ limitations under the License. package common const ( - // containerImage is the default contaimer image used to run the conformance tests - containerImage = "registry.k8s.io/conformance:v1.29.0" // busyboxImage is the image used to extract the e2e logs busyboxImage = "registry.k8s.io/e2e-test-images/busybox:1.36.1-1" // Namespace is the namespace where the conformance pod is created From 386892b72a5f85c90564b39411884981977f82d9 Mon Sep 17 00:00:00 2001 From: Rakshit Gondwal Date: Wed, 17 Jan 2024 03:49:01 +0530 Subject: [PATCH 2/4] modify containerVersion image later Signed-off-by: Rakshit Gondwal --- main.go | 2 +- pkg/common/args.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 985de01..be11687 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ func main() { config, clientSet := service.Init(cfg) client.ClientSet = clientSet - common.PrintInfo(client.ClientSet, config) + common.PrintInfo(client.ClientSet, config, cfg) if cfg.ListImages { service.PrintListImages(cfg, client.ClientSet, config) diff --git a/pkg/common/args.go b/pkg/common/args.go index de821d7..353039e 100644 --- a/pkg/common/args.go +++ b/pkg/common/args.go @@ -28,8 +28,6 @@ import ( "sigs.k8s.io/hydrophone/pkg/log" ) -var containerImage string - // ArgConfig stores the argument passed when running the program type ArgConfig struct { // Focus set the E2E_FOCUS env var to run a specific test @@ -89,8 +87,7 @@ func InitArgs() (*ArgConfig, error) { flag.StringVar(&cfg.Focus, "focus", "", "focus runs a specific e2e test. e.g. - sig-auth. allows regular expressions.") flag.StringVar(&cfg.Skip, "skip", "", "skip specific tests. allows regular expressions.") - flag.StringVar(&cfg.ConformanceImage, "conformance-image", fmt.Sprintf("registry.k8s.io/conformance:%s", containerImage), - "specify a conformance container image of your choice.") + flag.StringVar(&cfg.ConformanceImage, "conformance-image", "","specify a conformance container image of your choice.") flag.StringVar(&cfg.BusyboxImage, "busybox-image", busyboxImage, "specify an alternate busybox container image.") flag.StringVar(&cfg.Kubeconfig, "kubeconfig", "", "path to the kubeconfig file.") @@ -125,12 +122,15 @@ func InitArgs() (*ArgConfig, error) { } // PrintInfo prints the information about the cluster -func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config) { +func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config, cfg *ArgConfig) { serverVersion, err := clientSet.ServerVersion() if err != nil { log.Fatal("Error fetching server version: ", err) } - containerImage = serverVersion.String() + + if cfg.ConformanceImage == "" { + cfg.ConformanceImage = fmt.Sprintf("registry.k8s.io/conformance:%s", serverVersion.String()) + } log.Printf("API endpoint : %s", config.Host) log.Printf("Server version : %#v", *serverVersion) From 0b62a9de1ebc7b1ca8f886d6beb98bc816bf9f06 Mon Sep 17 00:00:00 2001 From: Rakshit Gondwal Date: Wed, 17 Jan 2024 23:06:26 +0530 Subject: [PATCH 3/4] set var for conf imag Signed-off-by: Rakshit Gondwal --- main.go | 2 +- pkg/common/args.go | 14 ++++++++++---- pkg/service/init.go | 2 +- pkg/service/list_images.go | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index be11687..985de01 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ func main() { config, clientSet := service.Init(cfg) client.ClientSet = clientSet - common.PrintInfo(client.ClientSet, config, cfg) + common.PrintInfo(client.ClientSet, config) if cfg.ListImages { service.PrintListImages(cfg, client.ClientSet, config) diff --git a/pkg/common/args.go b/pkg/common/args.go index 353039e..3dc38c9 100644 --- a/pkg/common/args.go +++ b/pkg/common/args.go @@ -28,6 +28,9 @@ import ( "sigs.k8s.io/hydrophone/pkg/log" ) +// ConformanceImage is used to define the container image being used to run the conformance tests +var ConformanceImage string + // ArgConfig stores the argument passed when running the program type ArgConfig struct { // Focus set the E2E_FOCUS env var to run a specific test @@ -78,6 +81,7 @@ type ArgConfig struct { // InitArgs initializes the arguments passed to the program func InitArgs() (*ArgConfig, error) { + var cfg ArgConfig outputDir, err := os.Getwd() @@ -118,18 +122,20 @@ func InitArgs() (*ArgConfig, error) { return nil, fmt.Errorf("specify either --conformance or --focus arguments, not both") } + ConformanceImage = cfg.ConformanceImage + return &cfg, nil } // PrintInfo prints the information about the cluster -func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config, cfg *ArgConfig) { +func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config) { serverVersion, err := clientSet.ServerVersion() if err != nil { log.Fatal("Error fetching server version: ", err) } - if cfg.ConformanceImage == "" { - cfg.ConformanceImage = fmt.Sprintf("registry.k8s.io/conformance:%s", serverVersion.String()) + if ConformanceImage == "" { + ConformanceImage = fmt.Sprintf("registry.k8s.io/conformance:%s", serverVersion.String()) } log.Printf("API endpoint : %s", config.Host) @@ -146,7 +152,7 @@ func ValidateArgs(clientSet *kubernetes.Clientset, config *rest.Config, cfg *Arg if cfg.Skip != "" { log.Printf("Skipping tests : '%s'", cfg.Skip) } - log.Printf("Using conformance image : '%s'", cfg.ConformanceImage) + log.Printf("Using conformance image : '%s'", ConformanceImage) log.Printf("Using busybox image : '%s'", cfg.BusyboxImage) log.Printf("Test framework will start '%d' threads and use verbosity '%d'", cfg.Parallel, cfg.Verbosity) diff --git a/pkg/service/init.go b/pkg/service/init.go index bfb78fc..e305221 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -144,7 +144,7 @@ func RunE2E(clientset *kubernetes.Clientset, cfg *common.ArgConfig) { Containers: []v1.Container{ { Name: common.ConformanceContainer, - Image: cfg.ConformanceImage, + Image: common.ConformanceImage, ImagePullPolicy: v1.PullIfNotPresent, Env: []v1.EnvVar{ { diff --git a/pkg/service/list_images.go b/pkg/service/list_images.go index a0641e3..d647cf5 100644 --- a/pkg/service/list_images.go +++ b/pkg/service/list_images.go @@ -51,7 +51,7 @@ func PrintListImages(cfg *common.ArgConfig, clientSet *kubernetes.Clientset, con Containers: []corev1.Container{ { Name: common.ConformanceContainer, - Image: cfg.ConformanceImage, + Image: common.ConformanceImage, Command: []string{ "/usr/local/bin/e2e.test", "--list-images", From 0e0f32ad83c455a4e4fc69a9fb32c7f7ac859bb0 Mon Sep 17 00:00:00 2001 From: Rakshit Gondwal Date: Thu, 18 Jan 2024 03:02:42 +0530 Subject: [PATCH 4/4] fix fmt err Signed-off-by: Rakshit Gondwal --- pkg/common/args.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/args.go b/pkg/common/args.go index 3dc38c9..0185df8 100644 --- a/pkg/common/args.go +++ b/pkg/common/args.go @@ -91,7 +91,7 @@ func InitArgs() (*ArgConfig, error) { flag.StringVar(&cfg.Focus, "focus", "", "focus runs a specific e2e test. e.g. - sig-auth. allows regular expressions.") flag.StringVar(&cfg.Skip, "skip", "", "skip specific tests. allows regular expressions.") - flag.StringVar(&cfg.ConformanceImage, "conformance-image", "","specify a conformance container image of your choice.") + flag.StringVar(&cfg.ConformanceImage, "conformance-image", "", "specify a conformance container image of your choice.") flag.StringVar(&cfg.BusyboxImage, "busybox-image", busyboxImage, "specify an alternate busybox container image.") flag.StringVar(&cfg.Kubeconfig, "kubeconfig", "", "path to the kubeconfig file.")