Skip to content

Commit

Permalink
CHE-8611 Add warning suppressing when namespace/project doesn't exist…
Browse files Browse the repository at this point in the history
… on removing
  • Loading branch information
sleshchenko committed Feb 6, 2018
1 parent 9abe8e4 commit dd4d9af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import io.fabric8.kubernetes.client.KubernetesClientException;
import javax.inject.Named;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.core.notification.EventSubscriber;
Expand Down Expand Up @@ -66,6 +67,13 @@ public void onEvent(WorkspaceRemovedEvent event) {

@VisibleForTesting
void doRemoveNamespace(String namespaceName) throws InfrastructureException {
clientFactory.create().namespaces().withName(namespaceName).delete();
try {
clientFactory.create().namespaces().withName(namespaceName).delete();
} catch (KubernetesClientException e) {
if (!(e.getCode() == 403)) {
throw new InfrastructureException(e.getMessage(), e);
}
// namespace doesn't exist
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import io.fabric8.kubernetes.client.KubernetesClientException;
import javax.inject.Named;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.core.notification.EventSubscriber;
Expand All @@ -32,6 +33,7 @@
*/
@Singleton
public class RemoveProjectOnWorkspaceRemove implements EventSubscriber<WorkspaceRemovedEvent> {

private static final Logger LOG = LoggerFactory.getLogger(RemoveProjectOnWorkspaceRemove.class);

private final OpenShiftClientFactory clientFactory;
Expand Down Expand Up @@ -66,6 +68,13 @@ public void onEvent(WorkspaceRemovedEvent event) {

@VisibleForTesting
void doRemoveProject(String projectName) throws InfrastructureException {
clientFactory.create().projects().withName(projectName).delete();
try {
clientFactory.create().projects().withName(projectName).delete();
} catch (KubernetesClientException e) {
if (!(e.getCode() == 403)) {
throw new InfrastructureException(e.getMessage(), e);
}
// project doesn't exist
}
}
}

0 comments on commit dd4d9af

Please sign in to comment.