Skip to content

owls-87091 keep namespaces processed in batches - backport #2189

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 1 commit into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Step readExistingNamespaces() {
}

private class NamespaceListResponseStep extends DefaultResponseStep<V1NamespaceList> {
Step current = getNext();

private NamespaceListResponseStep() {
super(new Namespaces.NamespaceListAfterStep(domainNamespaces));
Expand Down Expand Up @@ -168,8 +169,9 @@ private Step createNextSteps(Set<String> namespacesToStartNow) {
RunInParallel.perNamespace(namespacesToStartNow, DomainRecheck.this::createNamespaceReview));
}
}
nextSteps.add(getNext());
return Step.chain(nextSteps.toArray(new Step[0]));
nextSteps.add(current);
current = Step.chain(nextSteps.toArray(new Step[0]));
return current;
}

private Set<String> getNamespacesToStart(List<String> namespaceNames) {
Expand Down
33 changes: 33 additions & 0 deletions operator/src/test/java/oracle/kubernetes/operator/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ private List<String> getStartingNamespaces() {
return Arrays.stream(NAMESPACES).filter(domainNamespaces::isStarting).collect(Collectors.toList());
}

private List<String> getStartingNamespaces(String...namespaces) {
return Arrays.stream(namespaces).filter(domainNamespaces::isStarting).collect(Collectors.toList());
}

@NotNull
DomainRecheck createDomainRecheck() {
return new DomainRecheck(delegate);
Expand Down Expand Up @@ -427,6 +431,35 @@ private void defineSelectionStrategy(SelectionStrategy selectionStrategy) {
TuningParameters.getInstance().put(Namespaces.SELECTION_STRATEGY_KEY, selectionStrategy.toString());
}

@Test
public void whenNamespacesListedInMultipleChunks_allNamespacesStarted() {
loggerControl.withLogLevel(Level.WARNING).collectLogMessages(logRecords, MessageKeys.NAMESPACE_IS_MISSING);

defineSelectionStrategy(SelectionStrategy.List);
String namespaceString = "NS1,NS" + MULTICHUNK_LAST_NAMESPACE_NUM;
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString);
createNamespaces(MULTICHUNK_LAST_NAMESPACE_NUM);

testSupport.runSteps(createDomainRecheck().readExistingNamespaces());

assertThat(getStartingNamespaces("NS1", "NS" + MULTICHUNK_LAST_NAMESPACE_NUM),
contains("NS1", "NS" + MULTICHUNK_LAST_NAMESPACE_NUM));
}

@Test
public void whenNamespacesListedInMoreThanTwoChunks_allNamespacesStarted() {
loggerControl.withLogLevel(Level.WARNING).collectLogMessages(logRecords, MessageKeys.NAMESPACE_IS_MISSING);
int lastNSNumber = DEFAULT_CALL_LIMIT * 3 + 1;
defineSelectionStrategy(SelectionStrategy.List);
String namespaceString = "NS1,NS" + lastNSNumber;
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString);
createNamespaces(lastNSNumber);

testSupport.runSteps(createDomainRecheck().readExistingNamespaces());

assertThat(getStartingNamespaces("NS1", "NS" + lastNSNumber), contains("NS1", "NS" + lastNSNumber));
}

@Test
public void whenNamespacesListedInMultipleChunks_dontDeclarePresentNamespacesAsMissing() {
loggerControl.withLogLevel(Level.WARNING).collectLogMessages(logRecords, MessageKeys.NAMESPACE_IS_MISSING);
Expand Down