Skip to content

Conversation

@Hook25
Copy link
Collaborator

@Hook25 Hook25 commented Jul 29, 2025

Description

Currently:

  • The remote api relies on an obscure dict to re-connect to the agent depending on its state which is basically not documented or tested + weird partial usage that is unnecessary to pass arguments to functions
  • bootstrapping (with or without a ui) uses duplicated code in two functions
  • bootstrappping relies on a pointlessly duplicated api
  • bootstrapping uses a flag in self to suppress resource jobs output (sigh)
  • run_jobs is not used (and can't be used) to run any job, only normal jobs (post bootstrap)
  • remote api stores states as string, not an enum
  • there is a class local decorator in the remote api (which doesn't use the class and its args inferred wrong by the lsp)
  • the decorator also raises an AssertionError for a runtime error with an obscure error message
  • state transitions are done by setting a private variable and not logged
  • bootstrap transition is not done when starting the bootstrap process but when running the first bootstrap job
  • whats_up is poorly documented
  • similarly to the other pr, resume session is called resume session but doesn't resume the session!

This refactor fixes all the above issues

Resolved issues

Fixes: https://warthogs.atlassian.net/browse/CHECKBOX-1983

Documentation

Added documentation for many APIs

Tests

Metabox tests, nothing should change about the behaviour

@Hook25 Hook25 changed the title Remote assistant refactoring Remote assistant refactoring (new) Jul 29, 2025
@Hook25 Hook25 marked this pull request as draft July 29, 2025 15:53
@Hook25 Hook25 force-pushed the remote_assistant_refactoring branch from da22ab5 to 77156d8 Compare July 29, 2025 16:06
@codecov
Copy link

codecov bot commented Aug 4, 2025

Codecov Report

❌ Patch coverage is 65.75342% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.87%. Comparing base (0c78444) to head (c22d827).

Files with missing lines Patch % Lines
checkbox-ng/checkbox_ng/launcher/controller.py 64.54% 38 Missing and 1 partial ⚠️
...ckbox-ng/plainbox/impl/session/remote_assistant.py 70.31% 18 Missing and 1 partial ⚠️
checkbox-ng/checkbox_ng/launcher/subcommands.py 56.75% 13 Missing and 3 partials ⚠️
checkbox-ng/plainbox/impl/session/assistant.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           bootstrap_refactor    #2057   +/-   ##
===================================================
  Coverage               51.87%   51.87%           
===================================================
  Files                     387      387           
  Lines                   41684    41697   +13     
  Branches                 7743     7747    +4     
===================================================
+ Hits                    21623    21630    +7     
- Misses                  19295    19300    +5     
- Partials                  766      767    +1     
Flag Coverage Δ
checkbox-ng 70.79% <65.29%> (-0.02%) ⬇️
checkbox-support 65.06% <ø> (ø)
provider-base 27.72% <ø> (ø)
provider-certification-client 57.14% <ø> (ø)
provider-certification-server 57.14% <ø> (ø)
provider-genio 96.90% <ø> (ø)
provider-gpgpu 93.06% <ø> (ø)
provider-iiotg 100.00% <ø> (ø)
provider-resource 38.19% <ø> (ø)
provider-sru 97.97% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Hook25 Hook25 marked this pull request as ready for review August 6, 2025 13:04
@Hook25 Hook25 force-pushed the bootstrap_refactor branch from 4a19cc2 to 0c78444 Compare August 6, 2025 13:10
Hook25 added 19 commits August 6, 2025 15:10
Forgotten removed api
Decorator was moved to top level of the module, state now has a
non-private property (that logs transitions) and was changed accordingly

Minor fix: use .state and not ._state in decorator
Minor: forgotten 2 state comparison to str instead of new enum
This removes session finalization in all branches. It was added because
the start_new_sesison function starts a new session, so it fails on the
second iteration. The correct solution to this was not to spam finalize
everywhere but to split that function up into start and select_test_plan

(thanks me, I know you did this to me)
Minor: use new continue session function
@Hook25 Hook25 force-pushed the remote_assistant_refactoring branch from 9ba1984 to 77b2beb Compare August 6, 2025 13:19
Copy link
Collaborator

@fernando79513 fernando79513 left a comment

Choose a reason for hiding this comment

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

Amazing work here!
Overall, everything is clearer than before, and it makes more sense. Thanks for all the docstrings and the renaming.

I didn't find any issues in the code. I went through the issues that you mention in the description, and I agree with the solutions you proposed.

I don't think there are many big changes on the behavior of the sessions after this refactor, but is the information in checkbox remote page still correct?

@Hook25
Copy link
Collaborator Author

Hook25 commented Aug 8, 2025

The session behaviour must be exactly the same after this PR. The code I've removed was a legacy resume mechanism that was even more brittle than the one we have right now.

Copy link
Collaborator

@fernando79513 fernando79513 left a comment

Choose a reason for hiding this comment

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

Yep, that was what I thought, but I wanted to double check it.
I think this is good to go then.
Great work!

@Hook25 Hook25 merged commit 7090ed9 into bootstrap_refactor Aug 8, 2025
122 of 123 checks passed
@Hook25 Hook25 deleted the remote_assistant_refactoring branch August 8, 2025 09:40
Hook25 added a commit that referenced this pull request Aug 8, 2025
* Full refactoring backported to remote_assistant.py

* Backport controller refactoring

Forgotten removed api

* Fix unit tests by renaming apis and changing whats_up response

* Refactored allowed_when and _state -> state

Decorator was moved to top level of the module, state now has a
non-private property (that logs transitions) and was changed accordingly

Minor fix: use .state and not ._state in decorator

* Renamed resume_session to prepare_resume_session

Minor: forgotten 2 state comparison to str instead of new enum

* Missing bootstrap_and_continue

* Remove outdated resume machanism

* Check that all states have a connection_strategy

* Support optional parameters of interaction

* Include test plan in session metadata

* Move functions, rename functions that continue with _continue

* Default value of resume_by_id should be empty dict

* Propagate prepare_resume_session

* Also update name in the test

* Don't finalize the session until resume is decided

This removes session finalization in all branches. It was added because
the start_new_sesison function starts a new session, so it fails on the
second iteration. The correct solution to this was not to spam finalize
everywhere but to split that function up into start and select_test_plan

(thanks me, I know you did this to me)

* Port renames and new _continue process to tests

* Also fix local changes to subcommands

* Test test plan selection function

Minor: use new continue session function

* Disable fail-fast

* Update checkbox-ng/checkbox_ng/launcher/controller.py

Co-authored-by: Fernando Bravo <[email protected]>

---------

Co-authored-by: Fernando Bravo <[email protected]>
Hook25 added a commit that referenced this pull request Aug 8, 2025
* Rename bootstrap_todo_list to start_bootstrap and use the apis in silent
bootstrap

Minor: better docstring

* Create bootstrapping API to avoid using flags directly

* Rename resume_session to prepare_resume_session

resume session doesn't really resume the session,
more work is needed to get the session fully resumed

* Also propagate the bootstrap api change to remote_assistant

* Fix unit tests

* Test new bootstrapping property

* Backward compatible type hints using comments

Python3.5 (sigh) doesn't implement pep526

* Bump REMOTE_API_VERSION

* Fix typos in the docstrings

* Fix outdated todo_list getter

* Remote assistant refactoring (new) (#2057)

* Full refactoring backported to remote_assistant.py

* Backport controller refactoring

Forgotten removed api

* Fix unit tests by renaming apis and changing whats_up response

* Refactored allowed_when and _state -> state

Decorator was moved to top level of the module, state now has a
non-private property (that logs transitions) and was changed accordingly

Minor fix: use .state and not ._state in decorator

* Renamed resume_session to prepare_resume_session

Minor: forgotten 2 state comparison to str instead of new enum

* Missing bootstrap_and_continue

* Remove outdated resume machanism

* Check that all states have a connection_strategy

* Support optional parameters of interaction

* Include test plan in session metadata

* Move functions, rename functions that continue with _continue

* Default value of resume_by_id should be empty dict

* Propagate prepare_resume_session

* Also update name in the test

* Don't finalize the session until resume is decided

This removes session finalization in all branches. It was added because
the start_new_sesison function starts a new session, so it fails on the
second iteration. The correct solution to this was not to spam finalize
everywhere but to split that function up into start and select_test_plan

(thanks me, I know you did this to me)

* Port renames and new _continue process to tests

* Also fix local changes to subcommands

* Test test plan selection function

Minor: use new continue session function

* Disable fail-fast

* Update checkbox-ng/checkbox_ng/launcher/controller.py

Co-authored-by: Fernando Bravo <[email protected]>

---------

Co-authored-by: Fernando Bravo <[email protected]>

---------

Co-authored-by: Fernando Bravo <[email protected]>
stanley31huang pushed a commit that referenced this pull request Aug 14, 2025
* Rename bootstrap_todo_list to start_bootstrap and use the apis in silent
bootstrap

Minor: better docstring

* Create bootstrapping API to avoid using flags directly

* Rename resume_session to prepare_resume_session

resume session doesn't really resume the session,
more work is needed to get the session fully resumed

* Also propagate the bootstrap api change to remote_assistant

* Fix unit tests

* Test new bootstrapping property

* Backward compatible type hints using comments

Python3.5 (sigh) doesn't implement pep526

* Bump REMOTE_API_VERSION

* Fix typos in the docstrings

* Fix outdated todo_list getter

* Remote assistant refactoring (new) (#2057)

* Full refactoring backported to remote_assistant.py

* Backport controller refactoring

Forgotten removed api

* Fix unit tests by renaming apis and changing whats_up response

* Refactored allowed_when and _state -> state

Decorator was moved to top level of the module, state now has a
non-private property (that logs transitions) and was changed accordingly

Minor fix: use .state and not ._state in decorator

* Renamed resume_session to prepare_resume_session

Minor: forgotten 2 state comparison to str instead of new enum

* Missing bootstrap_and_continue

* Remove outdated resume machanism

* Check that all states have a connection_strategy

* Support optional parameters of interaction

* Include test plan in session metadata

* Move functions, rename functions that continue with _continue

* Default value of resume_by_id should be empty dict

* Propagate prepare_resume_session

* Also update name in the test

* Don't finalize the session until resume is decided

This removes session finalization in all branches. It was added because
the start_new_sesison function starts a new session, so it fails on the
second iteration. The correct solution to this was not to spam finalize
everywhere but to split that function up into start and select_test_plan

(thanks me, I know you did this to me)

* Port renames and new _continue process to tests

* Also fix local changes to subcommands

* Test test plan selection function

Minor: use new continue session function

* Disable fail-fast

* Update checkbox-ng/checkbox_ng/launcher/controller.py

Co-authored-by: Fernando Bravo <[email protected]>

---------

Co-authored-by: Fernando Bravo <[email protected]>

---------

Co-authored-by: Fernando Bravo <[email protected]>
bladernr pushed a commit that referenced this pull request Aug 28, 2025
* Rename bootstrap_todo_list to start_bootstrap and use the apis in silent
bootstrap

Minor: better docstring

* Create bootstrapping API to avoid using flags directly

* Rename resume_session to prepare_resume_session

resume session doesn't really resume the session,
more work is needed to get the session fully resumed

* Also propagate the bootstrap api change to remote_assistant

* Fix unit tests

* Test new bootstrapping property

* Backward compatible type hints using comments

Python3.5 (sigh) doesn't implement pep526

* Bump REMOTE_API_VERSION

* Fix typos in the docstrings

* Fix outdated todo_list getter

* Remote assistant refactoring (new) (#2057)

* Full refactoring backported to remote_assistant.py

* Backport controller refactoring

Forgotten removed api

* Fix unit tests by renaming apis and changing whats_up response

* Refactored allowed_when and _state -> state

Decorator was moved to top level of the module, state now has a
non-private property (that logs transitions) and was changed accordingly

Minor fix: use .state and not ._state in decorator

* Renamed resume_session to prepare_resume_session

Minor: forgotten 2 state comparison to str instead of new enum

* Missing bootstrap_and_continue

* Remove outdated resume machanism

* Check that all states have a connection_strategy

* Support optional parameters of interaction

* Include test plan in session metadata

* Move functions, rename functions that continue with _continue

* Default value of resume_by_id should be empty dict

* Propagate prepare_resume_session

* Also update name in the test

* Don't finalize the session until resume is decided

This removes session finalization in all branches. It was added because
the start_new_sesison function starts a new session, so it fails on the
second iteration. The correct solution to this was not to spam finalize
everywhere but to split that function up into start and select_test_plan

(thanks me, I know you did this to me)

* Port renames and new _continue process to tests

* Also fix local changes to subcommands

* Test test plan selection function

Minor: use new continue session function

* Disable fail-fast

* Update checkbox-ng/checkbox_ng/launcher/controller.py

Co-authored-by: Fernando Bravo <[email protected]>

---------

Co-authored-by: Fernando Bravo <[email protected]>

---------

Co-authored-by: Fernando Bravo <[email protected]>
stanley31huang pushed a commit that referenced this pull request Oct 3, 2025
* Rename bootstrap_todo_list to start_bootstrap and use the apis in silent
bootstrap

Minor: better docstring

* Create bootstrapping API to avoid using flags directly

* Rename resume_session to prepare_resume_session

resume session doesn't really resume the session,
more work is needed to get the session fully resumed

* Also propagate the bootstrap api change to remote_assistant

* Fix unit tests

* Test new bootstrapping property

* Backward compatible type hints using comments

Python3.5 (sigh) doesn't implement pep526

* Bump REMOTE_API_VERSION

* Fix typos in the docstrings

* Fix outdated todo_list getter

* Remote assistant refactoring (new) (#2057)

* Full refactoring backported to remote_assistant.py

* Backport controller refactoring

Forgotten removed api

* Fix unit tests by renaming apis and changing whats_up response

* Refactored allowed_when and _state -> state

Decorator was moved to top level of the module, state now has a
non-private property (that logs transitions) and was changed accordingly

Minor fix: use .state and not ._state in decorator

* Renamed resume_session to prepare_resume_session

Minor: forgotten 2 state comparison to str instead of new enum

* Missing bootstrap_and_continue

* Remove outdated resume machanism

* Check that all states have a connection_strategy

* Support optional parameters of interaction

* Include test plan in session metadata

* Move functions, rename functions that continue with _continue

* Default value of resume_by_id should be empty dict

* Propagate prepare_resume_session

* Also update name in the test

* Don't finalize the session until resume is decided

This removes session finalization in all branches. It was added because
the start_new_sesison function starts a new session, so it fails on the
second iteration. The correct solution to this was not to spam finalize
everywhere but to split that function up into start and select_test_plan

(thanks me, I know you did this to me)

* Port renames and new _continue process to tests

* Also fix local changes to subcommands

* Test test plan selection function

Minor: use new continue session function

* Disable fail-fast

* Update checkbox-ng/checkbox_ng/launcher/controller.py

Co-authored-by: Fernando Bravo <[email protected]>

---------

Co-authored-by: Fernando Bravo <[email protected]>

---------

Co-authored-by: Fernando Bravo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants