-
Notifications
You must be signed in to change notification settings - Fork 810
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
Encapsulate Recover of controllers #1014
Conversation
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
… into refine-recover
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
No that does not effect the encapsulation, #788 didn't make difference, and the difference resulting from #892 is coming from only change one of managers but forget the other one. |
Maybe I should also try to make a |
Sure I think we could wait until that time to update this part |
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #1014 +/- ##
==========================================
- Coverage 55.78% 52.15% -3.63%
==========================================
Files 68 78 +10
Lines 4383 4918 +535
==========================================
+ Hits 2445 2565 +120
- Misses 1768 2095 +327
- Partials 170 258 +88
Continue to review full report at Codecov.
|
Hi @YangKeao is the current implementation what we want |
/run-e2e-tests |
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Hi @YangKeao PTAL |
Actually, I don't think generating all codes through a generator is a good idea. Only small parts of them (such as some getter or setter) should be done by code generation. We can analyze the problem like this: To implement Only some of these requirements should be generated through the code generator (e.g. the |
Yeah it's actually also weird for me, to "generate" this large block of code that contains some logic. But since we could easily get/set finalizer so just only generate this part could not remove much duplicated code. I have another idea (still a bit weird) that to build a common func (e *endpoint) Recover(ctx context.Context, req ctrl.Request, chaos v1alpha1.InnerObject) error {
stressChaos, ok := chaos.(*v1alpha1.StressChaos)
finalizers, err := cleanFinalizersAndRecover(ctx, e, chaos, stressChaos.Finalizers, stressChaos.Annotations[common.AnnotationCleanFinalizer])
stressChaos.Finalizers = finalizers
}
// the common one
func cleanFinalizersAndRecover(ctx context.Context, e *endpoint, chaos v1alpha1.InnerObject, finalizers []string, forceClean string) error {
...
err = e.recoverPod(ctx, &pod, chaos)
...
}
// do another type assertion in recoverPod
func (e *endpoint) recoverPod(ctx context.Context, pod *v1.Pod, chaos *v1alpha1.StressChaos) error {
stressChaos, ok := chaos.(*v1alpha1.StressChaos)
...
} |
@Yiyiyimu We can ignore the A straightforward plan could be defining a trait And automatically implement But how to combine it with |
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
@cwen0 it seems the test goes stable now. PTAL |
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
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.
Rest LGTM
controllers/dnschaos/types.go
Outdated
|
||
func (r *endpoint) recoverPod(ctx context.Context, pod *v1.Pod) error { | ||
r.Log.Info("Try to recover pod", "namespace", pod.Namespace, "name", pod.Name) | ||
r.cancelDNSServerRules(service.Spec.ClusterIP, config.ControllerCfg.DNSServicePort, chaos.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.
We don't need to run this function in each pod.
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.
Fixed. Thanks!
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
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.
LGTM
@YangKeao PTAL |
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.
LGTM
/merge |
/run-all-tests |
@Yiyiyimu merge failed. |
/merge |
/run-all-tests |
@Yiyiyimu merge failed. |
/run-e2e-tests |
/merge |
Your auto merge job has been accepted, waiting for:
|
/run-all-tests |
Signed-off-by: yiyiyimu wosoyoung@gmail.com
What problem does this PR solve?
fix #961, currently only encapsulate chaos w/o managers.
What is changed and how does it work?
Add a common
CleanFinalizersAndRecover
which implemented for a new struct.Checklist
Tests
Does this PR introduce a user-facing change?