Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a custom wait duration for kwok provider #478

Open
liam-mackie opened this issue Jan 14, 2025 · 2 comments · May be fixed by #479
Open

Allow a custom wait duration for kwok provider #478

liam-mackie opened this issue Jan 14, 2025 · 2 comments · May be fixed by #479
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@liam-mackie
Copy link

What do you want to see?

When a kwok cluster is instantiated using the default NewProvider() method, the cluster has no wait time defined. This may cause race conditions (though we only saw this happening on Windows and MacOS machines, not Linux).

Currently, to work around this and still use envfuncs.CreateClusterWithConfig(), you can create a custom cluster first:

func TestMain(m *testing.M) {
	cfg, err := envconf.NewFromFlags()
	if err != nil {
		log.Fatalf("envconf failed: %s", err)
	}
	testenv = env.NewWithConfig(cfg)
	kwokClusterName := envconf.RandomName("kwok-cluster", 16)
	namespace := envconf.RandomName("kwok-ns", 16)

	testenv.Setup(
		envfuncs.CreateClusterWithConfig(customKwokProvider(), kwokClusterName, "kwok-config.yaml"),
		envfuncs.CreateNamespace(namespace),
	)

	testenv.Finish(
		envfuncs.ExportClusterLogs(kwokClusterName, "./logs"),
		envfuncs.DeleteNamespace(namespace),
		envfuncs.DestroyCluster(kwokClusterName),
	)
	os.Exit(testenv.Run(m))
}

func customKwokProvider() support.E2EClusterProvider {
	return kwok.NewCluster("")
}

kwok.NewCluster() sets a default wait time of 1 minute, which is enough for most scenarios we've tested. That being said, it would be great to use ClusterOpts to set the duration instead. An example of how it might look in the same situation is:

func TestMain(m *testing.M) {
	cfg, err := envconf.NewFromFlags()
	if err != nil {
		log.Fatalf("envconf failed: %s", err)
	}
	testenv = env.NewWithConfig(cfg)
	kwokClusterName := envconf.RandomName("kwok-cluster", 16)
	namespace := envconf.RandomName("kwok-ns", 16)

	testenv.Setup(
		envfuncs.CreateClusterWithConfig(kwok.NewProvider().WithOpts(kwok.WithWaitDuration(1*time.Minute)), kwokClusterName, "kwok-config.yaml"),
		envfuncs.CreateNamespace(namespace),
	)

	testenv.Finish(
		envfuncs.ExportClusterLogs(kwokClusterName, "./logs"),
		envfuncs.DeleteNamespace(namespace),
		envfuncs.DestroyCluster(kwokClusterName),
	)
	os.Exit(testenv.Run(m))
}

Extra Labels

No response

@liam-mackie liam-mackie added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 14, 2025
@liam-mackie liam-mackie linked a pull request Jan 14, 2025 that will close this issue
@vladimirvivien
Copy link
Contributor

cc @harshanarayana what do you think, this sounds sensible.

@harshanarayana
Copy link
Contributor

+1 Sounds like a good thing to have considering that the default duration is pretty small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants