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

Split the freeze toggles and checkers #610

Merged
merged 3 commits into from Dec 13, 2020
Merged

Conversation

nolar
Copy link
Owner

@nolar nolar commented Dec 13, 2020

In preparation for the coming changes when there are multiple peering objects from multiple namespaces monitored for a single operator, it is crucial that the freeze-checkers and freeze-toggle are split and managed separately.

Previously, it was a single flag, which was either on or off.

Now, it is multiple flags, each is in its own state, and one checker, which is off when all toggles are off, or on when at least one toggle is on — i.e. if there is at least one peering/namespace with a conflicting operator.

However, in the current codebase, only one freeze flag is possible, as the operator can handle one and only one namespace (or be cluster-wide); multiple namespaces are not yet supported.

The change is essentially an extracted preparation for a bigger PR to make it smaller and more readable.

Relies on #608 and #609.

In some cases, the toggle should be turned to or checked against a runtime value. With separate methods for on/off values, it requires `if-else` expressions or statements. It could be much more simple if there is only one method to turning it to any state, and one method for waiting, and one method for checking.

Especially in the light of coming changes when the freeze toggles are split to toggles & checkers, and there could be more than one toggle per checker — having too many methods is confusing and prone to errors.

However, the on/off checks are left as is — to keep the code readability, and to avoid confusion when checking for `bool(toggle_set)`, where the "toggle set" is a collection of toggles: a collection is typically true when it contains any items, but we need a special logic over these items.
@nolar nolar added the refactoring Code cleanup without new features added label Dec 13, 2020
@lgtm-com
Copy link

lgtm-com bot commented Dec 13, 2020

This pull request introduces 1 alert when merging 39329d2 into 8601875 - view on LGTM.com

new alerts:

  • 1 for Unused import

@nolar nolar force-pushed the peering-freeze-toggles-checkers branch from 39329d2 to 1cec5a1 Compare December 13, 2020 16:09
@nolar nolar merged commit db2c740 into master Dec 13, 2020
@nolar nolar deleted the peering-freeze-toggles-checkers branch December 13, 2020 16:40
@nolar nolar changed the title Split freeze toggles and checkers Split the freeze toggles and checkers Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code cleanup without new features added
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant