Skip to content
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

KV provider #1230

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

KV provider #1230

wants to merge 8 commits into from

Conversation

aerosouund
Copy link
Member

What this PR does / why we need it:

Create the KubevirtProvider type and make it the main entity for cluster actions

Part of: #1110

Special Notes
This branch is based off opts. PR: #1217
it introduces the same commits but after opts gets merged it will only introduce commits of the kubevirt provider

Checklist

Release note:

Create kubevirt provider, move run and provision logic to it

@kubevirt-bot kubevirt-bot added the dco-signoff: yes Indicates the PR's author has DCO signed all their commits. label Jul 23, 2024
@kubevirt-bot
Copy link
Contributor

Hi @aerosouund. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign awels for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@aerosouund
Copy link
Member Author

@aerosouund aerosouund changed the title Kv provider KV provider Jul 28, 2024
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 2, 2024
@aerosouund aerosouund mentioned this pull request Aug 14, 2024
8 tasks
@kubevirt-bot kubevirt-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 18, 2024
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 23, 2024
Two new opts that represent the two scripts used in the provision phase (provision linux and provision k8s).
Using go embed to include any necessary config files then run the commands on a node using libssh

Signed-off-by: aerosouund <aerosound161@gmail.com>
The KubevirtProvider is a struct representing an arbitrary Kubevirtci running cluster.
It holds all config flags and options that are in the run and provision commands.
A Kubevirt provider can be created in two ways, by creating a cluster using the Start method, or from
an already running cluster.
For this to be possible then json representation of the struct is persisted on the dnsmasq container and later read to parse
the deployed settings
Or through the normal constructor which uses the option pattern to avoid a bloated function signature

The logic that was previously in run.go has been split to several methods to facilitate readability and testing (runNFSGanesha, runRegistry, prepareQemuCmd, prepareDeviceMappings)
and dnsmasq creation logic got moved to its own method instead of existing in its own package

Floating methods such as waitForVMToBeUp, nodeNameFromIndex, nodeContainer.. etc were grouped to be methods of the struct

Signed-off-by: aerosouund <aerosound161@gmail.com>
@dhiller
Copy link
Contributor

dhiller commented Aug 26, 2024

/test all

@kubevirt-bot
Copy link
Contributor

@aerosouund: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
check-provision-k8s-1.29 28752d9 link true /test check-provision-k8s-1.29
check-provision-k8s-1.30 28752d9 link true /test check-provision-k8s-1.30
check-up-kind-1.27-vgpu 28752d9 link false /test check-up-kind-1.27-vgpu
check-up-kind-1.30-vgpu 28752d9 link false /test check-up-kind-1.30-vgpu
check-provision-k8s-1.31 28752d9 link true /test check-provision-k8s-1.31
check-provision-k8s-1.28 28752d9 link true /test check-provision-k8s-1.28

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. I understand the commands that are listed here.

To avoid having to read each flag and return an error if its unset leverage the FlagMap, a map of flag name to FlagConfig.
a FlagConfig is the type of this flag (string, int, uint16, bool or array of string) and the option function that sets the value
of this flag on the KubevirtProvider struct.
During parsing of flags this map is being iterated on and each option gets appended to an array to later be used in the KubevirtProvider constructor.

The run method's role is now to parse the flags and pass them to the provider and just call Start.
All the floating methods in run.go are removed after being moved to the provider.

Signed-off-by: aerosouund <aerosound161@gmail.com>
This functionality now exists in the KubevirtProvider type and doesn't need a package of its own

Signed-off-by: aerosouund <aerosound161@gmail.com>
The KubevirtProvider type is what provides the methods that run a node or run the k8s options.
Testing logic has been moved to a Base Provider Suite

Signed-off-by: aerosouund <aerosound161@gmail.com>
Implement provisioning logic on the provider and leverage the linux and k8s provisioning instead of the scripts.
Leverage the same pattern of creating an unpriviliged sshClient to add the ssh key to the root user then use a priviliged client.
Include a map of version major, minor to a version with major, minor and patch to pass it to the provisionk8s opt.

Remove unwanted floating methods such as _cmd, performPhase and implement copyDirectory as a method of the provider type.
Change provision.go command to call the Provision method.
Change type of port flags to uint16 to match the struct type.
Change default value of random-ports to true.

THIS COMMIT BREAKS THE KUBEVIRTCI RELEASE AND VERSIONING PATTERNS

Signed-off-by: aerosouund <aerosound161@gmail.com>
Signed-off-by: aerosouund <aerosound161@gmail.com>
@aerosouund
Copy link
Member Author

aerosouund commented Aug 26, 2024

I think a reason for this flake, the one where the CI job keeps waiting on the node to stop is that the node shuts down before reporting the status back to the ssh agent which makes it not know whether this happened or no

this code previously looked like this

_cmd(cli, nodeContainer(prefix, nodeName), "ssh.sh sudo shutdown now -h", "shutting down the node")

and now it looks like this (this PR introduces this change)

    if err = sshClient.Command("sudo shutdown now -h"); err != nil {
        return err
    }

which results in a golang error, since previously the error wasn't being handled

failed to execute command: sudo shutdown now -h

and so what i suggest we do is that we don't handle the error, i don't know if we also need to force the code to continue executing after a certain duration but this may not be necessary. since previously when ssh.sh would fail the gocli wouldn't get this failure and the CI run hangs. but since we now ssh directly its guaranteed that if there's an error you will get it

I will push a commit with this suggestion

Signed-off-by: aerosouund <aerosound161@gmail.com>
@kubevirt-bot
Copy link
Contributor

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-sigs/prow repository.

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 9, 2024
@@ -0,0 +1,6 @@
[isv_kubernetes_addons_cri-o_stable_v1.28]
name=CRI-O v1.28 (Stable) (rpm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will need some version handling here - cri-o version should match the k8s version being deployed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah agreed, after inspecting the existing state of the code. some providers share crio version but occasionally one provider might deviate. will account for this

@xpivarc
Copy link
Member

xpivarc commented Sep 11, 2024

I think a reason for this flake, the one where the CI job keeps waiting on the node to stop is that the node shuts down before reporting the status back to the ssh agent which makes it not know whether this happened or no

this code previously looked like this

_cmd(cli, nodeContainer(prefix, nodeName), "ssh.sh sudo shutdown now -h", "shutting down the node")

and now it looks like this (this PR introduces this change)

    if err = sshClient.Command("sudo shutdown now -h"); err != nil {
        return err
    }

which results in a golang error, since previously the error wasn't being handled

failed to execute command: sudo shutdown now -h

Is this from the _cmd?

and so what i suggest we do is that we don't handle the error, i don't know if we also need to force the code to continue executing after a certain duration but this may not be necessary. since previously when ssh.sh would fail the gocli wouldn't get this failure and the CI run hangs. but since we now ssh directly its guaranteed that if there's an error you will get it

I will push a commit with this suggestion

@aerosouund
Copy link
Member Author

aerosouund commented Sep 11, 2024

@xpivarc

Is this from the _cmd?

yes, i believe so. since when it was executed through ssh.sh it would timeout
and if executed and expected to handle the error it crashes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has DCO signed all their commits. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants