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

Add data-plane pre upgrade sanity checks #222

Merged
merged 11 commits into from
Jan 24, 2024

Conversation

gabrielcocenza
Copy link
Member

  • check if control-plane is already upgraded if user pass "data-pane" upgrade group
  • check if data-plane apps exists if user pass "data-pane" upgrade group
  • splitted the logic on determine_upgrade_target to several functions

This PR should be merged after #221

- create a new NamedTuple class to be the COU Namespace. With that,
  type is still checked and few arguments are necessary to pass to
  the functions that use the arguments passed by the user. Moreover,
  docstrings are shorter and easier to maintain

- Global variables for "data-plane" and "control-plane".
- check if control-plane is already upgraded if user pass "data-pane"
  upgrade group
- check if data-plane apps exists if user pass "data-pane"
  upgrade group
- splitted the logic on determine_upgrade_target to several functions
@gabrielcocenza gabrielcocenza requested a review from a team as a code owner January 16, 2024 22:24
@gabrielcocenza gabrielcocenza changed the base branch from main to dev/data-plane January 16, 2024 22:26
@gabrielcocenza gabrielcocenza self-assigned this Jan 16, 2024
cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
tests/unit/steps/test_steps_plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
@gabrielcocenza gabrielcocenza changed the title Add data-plane pre upgrade sane checks Add data-plane pre upgrade sanity checks Jan 18, 2024
cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
- small change in is_highest_release_achieved function
Copy link
Contributor

@agileshaw agileshaw left a comment

Choose a reason for hiding this comment

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

LGTM, but with one small non-blocking suggestion

cou/steps/plan.py Outdated Show resolved Hide resolved
cou/steps/plan.py Outdated Show resolved Hide resolved
is_data_plane_ready_to_upgrade(analysis_result)


def is_valid_openstack_cloud(analysis_result: Analysis) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming suggests this should return a boolean (is_*). Perhaps assert_* or verify_*?

@@ -53,6 +54,147 @@
logger = logging.getLogger(__name__)


def pre_plan_sanity_checks(args: CLIargs, analysis_result: Analysis) -> None:
"""Pre checks to generate the upgrade plan.
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be documented that this works by raising a particular set of exceptions if a check fails.

Copy link
Member Author

@gabrielcocenza gabrielcocenza Jan 23, 2024

Choose a reason for hiding this comment

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

I see little benefit on doing this. In Java for example, the checked exception forced the signature of every method would list all of the exceptions that it could pass to its caller and has a high price. If we start getting deep into this we could have a situation where we would need to go three or more levels checking all the exceptions that can happen.

On theory a change at a low level of the software would imply on updating on the higher level and I don't think it worth.

If you have the Clean Code book, chapter 7 has a session talking about this that worth the reading.

Copy link
Contributor

Choose a reason for hiding this comment

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

@samuelengineer that's good point, I lost myself with warlock operators in this PR.
@gabrielcocenza I see your point, however all those verify_* function are simple helper functions, and we expected this function to raise those exceptions. If I look at the function name pre_plan_sanity_checks, and then the description, I could not tell what this function actually do? It's not returning anything and not mention raising anything.

Please stop referring to that book (I'm going to buy and read it, because there could be good point). I believe that you're misinterpreting things from it, or it has written not for Python. Thanks

Copy link
Contributor

@samuelallan72 samuelallan72 left a comment

Choose a reason for hiding this comment

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

sorry, those comments were meant to be nonblocking - just drivethrough thoughts.

  a boolean.
- removed the pre_plan_sanity_checks is_valid_openstack_cloud to
  be nested under determine_upgrade_target
- fixed unit tests to test the verify_* functions instead of the
  pre_plan_sanity_checks
@@ -53,6 +54,147 @@
logger = logging.getLogger(__name__)


def pre_plan_sanity_checks(args: CLIargs, analysis_result: Analysis) -> None:
"""Pre checks to generate the upgrade plan.
Copy link
Contributor

Choose a reason for hiding this comment

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

@samuelengineer that's good point, I lost myself with warlock operators in this PR.
@gabrielcocenza I see your point, however all those verify_* function are simple helper functions, and we expected this function to raise those exceptions. If I look at the function name pre_plan_sanity_checks, and then the description, I could not tell what this function actually do? It's not returning anything and not mention raising anything.

Please stop referring to that book (I'm going to buy and read it, because there could be good point). I believe that you're misinterpreting things from it, or it has written not for Python. Thanks

Copy link
Contributor

@agileshaw agileshaw left a comment

Choose a reason for hiding this comment

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

LGTM

@rgildein rgildein merged commit 8e38d92 into canonical:dev/data-plane Jan 24, 2024
1 check passed
@gabrielcocenza gabrielcocenza deleted the pre_plan_sane_check branch March 12, 2024 15:31
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.

4 participants