fix: Correct prervious roles validation fixup for minikube (#94)

Signed-off-by: Max Shaposhnik <mshaposh@redhat.com>
pull/92/head^2
Max Shaposhnik 2021-09-03 08:55:14 +03:00 committed by GitHub
parent c273bd43a5
commit 3604c9a709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -131,8 +131,8 @@ public abstract class AbstractWorkspaceServiceAccount<
serviceAccountName + "-view");
// metrics role
if (k8sClient.supportsApiPath("/apis/metrics.k8s.io")) {
try {
try {
if (k8sClient.supportsApiPath("/apis/metrics.k8s.io")) {
ensureRoleWithBinding(
k8sClient,
buildRole(
@ -142,14 +142,14 @@ public abstract class AbstractWorkspaceServiceAccount<
singletonList("metrics.k8s.io"),
Arrays.asList("list", "get", "watch")),
serviceAccountName + "-metrics");
} catch (KubernetesClientException e) {
// workaround to unblock workspace start if no permissions for metrics
if (e.getCode() == 403) {
LOG.warn(
"Unable to add metrics roles due to insufficient permissions. Workspace metrics will be disabled.");
} else {
throw e;
}
}
} catch (KubernetesClientException e) {
// workaround to unblock workspace start if no permissions for metrics
if (e.getCode() == 403) {
LOG.warn(
"Unable to add metrics roles due to insufficient permissions. Workspace metrics will be disabled.");
} else {
throw e;
}
}

View File

@ -111,7 +111,7 @@ public class KubernetesWorkspaceServiceAccountTest {
}
@Test
public void shouldNotCreateMetricsRoleIfAPIEnabledOnServer() throws Exception {
public void shouldNotCreateMetricsRoleIfAPINotEnabledOnServer() throws Exception {
KubernetesClient localK8sClient = spy(serverMock.getClient());
when(localK8sClient.supportsApiPath(eq("/apis/metrics.k8s.io"))).thenReturn(false);
when(clientFactory.create(anyString())).thenReturn(localK8sClient);