-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Status not set correctly on Cron Job tests example #1778
Comments
Hi @EnriqueL8, Are you using the project in the docs If the above info is not enough to help you with, could you please share a snippet of the code used to perform all operations and or a link for we check your project? It might help us see what is missing. |
Hi @camilamacedo86, Thanks for the quick answer! Yes, I am using https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/cronjob-tutorial/testdata/project/testdata/project/controllers/cronjob_controller_test.go. I have pushed my changes to a branch: https://github.com/EnriqueL8/kubebuilder/tree/test_status if you want to take a look. I tried to update the object as you suggested, but also didn't get the status information correctly. See:
I am trying the same thing in my personal tests, so if I can figure out how this works here then it should also work there. |
Update: I checked the controller code and it never looks for the
Is this an antipattern to set the status of resources in order to test behaviour of controllers? For example, let's say I have a controller that creates a Pod and it is reconciling until the Pod is Ready. Once it is ready, the controller will populate the status of the resource it reconciled against to |
it was discussed in the slack; https://kubernetes.slack.com/archives/CAR30FCJZ/p1604503804366000 |
Solution! Use: |
I am trying to test a resource by creating a sub resource with a set status, as done here. Yet when I query the job as such"
I get no status field:
I expected the Status field to be populated with
Active: 2
. Can I not retrieve the status usingk8sClient.Get()
? Or do I need to add a sleep between the creation and fetch?What versions of software are you using? Specifically, the following are often useful:
kubebuilder version
) and scaffolding version (check yourPROJECT
file)/kind bug
The text was updated successfully, but these errors were encountered: