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

Bootc provisioner #1247

Closed
wants to merge 23 commits into from
Closed

Conversation

aerosouund
Copy link
Member

What this PR does / why we need it:

Use bootc in provisioning k8s providers rather than relying on golang opts running bash

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

Special notes for your reviewer:

This PR is based off #1230

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:

Use bootc in provisioning

Signed-off-by: aerosouund <[email protected]>
The K8s client is a type to perform kubernetes operations on arbitrary manifests and embedded in it is the schema for all needed resources.
It includes also a test client implementation for unit tests.

Signed-off-by: aerosouund <[email protected]>
…e SSH Client interface

The new method is used to copy an arbitrary file on a node or a remote entity to a local path.
The modification to the SSH method is to allow the returning of stdOut as a string to the caller or to supress output

Signed-off-by: aerosouund <[email protected]>
This package is a go representation for each bash script that was run to configure an option for the KubeVirtCI cluster, where each script maps to a particular SomethingOpt type.
They all share an interface of having an Exec() error method

Signed-off-by: aerosouund <[email protected]>
…ckage

Some options for the kubevirt cluster were solely dependent on the bash code, this adds them to the go code
As well as refactor the constructors for configs to the the options pattern to avoid having a constructor that takes too many args

Signed-off-by: aerosouund <[email protected]>
… gocli flags

Remove the need to run any scripts in the run command and depend on the opts package.
Refactor provisionNode and provisionK8sOptions to use the options pattern instead of passing many args to the constructor.
Add new flags to the gocli which were previously only in the bash code.
Remove prepareDeviceForAssignment and prepareDeviceForAssignment as they both have been moved to opts.

Signed-off-by: aerosouund <[email protected]>
… opts

Move params to gocli params intialization instead

Signed-off-by: aerosouund <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
This functionality now exists in the KubevirtProvider type and doesn't need a package of its own

Signed-off-by: aerosouund <[email protected]>
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 <[email protected]>
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 <[email protected]>
Signed-off-by: aerosouund <[email protected]>
The cri package provides interfaces to run, build, and other relevant container actions agnostic of a specific runtime.
Supports docker and podman.

Signed-off-by: aerosouund <[email protected]>
The bootc package provides a type that can be used to generate qcow2 disk images from container images
Ir provides a containerfile that maps to the linux phase and another for the k8s phase,
In addition to a systemd unit that makes changes to the operating system to match the needs of kubevirtCI,
Which are setting ipv4 and ipv6 assignment to auto by network manager, as well as moving /opt to a writable directory

Signed-off-by: aerosouund <[email protected]>
… the service command doesn't exist

Signed-off-by: aerosouund <[email protected]>
Package installation will take place in the containers built by the bootc provisioner

Signed-off-by: aerosouund <[email protected]>
… the bootc provisioner

The provisioning logic is changed to be:
1. Build the linux phase container and if only linux phase is required build a qcow2 from it and include it in a final container
2. if the k8s phase is also required, the k8s phase container is built and the qcow2 is generated from it. then spin up a
cluster and run the k8s opt

A new version of vm.sh is introduced that uses the disk that was copied to the container during build rather than the previously existing one

Signed-off-by: aerosouund <[email protected]>
@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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. labels Aug 14, 2024
@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
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 kubevirt-bot requested a review from ormergi August 14, 2024 15:54
@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 brianmcarey 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 aerosouund marked this pull request as ready for review August 14, 2024 15:54
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 14, 2024
@kubevirt-bot kubevirt-bot requested a review from qinqon August 14, 2024 15:55
@aerosouund
Copy link
Member Author

cc: @xpivarc @dhiller @brianmcarey

@vladikr
Copy link
Member

vladikr commented Aug 14, 2024

@aerosouund That's an impressive work! Thank you.
Have you considered splitting this work into a collection of PRs?
Otherwise, it is nearly impossible to review this as a single change.

@aerosouund
Copy link
Member Author

@vladikr
Thank you, yeah you are right
This isn't one pull request though, this includes commits from #1217 and #1230 and those two have to be merged first
This PR is just for the last 5 commits and will be alot simpler to review then

@kubevirt-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@kubevirt-bot kubevirt-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 12, 2024
@kubevirt-bot
Copy link
Contributor

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle rotten

@kubevirt-bot kubevirt-bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 12, 2024
@kubevirt-bot
Copy link
Contributor

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

/close

@kubevirt-bot
Copy link
Contributor

@kubevirt-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

/close

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.

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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. 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.

3 participants