chore: remove che.infra.kubernetes.workspace_start_timeout_min property

Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
pull/378/head
Andrew Obuchowicz 2022-09-26 15:55:29 -04:00 committed by Ilya Buziuk
parent ee3f2b9911
commit 5360484f28
9 changed files with 21 additions and 76 deletions

View File

@ -354,9 +354,6 @@ che.infra.kubernetes.workspace_sa_cluster_roles=NULL
# Cluster roles to assign to user in their namespace.
che.infra.kubernetes.user_cluster_roles=NULL
# Defines wait time that limits the Kubernetes workspace start time.
che.infra.kubernetes.workspace_start_timeout_min=8
# Defines the timeout (in minutes) that limits the period for which {orch-ingress} becomes ready.
che.infra.kubernetes.ingress_start_timeout_min=5

View File

@ -114,7 +114,6 @@ public class KubernetesInternalRuntime<E extends KubernetesEnvironment>
private static final Logger LOG = LoggerFactory.getLogger(KubernetesInternalRuntime.class);
private final int workspaceStartTimeoutMin;
private final long ingressStartTimeoutMillis;
private final UnrecoverablePodEventListenerFactory unrecoverableEventListenerFactory;
private final ServersCheckerFactory serverCheckerFactory;
@ -139,7 +138,6 @@ public class KubernetesInternalRuntime<E extends KubernetesEnvironment>
@Inject
public KubernetesInternalRuntime(
@Named("che.infra.kubernetes.workspace_start_timeout_min") int workspaceStartTimeoutMin,
@Named("che.infra.kubernetes.ingress_start_timeout_min") int ingressStartTimeoutMin,
NoOpURLRewriter urlRewriter,
UnrecoverablePodEventListenerFactory unrecoverableEventListenerFactory,
@ -166,7 +164,6 @@ public class KubernetesInternalRuntime<E extends KubernetesEnvironment>
super(context, urlRewriter);
this.unrecoverableEventListenerFactory = unrecoverableEventListenerFactory;
this.serverCheckerFactory = serverCheckerFactory;
this.workspaceStartTimeoutMin = workspaceStartTimeoutMin;
this.ingressStartTimeoutMillis = TimeUnit.MINUTES.toMillis(ingressStartTimeoutMin);
this.probeScheduler = probeScheduler;
this.probesFactory = probesFactory;
@ -299,38 +296,6 @@ public class KubernetesInternalRuntime<E extends KubernetesEnvironment>
LOG.debug("Provisioning of workspace '{}' completed.", workspaceId);
}
/**
* Schedules runtime state checks that are needed after recovering of runtime.
*
* <p>Different checks will be scheduled according to current runtime status:
*
* <ul>
* <li>STARTING - schedules servers checkers and starts tracking of starting runtime
* <li>RUNNING - schedules servers checkers
* <li>STOPPING - starts tracking of stopping runtime
* <li>STOPPED - do nothing. Should not happen since only active runtimes are recovered
* </ul>
*/
public void scheduleRuntimeStateChecks() throws InfrastructureException {
switch (getStatus()) {
case RUNNING:
scheduleServersCheckers();
break;
case STOPPING:
runtimeHangingDetector.trackStopping(this, workspaceStartTimeoutMin);
break;
case STARTING:
runtimeHangingDetector.trackStarting(this, workspaceStartTimeoutMin);
scheduleServersCheckers();
break;
case STOPPED:
default:
// do nothing
}
}
/** Returns new function that wraps given with set/unset context logic */
private <T, R> Function<T, R> setContext(EnvironmentContext context, Function<T, R> func) {
return funcArgument -> {
@ -574,18 +539,13 @@ public class KubernetesInternalRuntime<E extends KubernetesEnvironment>
runtimeHangingDetector.stopTracking(getContext().getIdentity());
if (startSynchronizer.interrupt()) {
// runtime is STARTING. Need to wait until start will be interrupted properly
try {
if (!startSynchronizer.awaitInterruption(workspaceStartTimeoutMin, TimeUnit.MINUTES)) {
// Runtime is not interrupted yet. It may occur when start was performing by another
// Che Server that is crashed so start is hung up in STOPPING phase.
// Need to clean up runtime resources
probeScheduler.cancel(identity.getWorkspaceId());
runtimeCleaner.cleanUp(namespace, identity.getWorkspaceId());
}
} catch (InterruptedException e) {
throw new InfrastructureException(
"Interrupted while waiting for start task cancellation", e);
}
// Runtime is not interrupted yet. It may occur when start was performing by another
// Che Server that is crashed so start is hung up in STOPPING phase.
// Need to clean up runtime resources
probeScheduler.cancel(identity.getWorkspaceId());
runtimeCleaner.cleanUp(namespace, identity.getWorkspaceId());
} else {
// runtime is RUNNING. Clean up used resources
// Cancels workspace servers probes if any

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* Copyright (c) 2012-2022 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@ -86,8 +86,6 @@ public class KubernetesRuntimeContext<T extends KubernetesEnvironment> extends R
runtimeFactory.create(
this, namespaceFactory.access(workspaceId, runtimeState.getNamespace()));
runtime.scheduleRuntimeStateChecks();
return runtime;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* Copyright (c) 2012-2022 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@ -18,7 +18,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.che.api.core.model.workspace.WorkspaceStatus;
import org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity;
import org.eclipse.che.api.core.notification.EventService;
@ -116,10 +115,7 @@ public class StartSynchronizer {
private final RuntimeStopWatcher runtimeStopWatcher;
@Inject
public StartSynchronizer(
EventService eventService,
@Named("che.infra.kubernetes.workspace_start_timeout_min") int workspaceStartTimeoutMin,
@Assisted RuntimeIdentity runtimeId) {
public StartSynchronizer(EventService eventService, @Assisted RuntimeIdentity runtimeId) {
this.eventService = eventService;
this.startFailure = new CompletableFuture<>();
this.completionLatch = new CountDownLatch(0);
@ -127,7 +123,7 @@ public class StartSynchronizer {
this.runtimeStartInterrupter = new RuntimeStartInterrupter();
this.runtimeStopWatcher = new RuntimeStopWatcher();
this.isStarting = false;
this.workspaceStartTimeoutMillis = TimeUnit.MINUTES.toMillis(workspaceStartTimeoutMin);
this.workspaceStartTimeoutMillis = TimeUnit.MINUTES.toMillis(8);
}
/** Registers a runtime start. */

View File

@ -270,12 +270,11 @@ public class KubernetesInternalRuntimeTest {
MULTI_HOST_STRATEGY,
WorkspaceExposureType.NATIVE.getConfigValue());
startSynchronizer = spy(new StartSynchronizer(eventService, 5, IDENTITY));
startSynchronizer = spy(new StartSynchronizer(eventService, IDENTITY));
when(startSynchronizerFactory.create(any())).thenReturn(startSynchronizer);
internalRuntime =
new KubernetesInternalRuntime<>(
13,
5,
new URLRewriter.NoOpURLRewriter(),
unrecoverablePodEventListenerFactory,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* Copyright (c) 2012-2022 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@ -55,7 +55,7 @@ public class StartSynchronizerTest {
@BeforeMethod
public void setUp() {
runtimeId = new RuntimeIdentityImpl("workspace123", "envName", "ownerId", "infraNamespace");
startSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
startSynchronizer = new StartSynchronizer(eventService, runtimeId);
}
@Test
@ -173,7 +173,7 @@ public class StartSynchronizerTest {
public void shouldInterruptStartWhenStoppingEventIsPublished() throws Exception {
// given
EventService eventService = new EventService();
StartSynchronizer localStartSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
StartSynchronizer localStartSynchronizer = new StartSynchronizer(eventService, runtimeId);
localStartSynchronizer.start();
// when
@ -187,7 +187,7 @@ public class StartSynchronizerTest {
public void shouldCompleteStartWhenStoppedEventIsPublished() {
// given
EventService eventService = new EventService();
StartSynchronizer localStartSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
StartSynchronizer localStartSynchronizer = new StartSynchronizer(eventService, runtimeId);
localStartSynchronizer.start();
// when
@ -212,7 +212,7 @@ public class StartSynchronizerTest {
// given
runtimeId = new RuntimeIdentityImpl("workspace123", "envName", "ownerId", "infraNamespace");
EventService eventService = new EventService();
startSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
startSynchronizer = new StartSynchronizer(eventService, runtimeId);
startSynchronizer.start();
// when
@ -228,7 +228,7 @@ public class StartSynchronizerTest {
// given
runtimeId = new RuntimeIdentityImpl("workspace123", "envName", "ownerId", "infraNamespace");
EventService eventService = new EventService();
startSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
startSynchronizer = new StartSynchronizer(eventService, runtimeId);
startSynchronizer.start();
// when
@ -246,7 +246,7 @@ public class StartSynchronizerTest {
EventService eventService = new EventService();
// when
startSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
startSynchronizer = new StartSynchronizer(eventService, runtimeId);
// then
assertSubscriberTypesNumber(eventService, 0);
@ -257,7 +257,7 @@ public class StartSynchronizerTest {
// given
runtimeId = new RuntimeIdentityImpl("workspace123", "envName", "ownerId", "infraNamespace");
EventService eventService = new EventService();
startSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
startSynchronizer = new StartSynchronizer(eventService, runtimeId);
// when
startSynchronizer.start();

View File

@ -59,7 +59,6 @@ public class OpenShiftInternalRuntime extends KubernetesInternalRuntime<OpenShif
@Inject
public OpenShiftInternalRuntime(
@Named("che.infra.kubernetes.workspace_start_timeout_min") int workspaceStartTimeout,
@Named("che.infra.kubernetes.ingress_start_timeout_min") int ingressStartTimeout,
NoOpURLRewriter urlRewriter,
UnrecoverablePodEventListenerFactory unrecoverablePodEventListenerFactory,
@ -85,7 +84,6 @@ public class OpenShiftInternalRuntime extends KubernetesInternalRuntime<OpenShif
@Assisted OpenShiftRuntimeContext context,
@Assisted OpenShiftProject project) {
super(
workspaceStartTimeout,
ingressStartTimeout,
urlRewriter,
unrecoverablePodEventListenerFactory,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2021 Red Hat, Inc.
* Copyright (c) 2012-2022 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
@ -81,8 +81,6 @@ public class OpenShiftRuntimeContext extends KubernetesRuntimeContext<OpenShiftE
runtimeFactory.create(
this, projectFactory.access(workspaceId, runtimeState.getNamespace()));
runtime.scheduleRuntimeStateChecks();
return runtime;
}
}

View File

@ -174,7 +174,6 @@ public class OpenShiftInternalRuntimeTest {
internalRuntime =
new OpenShiftInternalRuntime(
13,
5,
new URLRewriter.NoOpURLRewriter(),
unrecoverablePodEventListenerFactory,