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

refactor: [draft][rfc] mrack session + host as context holder #246

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pvoborni
Copy link
Contributor

This PR is currently more like an idea/RFC (request-for-comments). There is a lot of stuff missing, opening early to get feedback if it is a good idea.

The idea behind this is to not use global objects and rather pass a session object which would contain whole context (config, provisioning config, metadata, database, initialized providers). Adding the session to other objects (host, providers, transformers, outputs, actions).

I'd also unitize Host object for carrying a provisioning context. I.e. it would be initialized e.g. in following way:

  • loaded from DB if was created by previous run
  • updated from metadata (here we might intentionally fail, if metadata changed in incompatible way)
  • updated by transformer (req added)
  • update by provider (output of provisioning, deletion or out method)
  • saved to DB

Also the PR adds more python typing - helps with the refactoring to find areas which has type mismatch.

The envisioned benefits/purposes are:

  • easier unit testing (but this actually depends how other things are written)
  • a possibility of having 2+ provisioning session running in single process in parallel with different inputs - this makes it more friendly for usage as a library.
  • the usage of Host as context can make easier the future use case to add/remove host interactively (in different runs)

To replace GlobalContext so that mrack run can be isolated without
using global variables. Thus more unit testable and potentially usable
in parallel.

Signed-off-by: Petr Vobornik <pvoborni@redhat.com>
Signed-off-by: Petr Vobornik <pvoborni@redhat.com>
Signed-off-by: Petr Vobornik <pvoborni@redhat.com>
Let's allow sesion to have various transformers and providers.

Signed-off-by: Petr Vobornik <pvoborni@redhat.com>
@pvoborni pvoborni added the WIP Work In Progress label Feb 22, 2023
@Tiboris Tiboris marked this pull request as draft April 20, 2023 07:12
@Tiboris Tiboris changed the title [draft][rfc] mrack session + host as context holder refactor: [draft][rfc] mrack session + host as context holder Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work In Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant