Skip to content

Commit

Permalink
Better error handling of left-over pod
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Scholz <[email protected]>
  • Loading branch information
scholzj committed Dec 26, 2023
1 parent 7e6a608 commit 0180cfa
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/cz/scholz/kekspose/Proxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.fabric8.kubernetes.api.model.VolumeBuilder;
import io.fabric8.kubernetes.api.model.VolumeMountBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.KubernetesClientTimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -71,8 +72,16 @@ public Proxy(KubernetesClient client, String namespace, String name, Integer ini
*/
public void deployProxy() {
LOGGER.info("Deploying the proxy");
client.configMaps().inNamespace(namespace).resource(configMap()).create();
client.pods().inNamespace(namespace).resource(pod()).create();

try {
client.configMaps().inNamespace(namespace).resource(configMap()).create();
client.pods().inNamespace(namespace).resource(pod()).create();
} catch (KubernetesClientException e) {
if (e.getCode() == 409) {
LOGGER.error("The Proxy Pod or ConfigMap seem to already exist.");
throw new Keksception("The Proxy Pod or ConfigMap seem to already exist");
}
}

try {
LOGGER.info("Waiting for the proxy to become ready");
Expand Down

0 comments on commit 0180cfa

Please sign in to comment.