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

Wait returns exception without tearing down the KinD cluster if time-out occurs #96

Closed
helayoty opened this issue Dec 21, 2021 · 3 comments

Comments

@helayoty
Copy link
Contributor

helayoty commented Dec 21, 2021

A goroutine occurs while using wait.For(conditions.New(client.Resources()).ResourceMatch(&resultDeployment, func(object k8s.Object) bool {}
Also, the teardown in the feature step and Finish in the main step didn't execute when this error happened.

The function I tried to run:

func TestDeployment(t *testing.T) {
	deploymentFeat := features.New("Test").
		Setup(func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
			deployment := newDeployment()
			<Logic>
			return ctx
		}).
		Assess("Pods successfully deployed", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
			client, err := cfg.NewClient()
			if err != nil {
				t.Error("Failed to create new client", err)
			}
			resultDeployment := appsv1.Deployment{
				ObjectMeta: metav1.ObjectMeta{Name: "deployment-test", Namespace: cfg.Namespace()},
			}

			if err = wait.For(conditions.New(client.Resources()).DeploymentConditionMatch(&resultDeployment, appsv1.DeploymentAvailable, corev1.ConditionTrue),
				wait.WithTimeout(time.Minute*2)); err != nil {
				t.Error("deployment not found", err)
			}

			if err := wait.For(conditions.New(client.Resources()).ResourceMatch(&resultDeployment, func(object k8s.Object) bool {
				<Logic>
				return true
			}), wait.WithTimeout(time.Minute*4)); err != nil {
				t.Error("error", err)
			}
			return context.WithValue(ctx, "deployment-test", &resultDeployment)
		}).
		Teardown(func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
			client, err := cfg.NewClient()
			if err != nil {
				t.Error("failed to create new Client", err)
			}
			dep := ctx.Value("deployment-test").(*appsv1.Deployment)
			if err := client.Resources().Delete(ctx, dep); err != nil {
				t.Error("failed to delete deployment", err)
			}
			return ctx
		}).Feature()
	testenv.Test(t, deploymentFeat)
}

Error: Uploaded here

Type: Bug
Version: v0.5
KinD version: kind v0.11.1 go1.16.4 darwin/amd64

@crandles
Copy link
Contributor

I think you are seeing the output of a stack trace triggered by go test's default timeout (go test -timeout 10m).

*** Test killed with quit: ran too long (11m0s).

https://github.com/golang/go/blob/7bdbc73be1d10a9b32cb5edc6b9d0c93805f059c/src/cmd/go/internal/test/test.go#L1405
https://github.com/golang/go/blob/6df0957060b1315db4fd6a359eefc3ee92fcc198/src/cmd/go/internal/test/test.go#L323-L326

	-timeout d
	    If the cumulative test time for a package runs longer than
	    duration d, panic. Timeout is disabled if set to 0.
	    The default is 10 minutes (10m).

Also, the teardown in the feature step and Finish in the main step didn't execute when this error happened.

It does not look like any panic recovering is happening internally that would allow completion of teardown/Finish functions. Though I am not sure if it would be appropriate to execute teardown steps after a panic.

@vladimirvivien
Copy link
Contributor

@helayoty do you still feel this is bug ?

@helayoty
Copy link
Contributor Author

helayoty commented Feb 9, 2022

@helayoty do you still feel this is bug ?

No, we can close it no0w. thanks @crandles

@helayoty helayoty closed this as completed Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants