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

7.11.1 cherry-pick - Explicitly marked cascade deletion as Foreground (#16540) #16586

Merged
merged 1 commit into from
Apr 10, 2020
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 @@ -65,6 +65,7 @@ public void delete() throws InfrastructureException {
.configMaps()
.inNamespace(namespace)
.withLabel(CHE_WORKSPACE_ID_LABEL, workspaceId)
.withPropagationPolicy("Foreground")
.delete();
} catch (KubernetesClientException e) {
throw new KubernetesInfrastructureException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ protected CompletableFuture<Void> doDeleteDeployment(String deploymentName)
toCloseOnException = watch;
}

Boolean deleteSucceeded = deploymentResource.delete();
Boolean deleteSucceeded = deploymentResource.withPropagationPolicy("Foreground").delete();

if (deleteSucceeded == null || !deleteSucceeded) {
deleteFuture.complete(null);
Expand Down Expand Up @@ -963,7 +963,7 @@ protected CompletableFuture<Void> doDeletePod(String podName) throws Infrastruct
final Watch watch = podResource.watch(new DeleteWatcher<Pod>(deleteFuture));
toCloseOnException = watch;

Boolean deleteSucceeded = podResource.delete();
Boolean deleteSucceeded = podResource.withPropagationPolicy("Foreground").delete();
if (deleteSucceeded == null || !deleteSucceeded) {
deleteFuture.complete(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public void delete() throws InfrastructureException {
.ingresses()
.inNamespace(namespace)
.withLabel(CHE_WORKSPACE_ID_LABEL, workspaceId)
.withPropagationPolicy("Foreground")
.delete();
} catch (KubernetesClientException e) {
throw new KubernetesInfrastructureException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private void update(Namespace namespace, KubernetesClient client) throws Infrast
private void delete(String namespaceName, KubernetesClient client)
throws InfrastructureException {
try {
client.namespaces().withName(namespaceName).delete();
client.namespaces().withName(namespaceName).withPropagationPolicy("Foreground").delete();
} catch (KubernetesClientException e) {
if (e.getCode() == 404) {
LOG.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public void delete(Map<String, String> labels) throws InfrastructureException {
.persistentVolumeClaims()
.inNamespace(namespace)
.withLabels(labels)
.withPropagationPolicy("Foreground")
.delete();
} catch (KubernetesClientException e) {
throw new KubernetesInfrastructureException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void delete() throws InfrastructureException {
.secrets()
.inNamespace(namespace)
.withLabel(CHE_WORKSPACE_ID_LABEL, workspaceId)
.withPropagationPolicy("Foreground")
.delete();
} catch (KubernetesClientException e) {
throw new KubernetesInfrastructureException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void delete() throws InfrastructureException {
.services()
.inNamespace(namespace)
.withLabel(CHE_WORKSPACE_ID_LABEL, workspaceId)
.withPropagationPolicy("Foreground")
.delete();
} catch (KubernetesClientException e) {
throw new KubernetesInfrastructureException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static org.eclipse.che.workspace.infrastructure.kubernetes.Constants.POD_STATUS_PHASE_SUCCEEDED;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.lenient;
Expand Down Expand Up @@ -456,6 +457,7 @@ public void testDeleteNonExistingPodBeforeWatch() throws Exception {
doReturn(POD_NAME).when(metadata).getName();

doReturn(Boolean.FALSE).when(podResource).delete();
doReturn(podResource).when(podResource).withPropagationPolicy(eq("Foreground"));
Watch watch = mock(Watch.class);
doReturn(watch).when(podResource).watch(any());

Expand All @@ -470,7 +472,7 @@ public void testDeleteNonExistingPodBeforeWatch() throws Exception {
public void testDeletePodThrowingKubernetesClientExceptionShouldCloseWatch() throws Exception {
final String POD_NAME = "nonExistingPod";
doReturn(POD_NAME).when(metadata).getName();

doReturn(podResource).when(podResource).withPropagationPolicy(eq("Foreground"));
doThrow(KubernetesClientException.class).when(podResource).delete();
Watch watch = mock(Watch.class);
doReturn(watch).when(podResource).watch(any());
Expand All @@ -491,7 +493,8 @@ public void testDeletePodThrowingKubernetesClientExceptionShouldCloseWatch() thr
public void testDeleteNonExistingDeploymentBeforeWatch() throws Exception {
final String DEPLOYMENT_NAME = "nonExistingPod";
doReturn(DEPLOYMENT_NAME).when(deploymentMetadata).getName();

doReturn(podResource).when(podResource).withPropagationPolicy(eq("Foreground"));
doReturn(deploymentResource).when(deploymentResource).withPropagationPolicy(eq("Foreground"));
doReturn(Boolean.FALSE).when(deploymentResource).delete();
Watch watch = mock(Watch.class);
doReturn(watch).when(podResource).watch(any());
Expand All @@ -510,6 +513,7 @@ public void testDeleteDeploymentThrowingKubernetesClientExceptionShouldCloseWatc
doReturn(DEPLOYMENT_NAME).when(deploymentMetadata).getName();

doThrow(KubernetesClientException.class).when(deploymentResource).delete();
doReturn(deploymentResource).when(deploymentResource).withPropagationPolicy(eq("Foreground"));
Watch watch = mock(Watch.class);
doReturn(watch).when(podResource).watch(any());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
Expand Down Expand Up @@ -365,6 +366,7 @@ private MetadataNested prepareCreateNamespaceRequest() {
private Resource prepareNamespaceResource(String namespaceName) {
Resource namespaceResource = mock(Resource.class);
doReturn(namespaceResource).when(namespaceOperation).withName(namespaceName);
doReturn(namespaceResource).when(namespaceResource).withPropagationPolicy(eq("Foreground"));
when(namespaceResource.get())
.thenReturn(
new NamespaceBuilder().withNewMetadata().withName(namespaceName).endMetadata().build());
Expand All @@ -375,6 +377,7 @@ private Resource prepareNamespaceResource(String namespaceName) {
private Resource prepareManagedNamespaceResource(String namespaceName) {
Resource namespaceResource = mock(Resource.class);
doReturn(namespaceResource).when(namespaceOperation).withName(namespaceName);
doReturn(namespaceResource).when(namespaceResource).withPropagationPolicy(eq("Foreground"));
when(namespaceResource.get())
.thenReturn(
new NamespaceBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import static org.eclipse.che.workspace.infrastructure.kubernetes.Constants.CHE_WORKSPACE_ID_LABEL;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -73,6 +74,7 @@ public void setUp() throws Exception {
when(client.secrets()).thenReturn(secretsMixedOperation);
lenient().when(secretsMixedOperation.inNamespace(any())).thenReturn(nonNamespaceOperation);
lenient().when(nonNamespaceOperation.withLabel(any(), any())).thenReturn(deletableList);
lenient().doReturn(deletableList).when(deletableList).withPropagationPolicy(eq("Foreground"));
}

@Test
Expand Down