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

Print error message is printed with certificate is self-signed when deploying to OpenShift #16269

Merged
merged 1 commit into from
Apr 6, 2021
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,7 +65,7 @@
import io.quarkus.deployment.pkg.builditem.NativeImageBuildItem;
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem;
import io.quarkus.deployment.pkg.steps.NativeBuild;
import io.quarkus.kubernetes.client.deployment.KubernetesClientErrorHanlder;
import io.quarkus.kubernetes.client.deployment.KubernetesClientErrorHandler;
import io.quarkus.kubernetes.client.spi.KubernetesClientBuildItem;
import io.quarkus.kubernetes.spi.DecoratorBuildItem;
import io.quarkus.kubernetes.spi.KubernetesCommandBuildItem;
Expand Down Expand Up @@ -340,7 +340,7 @@ public static void createContainerImage(KubernetesClientBuildItem kubernetesClie
//Let's disable http2 as it causes issues with duplicate build triggers.
config.setHttp2Disable(true);
try (KubernetesClient client = Clients.fromConfig(config)) {
OpenShiftClient openShiftClient = client.adapt(OpenShiftClient.class);
OpenShiftClient openShiftClient = toOpenshiftClient(client);
KubernetesList kubernetesList = Serialization
.unmarshalAsList(new ByteArrayInputStream(openshiftManifests.getData()));

Expand All @@ -353,6 +353,15 @@ public static void createContainerImage(KubernetesClientBuildItem kubernetesClie
}
}

private static OpenShiftClient toOpenshiftClient(KubernetesClient client) {
try {
return client.adapt(OpenShiftClient.class);
} catch (KubernetesClientException e) {
KubernetesClientErrorHandler.handle(e);
return null; // will never happen
}
}

/**
* Apply the openshift resources and wait until ImageStreamTags are created.
*
Expand Down Expand Up @@ -391,7 +400,7 @@ private static void applyOpenshiftResources(OpenShiftClient client, List<HasMeta
OpenshiftUtils.waitForImageStreamTags(client, buildResources, 2, TimeUnit.MINUTES);

} catch (KubernetesClientException e) {
KubernetesClientErrorHanlder.handle(e);
KubernetesClientErrorHandler.handle(e);
}
}

Expand Down Expand Up @@ -499,7 +508,7 @@ private static Stream<Build> runningBuildsOf(OpenShiftClient client, BuildConfig

private static RuntimeException openshiftException(Throwable t) {
if (t instanceof KubernetesClientException) {
KubernetesClientErrorHanlder.handle((KubernetesClientException) t);
KubernetesClientErrorHandler.handle((KubernetesClientException) t);
}
return new RuntimeException("Execution of openshift build failed. See build output for more details", t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import io.quarkus.deployment.pkg.builditem.NativeImageBuildItem;
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem;
import io.quarkus.deployment.pkg.steps.NativeBuild;
import io.quarkus.kubernetes.client.deployment.KubernetesClientErrorHanlder;
import io.quarkus.kubernetes.client.deployment.KubernetesClientErrorHandler;
import io.quarkus.kubernetes.client.spi.KubernetesClientBuildItem;
import io.quarkus.kubernetes.spi.KubernetesCommandBuildItem;
import io.quarkus.kubernetes.spi.KubernetesEnvBuildItem;
Expand Down Expand Up @@ -313,7 +313,7 @@ private static void applyS2iResources(OpenShiftClient client, List<HasMetadata>
S2iUtils.waitForImageStreamTags(client, buildResources, 2, TimeUnit.MINUTES);

} catch (KubernetesClientException e) {
KubernetesClientErrorHanlder.handle(e);
KubernetesClientErrorHandler.handle(e);
}
}

Expand Down Expand Up @@ -400,7 +400,7 @@ private static Stream<Build> runningBuildsOf(OpenShiftClient client, BuildConfig

private static RuntimeException s2iException(Throwable t) {
if (t instanceof KubernetesClientException) {
KubernetesClientErrorHanlder.handle((KubernetesClientException) t);
KubernetesClientErrorHandler.handle((KubernetesClientException) t);
}
return new RuntimeException("Execution of s2i build failed. See s2i output for more details", t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import org.jboss.logging.Logger;

public class KubernetesClientErrorHanlder {
public class KubernetesClientErrorHandler {

private static final Logger LOG = Logger.getLogger(KubernetesClientErrorHanlder.class);
private static final Logger LOG = Logger.getLogger(KubernetesClientErrorHandler.class);

public static void handle(Exception e) {
if (e.getCause() instanceof SSLHandshakeException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem;
import io.quarkus.deployment.pkg.builditem.DeploymentResultBuildItem;
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem;
import io.quarkus.kubernetes.client.deployment.KubernetesClientErrorHanlder;
import io.quarkus.kubernetes.client.deployment.KubernetesClientErrorHandler;
import io.quarkus.kubernetes.client.spi.KubernetesClientBuildItem;
import io.quarkus.kubernetes.spi.KubernetesDeploymentTargetBuildItem;

Expand Down Expand Up @@ -192,7 +192,7 @@ private DeploymentResultBuildItem deploy(DeploymentTargetEntry deploymentTarget,
} catch (FileNotFoundException e) {
throw new IllegalStateException("Can't find generated kubernetes manifest: " + manifest.getAbsolutePath());
} catch (KubernetesClientException e) {
KubernetesClientErrorHanlder.handle(e);
KubernetesClientErrorHandler.handle(e);
throw e;
} catch (IOException e) {
throw new RuntimeException("Error closing file: " + manifest.getAbsolutePath());
Expand Down