fix: adjusting the startup of the local api server for ci (#41364)

closes: #39766

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
Steven Hawkins 2025-07-30 08:59:30 -04:00 committed by GitHub
parent 7cdb994ba6
commit a770204d0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 5 deletions

View File

@ -7,19 +7,37 @@ import java.util.Optional;
import org.keycloak.operator.Utils;
import io.fabric8.kubeapitest.KubeAPIServer;
import io.fabric8.kubeapitest.KubeAPIServerConfigBuilder;
import io.fabric8.kubeapitest.KubeAPITestException;
import io.fabric8.kubernetes.api.model.apps.StatefulSet;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
import io.quarkus.logging.Log;
public class ApiServerHelper {
static final int MAX_START_RETRIES = 2;
private KubeAPIServer kubeApi;
public ApiServerHelper() {
kubeApi = new KubeAPIServer();
kubeApi.start();
long start = System.currentTimeMillis();
for (int i = 0; i < MAX_START_RETRIES; i++) {
kubeApi = new KubeAPIServer(
KubeAPIServerConfigBuilder.anAPIServerConfig().withStartupTimeout(90_000).build());
try {
kubeApi.start();
} catch (KubeAPITestException e) {
if (i == MAX_START_RETRIES - 1) {
throw e;
}
kubeApi.stop();
Log.warnf("api server failed to become ready %s", e.getMessage());
}
}
Log.infof("api server started in %s ms", System.currentTimeMillis() - start);
}
public void stop() {

View File

@ -137,7 +137,7 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback {
setDefaultAwaitilityTimings();
if (operatorDeployment == OperatorDeployment.local_apiserver) {
if (operatorDeployment == OperatorDeployment.local_apiserver && kubeApi == null) {
kubeApi = new ApiServerHelper();
}
@ -486,10 +486,11 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback {
k8sclient = null;
}
if (kubeApi != null) {
// scope the api server to the entire test run
/*if (kubeApi != null) {
kubeApi.stop();
kubeApi = null;
}
}*/
}
private static void stopOperator() {