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

Kernel switching module: complete refactoring and hardening #308

Merged
merged 7 commits into from
Dec 9, 2024

Conversation

igorpecovnik
Copy link
Member

@igorpecovnik igorpecovnik commented Dec 5, 2024

Description

  • current kernel switching management had several design flaws and we could end up without a kernel.
  • switching between stable and beta was pulled into this common modules.

Implementation Details

BASH module.

Documentation Summary

Available commands:

select    	- TUI to select Armbian FW.              	 switches: [ stable | rolling ]
install   	- Install Armbian FW.                    	 switches: [ $branch | $version ]
show      	- Show Armbian FW packages.              	 switches: [ $branch | $version | hide ]
hold      	- Mark Armbian FW packages as held back. 	 switches: [status] returns true or false
unhold    	- Unset Armbian FW packages set as held back.
repository	- Selects repository and performs update. 	 switches: [ stable | rolling ]
headers 	- kernel headers management. 	  	  	 switches: [ install | remove | status ]

Testing Procedure

  • Installing headers install matching version
  • if headers are installed, switching to different kernel will also install matching headers
  • put packages on hold works as expected - it only hold armbian packages
  • switching kernels from frozen firmware, prompts for release and if confirmed installs selected firmware

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have ensured that my changes do not introduce new warnings or errors
  • No new external dependencies are included
  • Changes have been tested and verified
  • I have included necessary metadata in the code, including associative arrays

@github-actions github-actions bot added the size/large PR with 250 lines or more label Dec 5, 2024
@igorpecovnik igorpecovnik force-pushed the hardening-kernel-switch branch 7 times, most recently from d05b033 to 5f59f73 Compare December 6, 2024 10:35
@igorpecovnik igorpecovnik marked this pull request as ready for review December 6, 2024 10:36
@igorpecovnik igorpecovnik added 02 Milestone: First quarter release Bugfix Pull request is fixing a bug Needs review Seeking for review labels Dec 6, 2024
@igorpecovnik igorpecovnik force-pushed the hardening-kernel-switch branch from 5f59f73 to ad3f622 Compare December 6, 2024 10:39
@igorpecovnik igorpecovnik force-pushed the hardening-kernel-switch branch 4 times, most recently from b5ed6c2 to 8c305eb Compare December 6, 2024 10:46
@igorpecovnik igorpecovnik force-pushed the hardening-kernel-switch branch 11 times, most recently from edd643a to ada7034 Compare December 6, 2024 13:08
@igorpecovnik igorpecovnik force-pushed the hardening-kernel-switch branch 4 times, most recently from 59718db to d4c96eb Compare December 6, 2024 16:36
@igorpecovnik igorpecovnik force-pushed the hardening-kernel-switch branch 7 times, most recently from 19a1a0e to f929303 Compare December 6, 2024 19:19
@igorpecovnik igorpecovnik force-pushed the hardening-kernel-switch branch from f929303 to b6ae0b9 Compare December 6, 2024 19:21
@igorpecovnik
Copy link
Member Author

@Tearran @dimitry-ishenko @EvilOlaf

Those changes above works well now, but there is a problem that menu got quite slow (Odroid M1 takes several seconds, my desktop is fast, so it gets <1s) due to many checks. Which are IMO needed to perform as designed. Or I am blind and I don't see how to do it better ;)

Alternatively adding sub menu here System -> Kernel management and put there:

  • headers install
  • hold upgrades
  • rolling repository
  • alternative kernels
  • device tree overlays

Any thoughts?

@Tearran
Copy link
Member

Tearran commented Dec 7, 2024

Alternatively adding sub menu here System -> Kernel management and put there:

for the front end and grouping. Adding header ["...,group"]="some_subgroup" could be easily used

PR #287 Shows how we can query and nest separate groups. The example I used naming conventions module_ and gererate_ for groups others then fall in helper group.

"./bin/armbian-config" --api interface_json_data
image

@EvilOlaf
Copy link
Member

EvilOlaf commented Dec 7, 2024

Nothing obvious. Though I am not a bash wizard. Maybe add a warning "can take several seconds" :D

@igorpecovnik
Copy link
Member Author

Though I am not a bash wizard. Maybe add a warning "can take several seconds" :D

It takes too much of time already on arm64 board and this would go into 15 seconds or more in some old H3 board.

Here is a UX question first. If I push those kernel management stuff into submenu, main system will remain smooth as butter.

ow we can query and nest separate groups.

will look into this, thanks.

@Tearran
Copy link
Member

Tearran commented Dec 7, 2024

                {
                    "id": "Kernel",
                    "description": "Manage Armbian kernel upgrades",
                    "command": [
                        "see_menu module_armbian_firmware"
                    ],
                    "status": "Stable",
                    "author": "@igorpecovnik",
                    "condition": ""
                }

@Tearran
Copy link
Member

Tearran commented Dec 7, 2024

condition checking in the help message to produce a list available options. https://github.com/armbian/configng/blob/main/tools/modules/software/install_webmin.sh

@Tearran
Copy link
Member

Tearran commented Dec 7, 2024

As shown with https://github.com/armbian/configng/blob/hardening-kernel-switch/tools/modules/software/install_webmin.sh some condition checking done when a module is needed instead of checking conditions all at once.

"armbian-config" -> System -> Kernel
armbian-config --cmd Kernel
armbian-config --api see_menu module_armbian_firmware

All produce
{CF3520FC-D8A6-4F30-9C2D-0ED542D1E66A}

armbian-config --api module_armbian_firmware

The second tabs break the array.
{D92785B3-25C9-466A-A7C1-0C668156F021}

@igorpecovnik
Copy link
Member Author

The second tabs break the array.

I wasn't sure how to document those switches. Also here direct translation to the menu might not work well, at least how it is designed now - switch has more additional options. Kernel headers have remove, install, status (which is in this kind of arrangement not needed).

@Tearran
Copy link
Member

Tearran commented Dec 7, 2024

if you remove the 2nd \t on each line. That will fix the strings.

You can nest the Kernel in a sub_group but suggest that a [...,group"]="Kernel" and [...,conditions]="", be added to the module_options along with [...,arch]="" and port even if not used.

Perhaps one day this subfolder is done better as managing is still slow, but at least no affect whole system folder as before.
@igorpecovnik
Copy link
Member Author

I think I will get back to this in the future, but for now I would merge good working but slow functioning. As kernel management was moved into submenu, this gets less annoying. And probably UX wise, this is also better.

@igorpecovnik igorpecovnik merged commit b49c9fd into main Dec 9, 2024
6 of 19 checks passed
@igorpecovnik igorpecovnik deleted the hardening-kernel-switch branch December 9, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
02 Milestone: First quarter release Bugfix Pull request is fixing a bug Needs review Seeking for review size/large PR with 250 lines or more Unit Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants