Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -58,6 +58,7 @@ public abstract class AbstractOperatorExtension
protected Duration infrastructureTimeout;
protected final boolean oneNamespacePerClass;
protected final boolean preserveNamespaceOnError;
protected final boolean skipNamespaceDeletion;
protected final boolean waitForNamespaceDeletion;
protected final int namespaceDeleteTimeout = DEFAULT_NAMESPACE_DELETE_TIMEOUT;
protected final Function<ExtensionContext, String> namespaceNameSupplier;
Expand All @@ -70,6 +71,7 @@ protected AbstractOperatorExtension(
Duration infrastructureTimeout,
boolean oneNamespacePerClass,
boolean preserveNamespaceOnError,
boolean skipNamespaceDeletion,
boolean waitForNamespaceDeletion,
KubernetesClient kubernetesClient,
KubernetesClient infrastructureKubernetesClient,
Expand All @@ -85,6 +87,7 @@ protected AbstractOperatorExtension(
this.infrastructureTimeout = infrastructureTimeout;
this.oneNamespacePerClass = oneNamespacePerClass;
this.preserveNamespaceOnError = preserveNamespaceOnError;
this.skipNamespaceDeletion = skipNamespaceDeletion;
this.waitForNamespaceDeletion = waitForNamespaceDeletion;
this.namespaceNameSupplier = namespaceNameSupplier;
this.perClassNamespaceNameSupplier = perClassNamespaceNameSupplier;
Expand Down Expand Up @@ -201,6 +204,9 @@ protected void after(ExtensionContext context) {
if (namespace != null) {
if (preserveNamespaceOnError && context.getExecutionException().isPresent()) {
LOGGER.info("Preserving namespace {}", namespace);
} else if (skipNamespaceDeletion) {
LOGGER.info("Skipping namespace deletion for {}", namespace);
deleteOperator();
} else {
infrastructureKubernetesClient.resourceList(infrastructure).delete();
deleteOperator();
Comment on lines 205 to 210
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

skipNamespaceDeletion branch currently skips not only namespace deletion but also infrastructure cleanup (resourceList(infrastructure).delete()). This can leak namespaced resources and diverges from the stated intent of only skipping namespace deletion. Consider still deleting infrastructure (and stopping/deleting the operator) while only skipping the namespaces().withName(namespace).delete() + wait logic, and update the log message accordingly.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems like a valid comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes, fixed, thx!

Expand Down Expand Up @@ -229,6 +235,7 @@ public abstract static class AbstractBuilder<T extends AbstractBuilder<T>> {
protected final List<HasMetadata> infrastructure;
protected Duration infrastructureTimeout;
protected boolean preserveNamespaceOnError;
protected boolean skipNamespaceDeletion;
protected boolean waitForNamespaceDeletion;
protected boolean oneNamespacePerClass;
protected int namespaceDeleteTimeout;
Expand All @@ -245,6 +252,9 @@ protected AbstractBuilder() {
this.preserveNamespaceOnError =
Utils.getSystemPropertyOrEnvVar("josdk.it.preserveNamespaceOnError", false);

this.skipNamespaceDeletion =
Utils.getSystemPropertyOrEnvVar("josdk.it.skipNamespaceDeletion", false);

this.waitForNamespaceDeletion =
Utils.getSystemPropertyOrEnvVar("josdk.it.waitForNamespaceDeletion", true);

Expand All @@ -261,6 +271,11 @@ public T preserveNamespaceOnError(boolean value) {
return (T) this;
}

public T skipNamespaceDeletion(boolean value) {
this.skipNamespaceDeletion = value;
return (T) this;
}

public T waitForNamespaceDeletion(boolean value) {
this.waitForNamespaceDeletion = value;
return (T) this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private ClusterDeployedOperatorExtension(
List<HasMetadata> infrastructure,
Duration infrastructureTimeout,
boolean preserveNamespaceOnError,
boolean skipNamespaceDeletion,
boolean waitForNamespaceDeletion,
boolean oneNamespacePerClass,
KubernetesClient kubernetesClient,
Expand All @@ -62,6 +63,7 @@ private ClusterDeployedOperatorExtension(
infrastructureTimeout,
oneNamespacePerClass,
preserveNamespaceOnError,
skipNamespaceDeletion,
waitForNamespaceDeletion,
kubernetesClient,
infrastructureKubernetesClient,
Expand Down Expand Up @@ -189,6 +191,7 @@ public ClusterDeployedOperatorExtension build() {
infrastructure,
infrastructureTimeout,
preserveNamespaceOnError,
skipNamespaceDeletion,
waitForNamespaceDeletion,
oneNamespacePerClass,
kubernetesClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private LocallyRunOperatorExtension(
List<CustomResourceDefinition> additionalCustomResourceDefinitionInstances,
Duration infrastructureTimeout,
boolean preserveNamespaceOnError,
boolean skipNamespaceDeletion,
boolean waitForNamespaceDeletion,
boolean oneNamespacePerClass,
KubernetesClient kubernetesClient,
Expand All @@ -94,6 +95,7 @@ private LocallyRunOperatorExtension(
infrastructureTimeout,
oneNamespacePerClass,
preserveNamespaceOnError,
skipNamespaceDeletion,
waitForNamespaceDeletion,
kubernetesClient,
infrastructureKubernetesClient,
Expand Down Expand Up @@ -541,6 +543,7 @@ public LocallyRunOperatorExtension build() {
additionalCustomResourceDefinitionInstances,
infrastructureTimeout,
preserveNamespaceOnError,
skipNamespaceDeletion,
waitForNamespaceDeletion,
oneNamespacePerClass,
kubernetesClient,
Expand Down