Skip to content

Owls88697 stop namespaces that no longer managed by operator when change to dedicated strategy #2345

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

Merged
merged 9 commits into from
May 4, 2021

Conversation

doxiao
Copy link
Member

@doxiao doxiao commented Apr 27, 2021

For List, RegExp and LabelSelector domain selection strategy, the operator cleans up the namespaces that it does not managed any more in Namespaces.NamespaceListAfterStep. The cleanup is missed for the dedicated case because the operator does not go through the steps to list the existing namespaces. The fix is to add the Namespaces.NamespaceListAfterStep to the dedicated case and customize the getFoundDomainNamespaces to return the operator namespace.

The PR also makes the operator perform more necessary clean upon stopping managing a namespace or when a domain is deleted.

Unit test cases are added to cover the scenarios associated with the code changes. Some existing unit test cases where a particular domain namespaces selection strategy is tested are modified to run CreateReadNamespacesStep instead of readExsitingNamespaces because the latter does not exercise the strategy specific code path.

The test case in ItKuerbenetesEvents.java for dedicated strategy that used to fail because of this issue is turned on.

https://build.weblogick8s.org:8443/job/weblogic-kubernetes-operator-kind-new/4870/

@doxiao doxiao requested a review from alai8 April 30, 2021 16:39
Copy link
Member

@russgold russgold left a comment

Choose a reason for hiding this comment

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

Generally looks good; I have left a style recommendation.

defineSelectionStrategy(SelectionStrategy.List);
String namespaceString = "NS1";
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString);
createNamespaces(4);
Copy link
Member

Choose a reason for hiding this comment

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

I have found that organizing tests can help readability:

  1. general setup (what the world looks like before the operation)
  2. the action to test
  3. the assertion.

You can do that with judicious use of spaces. Here, lines 845-850 establish your starting point, and 852-854 are the action, so I would remove the blank lines in between them, and reserve those as separators only between the three sections.

If those are complex, you might consider extract them to their own methods, especially if you do the same setup in multiple tests.

@doxiao doxiao requested a review from russgold April 30, 2021 20:51
public void withNamespaceList_changeToDedicated_onCreateReadNamespaces_nsWatchStartedEventCreatedInOpNS() {
setupDomainWithNamespaceListStrategy("NS1");
runCreateReadNamespacesStep();
defineSelectionStrategy(SelectionStrategy.Dedicated);
Copy link
Member

Choose a reason for hiding this comment

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

Here you are changing to a new strategy, so line 859 begins the 'action' part of the test and should be separated by a blank line from the 'setup'

@rjeberhard rjeberhard merged commit 94014dd into main May 4, 2021
@rjeberhard rjeberhard deleted the owls88697-dedicated branch January 31, 2022 14:29
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