redhat-developer / intellij-common

4 stars 11 forks source link

ClusterHelper.isOpenShift thinks k8 cluster with expired token is OpenShift cluster #216

Closed adietish closed 5 months ago

adietish commented 5 months ago

Current implementation of ClusterHelper.isOpenShift thinks that a kubernetes cluster, where the token is expired, is an OpenShift cluster.

    public static boolean isOpenShift(KubernetesClient client) {
        OpenShiftClient osClient = client.adapt(OpenShiftClient.class);
        try {
            return osClient.isSupported();
        } catch (KubernetesClientException e) {
            return e.getCode() == HttpURLConnection.HTTP_UNAUTHORIZED;
        }
    }

An expired token causes a KubernetesClientException with error code 401 and thus erroneously returns true.

This prevents OIDC tokens from being refreshed in https://github.com/redhat-developer/intellij-kubernetes/issues/726 as