-
Notifications
You must be signed in to change notification settings - Fork 85
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
feat: add lazy loading kubeconfigs for Test Steps #540
feat: add lazy loading kubeconfigs for Test Steps #540
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
Please see the comments inline.
Also, could you please either add an automated test, or if (likely) this will be difficult, then paste how the kuttl output looks like in case the lazy loading fails (perhaps in comparison to how it fails eagerly now).
4d07acc
to
37c107a
Compare
Hi @porridge , thanks for the quick review. I've incorporated your comments. I found it a little difficult to add tests for this. For now, I've updated the PR description with the outputs comparing the failures to load lazily on |
I see the CRDs are in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I don't see the failed to lazy-load kubeconfig
string in the ouput you pasted? Was the code changed after you copied? Can you please update them?
As for the CRDs, they seem to have gone stale. I didn't even know they were there 😅
If you could file a bug to remind us to fix generation and check their freshness in CI, that would be great.
This is almost good to go, just a few more nitpicks.
Apologies, I seem to have mixed up the outputs. I've updated them now.
Oh, okay.
Opened #541. |
pkg/test/case.go
Outdated
} | ||
} | ||
|
||
errs = append(errs, testStep.Run(test, ns.Name)...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed in the output that we're getting the error twice now:
case.go:392: failed to lazy-load kubeconfig "/Users/kumarmallikarjuna/Workspace/kuttl/lazy_test/lazy/loading/test.kubeconfig": stat /Users/kumarmallikarjuna/Workspace/kuttl/lazy_test/lazy/loading/test.kubeconfig: no such file or directory
case.go:392: stat /Users/kumarmallikarjuna/Workspace/kuttl/lazy_test/lazy/loading/test.kubeconfig: no such file or directory
I guess this is because we Run
the step on this line regardless of whether the lazy loading succeeded or not 😟
However looking deeper into this I realized a few more problems that I didn't see earlier, sorry:
- the conditional creation of a client on line 377 is mostly redundant since we already prepare one on line 364,
- more importantly, we're failing to create a namespace for lazy-loaded clients, I think we should replace the block 377-382 with one that creates a namespace if it hasn't been done eagerly (not sure how to do this elegantly and robustly, but I'm sure you can come up with something 😉 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed in the output that we're getting the error twice now:
case.go:392: failed to lazy-load kubeconfig "/Users/kumarmallikarjuna/Workspace/kuttl/lazy_test/lazy/loading/test.kubeconfig": stat /Users/kumarmallikarjuna/Workspace/kuttl/lazy_test/lazy/loading/test.kubeconfig: no such file or directory case.go:392: stat /Users/kumarmallikarjuna/Workspace/kuttl/lazy_test/lazy/loading/test.kubeconfig: no such file or directory
I guess this is because we
Run
the step on this line regardless of whether the lazy loading succeeded or not 😟
Fixed here: 75eb6a9. I've skipped the test setup from running in-case the kubeconfig setup fails.
However looking deeper into this I realized a few more problems that I didn't see earlier, sorry:
- the conditional creation of a client on line 377 is mostly redundant since we already prepare one on line 364,
- more importantly, we're failing to create a namespace for lazy-loaded clients, I think we should replace the block 377-382 with one that creates a namespace if it hasn't been done eagerly (not sure how to do this elegantly and robustly, but I'm sure you can come up with something 😉 )
Totally missed that. Since, the namespace is created for each eager client, I've replicated that and placed the logic right after the lazy-client is created:
82fe683.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible edge case here: the Kubeconfigs are common b/w steps or the same as the global one. In that case, the namespace would attempt to be re-created and its failure would keep the test from evaluating. I'll add an additional check.
Added it here: ab07d9a.
Also please take a look at the failing checks. |
Signed-off-by: Kumar Mallikarjuna <[email protected]>
Signed-off-by: Kumar Mallikarjuna <[email protected]>
Signed-off-by: Kumar Mallikarjuna <[email protected]>
Signed-off-by: Kumar Mallikarjuna <[email protected]>
Signed-off-by: Kumar Mallikarjuna <[email protected]>
Signed-off-by: Kumar Mallikarjuna <[email protected]>
Signed-off-by: Kumar Mallikarjuna <[email protected]>
Signed-off-by: Kumar Mallikarjuna <[email protected]>
The transformation from "" -> "Eager" is confusing. Removing it since both trigger "Eager" evaluation. Signed-off-by: Kumar Mallikarjuna <[email protected]>
Signed-off-by: Kumar Mallikarjuna <[email protected]>
f600a92
to
e7f1165
Compare
What this PR does / why we need it:
This PR adds an attribute
LazyLoadKubeconfig
to theTestStep
type which can be used to configure whether theKubeconfig
specified in theTestStep
needs to be lazy-loaded, i.e., if theKubeconfig
doesn't need to be loaded at the start of theTestCase
eval.Fixes #539
Tests
eager/loading/00-teststep.yaml
:lazy/loading/00-teststep.yaml
:Output on
main
:Output after these changes:
Lazy-loading when the Kubeconfig exists and is same as the global Kubeconfig: