use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project devspaces-images by redhat-developer.
the class AsyncStorageProvisioner method provision.
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws InfrastructureException {
if (!parseBoolean(k8sEnv.getAttributes().get(ASYNC_PERSIST_ATTRIBUTE))) {
return;
}
if (!COMMON_STRATEGY.equals(pvcStrategy)) {
String message = format("Workspace configuration not valid: Asynchronous storage available only for 'common' PVC strategy, but got %s", pvcStrategy);
LOG.warn(message);
k8sEnv.addWarning(new WarningImpl(4200, message));
throw new InfrastructureException(message);
}
if (!isEphemeral(k8sEnv.getAttributes())) {
String message = format("Workspace configuration not valid: Asynchronous storage available only if '%s' attribute set to false", PERSIST_VOLUMES_ATTRIBUTE);
LOG.warn(message);
k8sEnv.addWarning(new WarningImpl(4200, message));
throw new InfrastructureException(message);
}
String namespace = identity.getInfrastructureNamespace();
String userId = identity.getOwnerId();
KubernetesClient k8sClient = kubernetesClientFactory.create(identity.getWorkspaceId());
String configMapName = namespace + ASYNC_STORAGE_CONFIG;
createPvcIfNotExist(k8sClient, namespace, userId);
createConfigMapIfNotExist(k8sClient, namespace, configMapName, userId, k8sEnv);
createAsyncStoragePodIfNotExist(k8sClient, namespace, configMapName, userId);
createStorageServiceIfNotExist(k8sClient, namespace, userId);
}
use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project devspaces-images by redhat-developer.
the class RestartPolicyRewriter method rewriteRestartPolicy.
private void rewriteRestartPolicy(PodSpec podSpec, String podName, KubernetesEnvironment env) {
final String restartPolicy = podSpec.getRestartPolicy();
if (restartPolicy != null && !DEFAULT_RESTART_POLICY.equalsIgnoreCase(restartPolicy)) {
final String warnMsg = format(Warnings.RESTART_POLICY_SET_TO_NEVER_WARNING_MESSAGE_FMT, restartPolicy, podName, DEFAULT_RESTART_POLICY);
env.addWarning(new WarningImpl(Warnings.RESTART_POLICY_SET_TO_NEVER_WARNING_CODE, warnMsg));
}
podSpec.setRestartPolicy(DEFAULT_RESTART_POLICY);
}
use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project devspaces-images by redhat-developer.
the class DeploymentMetadataProvisionerTest method shouldAddWarningIfNotAbleToGetWorkspaceAttributes.
@Test
public void shouldAddWarningIfNotAbleToGetWorkspaceAttributes() throws NotFoundException, ServerException, InfrastructureException {
// given
doThrow(new NotFoundException("Element not found")).when(workspaceManager).getWorkspace(eq(WS_ID));
// when
provisioner.provision(k8sEnv, identity);
// then
ArgumentCaptor<WarningImpl> argumentCaptor = ArgumentCaptor.forClass(WarningImpl.class);
verify(k8sEnv).addWarning(argumentCaptor.capture());
assertEquals(argumentCaptor.getAllValues().size(), 1);
assertEquals(argumentCaptor.getValue(), new WarningImpl(4200, "Not able to find workspace attributes for " + WS_ID + ". Reason Element not found"));
}
use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project devspaces-images by redhat-developer.
the class DeploymentMetadataProvisionerTest method shouldAddWarningIfNotAbleToGetWorkspaceAttributesServerException.
@Test
public void shouldAddWarningIfNotAbleToGetWorkspaceAttributesServerException() throws NotFoundException, ServerException, InfrastructureException {
// given
doThrow(new ServerException("Connection problem")).when(workspaceManager).getWorkspace(eq(WS_ID));
// when
provisioner.provision(k8sEnv, identity);
// then
ArgumentCaptor<WarningImpl> argumentCaptor = ArgumentCaptor.forClass(WarningImpl.class);
verify(k8sEnv).addWarning(argumentCaptor.capture());
assertEquals(argumentCaptor.getAllValues().size(), 1);
assertEquals(argumentCaptor.getValue(), new WarningImpl(NOT_ABLE_TO_PROVISION_WORKSPACE_DEPLOYMENT, "Not able to find workspace attributes for " + WS_ID + ". Reason Connection problem"));
}
use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project devspaces-images by redhat-developer.
the class GitConfigProvisionerTest method testShouldExpectWarningWhenJsonObjectInPreferencesIsNotValid.
@Test
public void testShouldExpectWarningWhenJsonObjectInPreferencesIsNotValid() throws Exception {
Map<String, String> preferences = singletonMap("theia-user-preferences", "{#$%}");
when(preferenceManager.find(eq("id"), eq("theia-user-preferences"))).thenReturn(preferences);
gitConfigProvisioner.provision(k8sEnv, runtimeIdentity);
verifyNoMoreInteractions(runtimeIdentity);
List<Warning> warnings = k8sEnv.getWarnings();
assertEquals(warnings.size(), 1);
Warning actualWarning = warnings.get(0);
String warnMsg = format(Warnings.JSON_IS_NOT_A_VALID_REPRESENTATION_FOR_AN_OBJECT_OF_TYPE_MESSAGE_FMT, "java.io.EOFException: End of input at line 1 column 6 path $.");
Warning expectedWarning = new WarningImpl(Warnings.JSON_IS_NOT_A_VALID_REPRESENTATION_FOR_AN_OBJECT_OF_TYPE_WARNING_CODE, warnMsg);
assertEquals(expectedWarning, actualWarning);
}
Aggregations