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
fix(k8s): handle AEC-paused resources properly #5122
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.
Overall looks good, but i think we might be using the wrong annotation key.
|
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.
Super quick turnaround!
* refactor: extract named function for manifest post-processing * refactor: split manifest reading and post-processing * fix(k8s): correctly resolve manifests when `build` is set * fix(k8s): quickfix to avoid resetting `outdated` state to `ready` * test: fix tests * refactor(test): move helper to the upper-level scope It will be used by other test contexts. * refactor(test): introduce one more convenience helper * refactor(test): introduce and rename some local vars * refactor(test): use helpers to avoid code duplication * chore: re-arranged code Keep all helpers close to each other for simpler navigation. * chore(test): rename some tests and variables To avoid usage of the old glossary. * refactor(test): helper function to deploy in namespaces * DRY to avoid repetition and too complex local state * Less shared global state between different test contexts * Avoid dependencies between tests and reliance on the execution order * Ability to run individual tests locally * refactor(test): convert lambdas to functions * test: ensure all resources are deleted by `deleteKubernetesDeploy` A metadata `ConfigMap` describing what was last deployed must be deleted too. * test: restore initial module config state after each test To avoid unexpected pollution of the Garden instance's state. Multiple test can define temporary custom module config. Such config changes should not affect the other tests. * refactor(k8s): helper to compose k8s deploy status * refactor(k8s): return deploy status immediately on "missing" state * refactor: unwrap unnecessary else-block * chore: variable scoping * refactor: extract helper to check if deploy is outdated * refactor: move input args check into `getForwardablePorts` * chore: remove unnecessary code and comments Local mode checks were moved to `getForwardablePorts` in #5022. * chore: remove unnecessary try/catch Function `getForwardablePorts` does not call any potentially unsafe operations. It's not wrapped into try/catch in the other code places. * chore: remove unused local var * refactor: use SRP in status calculation Split individual resource status retrieval and overall state calculation. * refactor: simplified code Minimized mutability of the local vars. More straightforward and linear processing flow. * test: fix test setup to cover the original bug * chore: post-merge corrections * refactor: remove unnecessary function call The value has already been calculated as an immutable value. * chore: typos and wording Got rid of old-fashioned term "service". Replaced it with "deploy". --------- Co-authored-by: Jon Edvald <edvald@gmail.com>
b483afc
b483afc
to
4569244
Compare
This is a follow-up quickfix for #4846. It reads a specific annotation and checks if it has a special value set by Cloud. This needs to be changed to reply on a more generic and reliable way of k8s resource comparison.
To avoid repetitive creation of the same immutable string.
e15a682
to
f2f2704
Compare
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.
Great work! 👍
I think we need to still make sure that deploy -f
always deploys even when the deploy is ready
already; But that can be done in a separate PR.
@vvagaytsev Some of the tests are failing. I wonder if those are due to the manifest hash check you added. |
@shumailxyz thanks! I see, that's because of the annotation change. The tests share the same in-cluster resource. After the new test is executed, I'll ensure that everything is reverted back to the normal state. @stefreak thanks! Yes, let's address the |
Because `Regex` is a stateful object.
} finally { | ||
// Redeploy the resource to restore the original value of `k8sManifestHashAnnotationKey` annotation, | ||
// because the remote resource state is used by the other tests. | ||
await kubernetesDeploy(deployParams) |
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 understand if that's a bigger change and you want to do it separately; But would it be better to run kubernetesDeploy
in a beforeEach
in a group for all the tests that rely on it being deployed?
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.
seeing try {} finally {}
in a test is strange when mocha provides before
and after
primitives for these kinds of things
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.
That requires more changes and re-grouping of the tests. We can do it later if we have more tests that modify remote resources that should be re-deployed on the test completion.
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 added a dedicated config for this test case in 75c1b24.
Now we don't need to restore the remote resource state used by the other tests.
To avoid unwanted modifications of the remote resources used by the other tests.
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.
👍
core/test/integ/src/plugins/kubernetes/kubernetes-type/handlers.ts
Outdated
Show resolved
Hide resolved
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.
Awesome 💯
Just a typo that i found.
07d32c6
Co-authored-by: Shumail Mohyuddin <shumailmohyuddin@gmail.com>
What this PR does / why we need it:
A follow-up fix for #4846 to address @stefreak 's comment on the AEC.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
The commit-by-commit review might be easier :)