-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Timeout waiting for process kube-apiserver to stop #1571
Comments
using 1.20.2 for example works fine |
+1, hit the same issue and using 1.20 binaries works fine. |
+1, I also tested with the 1.22 binaries, and still same issue. It would be nice if someone with the skills could take a look ASAP. 😉 /priority important-soon |
I'm not able to reproduce this issue with the envtest 1.22.0 binaries and controller-runtime v0.9.6. To try to reproduce, I bumped to the latest k8s, envtest, and c-r versions here |
Tested using the cronjob-tutorial, results as follows:
So, looks like issue in Kubernetes v1.21, v1.22. |
This is what I have found so far. From Kubernetes 1.21+, when it tries to cleanup the test environment, there is a clash if a custom controller is created during testing. It would seem that the controller is still running and I can get it to work by, changing controller goroutine: go func() {
err = k8sManager.Start(ctrl.SetupSignalHandler())
Expect(err).ToNot(HaveOccurred())
}() to: go func() {
defer GinkgoRecover()
err = k8sManager.Start(ctrl.SetupSignalHandler())
Expect(err).ToNot(HaveOccurred(), "failed to run manager")
gexec.KillAndWait(4 * time.Second)
// Teardown the test environment once controller is fnished.
// Otherwise from Kubernetes 1.21+, teardon timeouts waiting on
// kube-apiserver to return
err := testEnv.Stop()
Expect(err).ToNot(HaveOccurred())
}() and disabling the teardown in |
Is it a mistake that the |
Thx @tenstad! I think this issue can ble closed, as not a problem (here), ref. cybozu-go/coil#189. I will prepare a PR to fix the skaffolding (and doc) in kubebuilder, ref. the workaround implemented in kubernetes-sigs/kubebuilder#2302. CC: @hickeyma |
Wondering if |
I think the problem source is a pending watch request, initiated by the controller after To avoid the error, one must thus avoid sending watch requests after SIGTERMing the apiserver,
1 will avoid sending requests to the terminating apiserver, IMO, 1 is the cleanest solution. It is already implemented in kubernetes-sigs/kubebuilder#2379. A context that is canceled in FYI: I am not experienced with this codebase and the core of k8s, please do not take these as hard facts without verifying yourself. |
Need to cancel the context. It is discussed in kubernetes-sigs/controller-runtime#1571 (comment).
Need to cancel the context. It is discussed in kubernetes-sigs/controller-runtime#1571 (comment).
* Add multigroup structure to apis Move controllers to multigroup struct, refactor some testing Fix create-clientconfig Rename apis/core to apis/k8ssandra * fix api server timeouts during shutdown Need to cancel the context. It is discussed in kubernetes-sigs/controller-runtime#1571 (comment). Co-authored-by: John Sanda <john.sanda@gmail.com>
This cancels the context to cause the API server to properly shut down at the conclusion of the tests. Ref: kubernetes-sigs/controller-runtime#1571 Ref: kubernetes-sigs/kubebuilder#2379 Signed-off-by: John Strunk <jstrunk@redhat.com>
Hi, guys. Hit the same issue here with I have been try to add the In my situation it looks like the watch mechanism is pending by the server.
|
I know this is not a solution, if anyone hit same issue like me. This may work for you, I try the solution above, migrate the
|
issue: kubernetes-sigs/controller-runtime#1571 Signed-off-by: Sebastian Sch <sebassch@gmail.com>
issue: kubernetes-sigs/controller-runtime#1571 Signed-off-by: Sebastian Sch <sebassch@gmail.com>
issue: kubernetes-sigs/controller-runtime#1571 Signed-off-by: Sebastian Sch <sebassch@gmail.com>
issue: kubernetes-sigs/controller-runtime#1571 Signed-off-by: Sebastian Sch <sebassch@gmail.com>
issue: kubernetes-sigs/controller-runtime#1571 Signed-off-by: Sebastian Sch <sebassch@gmail.com>
Reference issue: kubernetes-sigs/controller-runtime#1571
- go@1.19 - hermit - linter (and configuration so things pass) - kubebuilder Makefile (so it's consistent with changes) - fixed tests kubernetes-sigs/controller-runtime#1571 - controller-runtime@0.11.1
issue: kubernetes-sigs/controller-runtime#1571 Signed-off-by: Sebastian Sch <sebassch@gmail.com>
For the impatient: err := (func() (err error) {
// Need to sleep if the first stop fails due to a bug:
// https://github.com/kubernetes-sigs/controller-runtime/issues/1571
sleepTime := 1 * time.Millisecond
for i := 0; i < 12; i++ { // Exponentially sleep up to ~4s
if err = testEnv.Stop(); err == nil {
return
}
sleepTime *= 2
time.Sleep(sleepTime)
}
return
})()
Expect(err).NotTo(HaveOccurred()) |
The test works fine but for some reason the AfterSuite tear down function isn't working as expected. It times out after trying to shut down the API server. The test comes back as passed but because the API server won't shut down in time, `make test` fails. kubernetes-sigs/controller-runtime#1571
As reported in kubernetes-sigs/controller-runtime#1571, not doing this can cause timeout errors waiting for kube-apiserver to stop.
Maybe if someone still encounters this problem - setting testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{
filepath.Join("..", "..", "config", "crd", "bases"),
},
ErrorIfCRDPathMissing: true,
ControlPlaneStopTimeout: 1 * time.Minute, // Or any duration that suits your tests
} |
This works for me. |
What happened:
envtest.Environment.Stop()
raises the errortimeout waiting for process kube-apiserver to stop
with kube-apiserver 1.21.2 that set up usingsetup-envtest use -p env
.How to reproduce it (as minimally and precisely as possible):
Run this envtest with kube-apiserver 1.21.2.
Environment:
The text was updated successfully, but these errors were encountered: