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

Deploy remote rework #536

Closed

Conversation

rodrigosiqueira
Copy link
Collaborator

kw deploy is one of the most important parts of kw, and right now, this code is heavily coupled with distro-specific command and grub bootloader. This represents a barrier to making the deploy feature generic to other distros, systems, and bootloaders. This PR is a little bit big due to all the new code organization and other related changes. I still need to add more test coverage and documentation, but I want to open this PR in case that someone wants to comment.

We are trying to make the kw follow some basic patterns. For this
reason, this commit creates the deploy_main function and moves the parse
function to the bottom of the file.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
This commit is preparation work to make the deploy feature slightly more
generic by using better paths. Additionally, it moves those paths to a
set of variables that can be easily updated, enabling us to give the
user the option to set up the path they want in the config file.

Closes: kworkflow#470.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Currently, kw expect that users conduct the following basic setup in the
target machine:

1. Setup ssh connection to the root
2. Install required package (such as rsync)
3. Run any specific distro setup

This commit introduces the `deploy --setup`, which will run all of the
above basic configurations in the target machine. Now, the user only
needs to guarantee the ssh via password the first time.

Closes: kworkflow#481.
Closes: kworkflow#220.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
@rodrigosiqueira rodrigosiqueira added this to the kworkflow-beta milestone Jan 9, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2022

Codecov Report

Merging #536 (ff70e00) into unstable (c3b63c2) will decrease coverage by 0.81%.
The diff coverage is 63.25%.

Impacted file tree graph

@@             Coverage Diff              @@
##           unstable     #536      +/-   ##
============================================
- Coverage     73.84%   73.03%   -0.82%     
============================================
  Files            32       34       +2     
  Lines          4687     5117     +430     
============================================
+ Hits           3461     3737     +276     
- Misses         1226     1380     +154     
Impacted Files Coverage Δ
kw 27.96% <0.00%> (ø)
src/plugins/kernel_install/remote_deploy.sh 0.00% <0.00%> (ø)
src/remote.sh 88.37% <0.00%> (-2.11%) ⬇️
src/plugins/kernel_install/bootloader_utils.sh 48.92% <48.92%> (ø)
src/deploy.sh 64.36% <70.30%> (+6.71%) ⬆️
src/plugins/kernel_install/debian.sh 79.41% <75.00%> (+38.23%) ⬆️
src/plugins/kernel_install/arch.sh 80.39% <76.74%> (-19.61%) ⬇️
src/plugins/kernel_install/utils.sh 85.47% <89.47%> (+2.21%) ⬆️
src/plugins/kernel_install/grub.sh 91.17% <91.17%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3b63c2...ff70e00. Read the comment docs.

We want to make our deploy more generic, and one step for achieving this
goal consists in adding bootloader detection. This commit introduces a
function for handling the device and partition discovery which can be
used to identify the disk bootloader and even provide essential info to
users.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
This commit introduces a helper that identifies all hard disk types
available in the system and saves them in a list. This can be useful for
scanning each of the devices available in the system.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
If the target system uses MBR, there is a good chance that the first 4
bytes inform the partition table type. For this reason, this commit
introduces a function that checks those bytes. It is important to
highlight that we also added a couple of binary files to the sample
folder for validating the new function and other news that will be
implemented.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
This commit introduces a new function that tries to identify the
bootloader information based on the MBR partition. Notice that this is
heavily inspired in the bootscriptinfo.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Based on the standard set of files used by some bootloader this commit
introduces a dedicated function for searching for these files and report
the bootloader type.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
This function is responsible for collecting basic information from the
target machine in order to provide data that kw can use to check if it
can deploy the new kernel.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
kw deploy has to deal with generating rootfs and bootloader updates.
Unfortunately, the logic that handles the kernel update is very tangled
and mixes multiple steps spread around kernel plugin functions. This
commit starts to untangle this code by decoupling:

1. Bootloader logic;
2. Specific bootloader file type (e.g., now we have grub.sh);
3. Move specific logic for generating rootfs to the distro file (e.g.,
   arch.sh or debian.sh);
4. Isolate VM updates in their specific functions;

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
While conducting this massive code refactor, I took the strategy of
first focusing on local and remote deploy even if it means breaking vm
support. This commit represents a fix to the vm deploy, which means that
kw vm is working again for Debian and Arch VM. Note that we still need
to bring much more improvements to the VM parts; this commit is far away
from being ideal for vm deploy.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
The deploy test is one of the oldest files that we have inside kw, and
it has a lot of technical debt. This commit is mostly focused on
modernizing this test by cleanup and reorganizing it.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
@rodrigosiqueira rodrigosiqueira changed the title Deploy remote rework (WIP) Deploy remote rework Jan 14, 2022
Our deploy code is not very well covered, and the tests have technical
debt. This commit is mostly focused on testing new areas of the deploy
feature and changing some other parts of the code.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Plugins for kernel_install are outdated or do not cover important parts
of the code; this commit reduces this gap by modernizing and adding more
tests.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
When I tried to push the deploy refactor, I got the following error:

Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/pillow/python3-pil_7.0.0-4ubuntu0.4_amd64.deb  404  Not Found

It looks like this is an update issue.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
@rodrigosiqueira
Copy link
Collaborator Author

This is a huge and important work refactor in the deploy feature, which still has a lot of things to be improved. I suspect that I'll not get any review on this PR any time soon; for this reason, I decided to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Deploy
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

2 participants