fix: Correct prervious roles validation fixup for minikube (#94)
Signed-off-by: Max Shaposhnik <mshaposh@redhat.com>pull/92/head^2
parent
c273bd43a5
commit
3604c9a709
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue