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

TestConfigMapController test flake #41419

Closed
a-robinson opened this issue Feb 14, 2017 · 14 comments
Closed

TestConfigMapController test flake #41419

a-robinson opened this issue Feb 14, 2017 · 14 comments
Assignees
Labels
kind/flake Categorizes issue or PR as related to a flaky test.
Milestone

Comments

@a-robinson
Copy link
Contributor

https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/41412/pull-kubernetes-unit/17829/#k8siokubernetesfederationpkgfederation-controllerconfigmap-testconfigmapcontroller

panic: interface conversion: interface is nil, not *v1.ConfigMap
/usr/local/go/src/runtime/panic.go:500 +0x1ae
/usr/local/go/src/testing/testing.go:579 +0x474
/usr/local/go/src/runtime/panic.go:458 +0x271
/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/configmap/configmap_controller_test.go:158 +0x74
/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/configmap/configmap_controller_test.go:140 +0x1d8b
/usr/local/go/src/testing/testing.go:610 +0xca
/usr/local/go/src/testing/testing.go:646 +0x530
@0xmichalis
Copy link
Contributor

0xf2efbd	k8s.io/kubernetes/federation/pkg/federation-controller/util/test.RegisterFakeWatch.func1+0x14d	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/util/test/test_helper.go:155
0xa2799d	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.(*controller).Run.func1+0x4d	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache/controller.go:103
0x44379e	sync.runtime_notifyListWait+0x12e														/usr/local/go/src/runtime/sema.go:267
0x4dbaed	sync.(*Cond).Wait+0x8d																/usr/local/go/src/sync/cond.go:57
0xa1c60b	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.(*DeltaFIFO).Pop+0x10b									/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache/delta_fifo.go:438
0xa187e0	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.(*controller).processLoop+0x70								/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache/controller.go:147
0xa27a21	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.(*controller).(k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.processLoop)-fm+0x41	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache/controller.go:121
0xf28a2f	k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1+0x6f								/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:96
0xf280ed	k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil+0xbd									/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:97
0xf2800a	k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.Until+0x5a										/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:52
0xa1854f	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.(*controller).Run+0x31f									/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache/controller.go:121
0xa22f02	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.(*Reflector).watchHandler+0x16e2	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache/reflector.go:350
0xa20b5b	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.(*Reflector).ListAndWatch+0xe3b	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache/reflector.go:321
0xa2817a	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.(*Reflector).RunUntil.func1+0x4a	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache/reflector.go:200
0xf28a2f	k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1+0x6f	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:96
0xf280ed	k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil+0xbd		/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:97
0xf2800a	k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait.Until+0x5a			/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:52
0xa2869d	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache.(*Reflector).ListAndWatch.func1+0x42d	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/cache/reflector.go:268
0xa5927a	k8s.io/kubernetes/federation/pkg/federation-controller/util.(*DelayingDeliverer).run+0x63a	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/util/delaying_deliverer.go:122
0xa5edf7	k8s.io/kubernetes/federation/pkg/federation-controller/util.(*DelayingDeliverer).StartWithHandler.func1+0x157	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/util/delaying_deliverer.go:174
0x49861d	testing.(*T).Run+0x56d		/usr/local/go/src/testing/testing.go:647
0x49cf09	testing.RunTests.func1+0xb9	/usr/local/go/src/testing/testing.go:793
0x498039	testing.tRunner+0xc9		/usr/local/go/src/testing/testing.go:610
0x4999fa	testing.RunTests+0x4ba		/usr/local/go/src/testing/testing.go:799
0x498bcf	testing.(*M).Run+0x12f		/usr/local/go/src/testing/testing.go:743
0x401428	main.main+0x1b8			k8s.io/kubernetes/federation/pkg/federation-controller/configmap/_test/_testmain.go:54
0x43122c	runtime.main+0x18c		/usr/local/go/src/runtime/proc.go:183
0x4a96bd	k8s.io/kubernetes/federation/pkg/federation-controller/configmap.(*ConfigMapController).Run.func1+0x4d	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/configmap/configmap_controller.go:238
0x5e2c02	k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/watch.(*Broadcaster).loop+0x92	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/watch/mux.go:201
0xa309d5	k8s.io/kubernetes/vendor/k8s.io/client-go/tools/record.(*eventBroadcasterImpl).StartEventWatcher.func1+0xc5	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/tools/record/event.go:228
0xf22f1d	k8s.io/kubernetes/vendor/github.com/golang/glog.(*loggingT).flushDaemon+0x9d	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/github.com/golang/glog/glog.go:879
0xa5ec86	k8s.io/kubernetes/federation/pkg/federation-controller/util.StartBackoffGC.func1+0x126	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/util/backoff.go:28
0x55725d	runtime/pprof.writeRuntimeProfile+0xbd								/usr/local/go/src/runtime/pprof/pprof.go:614
0x556ff9	runtime/pprof.writeGoroutine+0xc9								/usr/local/go/src/runtime/pprof/pprof.go:576
0x55287d	runtime/pprof.(*Profile).WriteTo+0x47d								/usr/local/go/src/runtime/pprof/pprof.go:298
0xf2ec46	k8s.io/kubernetes/federation/pkg/federation-controller/util/test.GetObjectFromChan+0x1b6	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/util/test/test_helper.go:248
0x4a7e3c	k8s.io/kubernetes/federation/pkg/federation-controller/configmap.GetConfigMapFromChan+0x3c	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/configmap/configmap_controller_test.go:164
0x4a758a	k8s.io/kubernetes/federation/pkg/federation-controller/configmap.TestConfigMapController+0x1d8a	/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/configmap/configmap_controller_test.go:146
0x498039	testing.tRunner+0xc9										/usr/local/go/src/testing/testing.go:610
<autogenerated>:10: 
                        
	Error Trace:	configmap_controller_test.go:147
	
	Error:		Expected value not to be nil.
	
