-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Abstract Command Client #10992
Abstract Command Client #10992
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cc |
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 @xpivarc Some comments below
@@ -50,6 +50,10 @@ type PodIsolationDetector interface { | |||
|
|||
DetectForSocket(vm *v1.VirtualMachineInstance, socket string) (IsolationResult, error) | |||
|
|||
// Detects if there is a Pod on the host for given vm | |||
// Returns error otherwise | |||
DetectPod(vmi *v1.VirtualMachineInstance) error |
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.
Shouldn't this return the socketPodDir
, error otherwise?
Otherwise I would tend to switch to something like:
DoesPodExists(vmi *v1.VirtualMachineInstance) (bool, error)
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.
The socketPodDir
is unused. In fact FindPodDirOnHost
is now only used once, here.
I thought about (bool, error)
but I am not sure if there is any value. For now, I like that it preserves the behavior and I don't need to add additional coverage.
I am open to suggestions for names but I do reserve to keep the logic in this PR as close as it was and only follow up with improvements to the logic once we cover this with more unit 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.
It's ok to me to leave the things as you proposed, with the promise that FindPodDirOnHost
will be refactored in the future to drop the socketPodDir
, if is not needed at all.
IOW my only concern is that we will forget that FindPodDirOnHost
is returning an unused value.
} | ||
|
||
func (cm *clientManager) Socket(vmi *v1.VirtualMachineInstance) (string, error) { | ||
return FindSocketOnHost(vmi) |
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.
Could the socket path found inCreate()
be saved as a member and returned here?
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.
This would require also cleaning it later. I have reverted the first commit to a simpler solution, please revisit.
As of now we directly search the filesystem to find the socket and then initialize a client for the command server in the launcher. This is harder to test and change than it could be. This commit encapsulates this into a simple yet effective abstraction. The next step will be to use this abstraction in all places that require the command client. Signed-off-by: Luboslav Pivarc <lpivarc@redhat.com>
FindPodDirOnHost is a simple function that goes through the file system to determine if there is a Pod for a given VMI. This direct approach makes testing problematic and therefore we are extending the Isolation Detector to cover this logic instead. Signed-off-by: Luboslav Pivarc <lpivarc@redhat.com>
@fossedihelm @orelmisan 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.
Thanks @xpivarc!
I like the new simplified logic in the first commit.
One small last nit :)
* | ||
* Copyright 2023 The KubeVirt Authors. | ||
* | ||
*/ |
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.
nit: missing newline
(sorry to be pedantic) 🙂
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 adjust if any changes are requested.
Please, also, adjust the PR description with the new function name for |
Done |
/lgtm |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@xpivarc: The following tests failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with /lifecycle stale |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with /lifecycle rotten |
Pull requests that are marked with After that period the bot marks them with the label /label needs-approver-review |
@kubevirt-bot: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Rotten issues close after 30d of inactivity. /close |
@kubevirt-bot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/remove-label needs-approver-review |
What this PR does / why we need it:
This PR is abstracting two things.
The first being is the creation of a client for the Command Server. The following interface is introduced:
This allows us to write simpler tests in the future and resue one implementation in multiple places (search for
FindSocketOnHost
).The second thing that is handled here is the usage of
FindPodDirOnHost
which has the same drawbacks. For this, we simply extendPodIsolationDetector
, see below:Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Note: This PR doesn't convert everything into a new abstraction and does not leverage it for tests. This will be follow-up work. The implementation is almost identical to the old one. We use the real implementation for the tests and that ensures we do not break tests and production code as well.
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note: