public String extractServiceUrl()

in src/main/java/com/epam/aidial/util/KubernetesUtils.java [66:98]


    public String extractServiceUrl(V1Service service) {
        String name = service.getMetadata().getName();
        V1ServiceStatus status = service.getStatus();
        if (status != null && status.getConditions() != null) {
            for (V1Condition condition : status.getConditions()) {
                if ("Ready".equals(condition.getType())) {
                    if ("True".equals(condition.getStatus())) {
                        if (StringUtils.isBlank(status.getUrl())) {
                            throw new IllegalStateException("Empty service URL.");
                        }

                        return status.getUrl();
                    }

                    if ("False".equals(condition.getStatus())) {
                        // Cannot throw an exception here because in some cases it recovers,
                        // and it's not clear how to differentiate those.
                        log.warn("Failed to setup service %s: %s".formatted(name, condition.getMessage()));
                        return null;
                    }
                }

                if (condition.getMessage() == null) {
                    log.info("Service: {}, status: {}", name, condition.getType());
                } else {
                    log.info("Service: {}, status: {}, reason: {}, message: {}",
                            name, condition.getType(), condition.getReason(), condition.getMessage());
                }
            }
        }

        return null;
    }