panic: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:500 +0x1ae
/usr/local/go/src/testing/testing.go:579 +0x474
/usr/local/go/src/runtime/panic.go:458 +0x271
/go/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/federation/pkg/federation-controller/configmap/configmap_controller_test.go:148 +0x1e2e
/usr/local/go/src/testing/testing.go:610 +0xca

Seems like a different failure mode
https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/42480/pull-kubernetes-unit/21387/

@0xmichalis
Copy link
Contributor

@kubernetes/sig-federation-bugs who owns this test?

@0xmichalis
Copy link
Contributor

Also a different failure mode again in #39567

@nikhiljindal
Copy link
Contributor

cc @mwielgus who wrote the test and @csbell who is the last one to change it

@ethernetdan
Copy link
Contributor

@nikhiljindal @Kargakis @csbell is this issue release blocking? If not, please remove from 1.6 milestone

@marun
Copy link
Contributor

marun commented Mar 15, 2017

I think this can be moved out of 1.6. It's a unit test problem, not a regression in functionality. There is an integration test pending that verifies the same functionality in a more realistic way (#43125).

@csbell
Copy link
Contributor

csbell commented Mar 15, 2017

@perotinus you had also been looking into this. Can you give your opinion by 1PM PDT so we can triage it before the 1.6 burndown?

@perotinus
Copy link
Contributor

I think this can be removed from 1.6; the flakiness that I've been tracking down is similar to this, so it doesn't appear to be a regression.

Note that the flake described specifically by this issue is different from the ones I've been debugging, though #39567 seems similar to one of them. It looks like there are three classes of flakes happening:

@ethernetdan
Copy link
Contributor

Moving from 1.6 as appears known flake.

@ethernetdan ethernetdan modified the milestones: v1.7, v1.6 Mar 15, 2017
@marun
Copy link
Contributor

marun commented Mar 15, 2017

@perotinus I think the configmap unit test should be removed in favor of the integration test proposed by #42025. I don't see the benefit to debugging and/or rewriting a bad unit test when the functionality in question could be better tested in integration anyway. Also, I'm intending the generic controller refactor (#41050) to include unit testing of corner cases not covered by the existing unit test or the proposed integration test.

@madhusudancs
Copy link
Contributor

I am not entirely sure how integration tests have a greater benefit than unit tests. They all serve different purposes. Unit tests test the controller code paths in the absence of other components or faked components. Integration tests test the same code paths but with the other components actually running. More room for flakiness. Unit tests don't need etcd, don't need underlying clusters' API servers to be running whereas integration tests do. One of the real benefits in having unit tests is to have a faster debug cycles and more predictability. Unit tests should be less flaky than integration tests. If they are not, we should invest time in fixing them rather than deleting them. Integration tests can fail for reasons not in our control. Example, etcd failure or some such, but unit tests are immune to those types of failures.

@perotinus
Copy link
Contributor

I agree with @madhusudancs that there is definite value in unit tests. I'm not familiar enough with the project to really have a good sense for whether the current suites of unit tests for the federation controllers are really the right tests. I prefer unit tests to integration tests (and integration tests to e2e tests), and I believe that these flaky unit tests are helping to reveal issues with the way our controllers work and mismatches between what we think they do and what they actually do, which is valuable.

@marun
Copy link
Contributor

marun commented Mar 16, 2017

@madhusudancs @perotinus I'm not sure how my statement about the configmap unit test gave you the impression that I think integration_tests > unit_tests. Yes, I think a golden-path integration test for the configmap controller is preferable to the existing unit test, since the same functionality is tested but with real components instead of having to fake them out. But unit tests are the base of the 'testing pyramid' that I'm always harping on. I always prefer to test at the lowest possible level of abstraction:

https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html

I do not think the current 'unit' tests for the federation controllers - including the one in question for the ConfigMap controller - typify good unit testing. They are brittle and prone to race conditions due to the way they attempt to fake out the api server. I think the flakiness is more a reflection of the test design than the functionality under test. There's also the issue of the monolithic nature of the existing tests - 100-200 lines each but providing relatively poor coverage due to targeting the controller as a whole rather than individual code paths. So yes, I think most of the coverage provided by the existing unit tests for the federation controllers can be better provided by the integration testing I'm proposing.

And yes, I think better unit tests need to be written for the controllers. That will require refactoring the controllers to make such an effort tractable. The reconcile methods have too many dependencies and too many branches. And since the current controllers duplicate code instead of reusing it, the test surface is too large to justify providing good coverage for all of them individually. My proposal (starting with #41050) is to factor out the comment elements and ensure that the bulk of functionality can be targeted once rather than per-controller. Then type-specific functionality (e.g. ingress ip assignment, replicaset and deployment scheduling) can be targeted separately.

@madhusudancs
Copy link
Contributor

@madhusudancs @perotinus I'm not sure how my statement about the configmap unit test gave you the impression that I think integration_tests > unit_tests.

Honestly, I don't know how else to interpret #41419 (comment) even after reading your clarification above.

But anyway, without digressing, I agree with your point that our current testing of controllers as a whole in unit tests is sub-optimal given the way we setup fakes. But if you look at the general design of federated controllers, the bulk of the work is just replicating the objects in different API servers with some additional logic in some controllers. You can't just ignore the bulk of the work. But if that functionality is tested in a generic controller unit tests then that's fine.

k8s-github-robot pushed a commit that referenced this issue Mar 18, 2017
Automatic merge from submit-queue

Fix federated config map unit tests

Fixes #41419 and #42847 and possibly other issues in this area.

cc: @nikhiljindal @csbell @perotinus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/flake Categorizes issue or PR as related to a flaky test.
Projects
None yet
Development

No branches or pull requests