Fix error message when workspace has invalid async storage config (#19017)

* Fix error message when workspace has invalid async storage config

Fix error message when workspace is started with

attributes:
  asyncPersist: 'true'

to correctly mention that persistVolumes: 'false' is required for
asyncPersist: 'true'

Verify message of errors in async storage provisioning tests

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
7.28.x
Angel Misevski 2021-02-22 19:59:53 -05:00 committed by GitHub
parent 3f6473f6b8
commit a1d425a989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import static java.lang.String.format;
import static java.lang.String.valueOf;
import static java.util.Collections.singletonList;
import static org.eclipse.che.api.workspace.shared.Constants.ASYNC_PERSIST_ATTRIBUTE;
import static org.eclipse.che.api.workspace.shared.Constants.PERSIST_VOLUMES_ATTRIBUTE;
import static org.eclipse.che.workspace.infrastructure.kubernetes.Constants.CHE_DEPLOYMENT_NAME_LABEL;
import static org.eclipse.che.workspace.infrastructure.kubernetes.Constants.CHE_USER_ID_LABEL;
import static org.eclipse.che.workspace.infrastructure.kubernetes.Warnings.NOT_ABLE_TO_PROVISION_SSH_KEYS;
@ -169,7 +170,7 @@ public class AsyncStorageProvisioner {
String message =
format(
"Workspace configuration not valid: Asynchronous storage available only if '%s' attribute set to false",
ASYNC_PERSIST_ATTRIBUTE);
PERSIST_VOLUMES_ATTRIBUTE);
LOG.warn(message);
k8sEnv.addWarning(new WarningImpl(4200, message));
throw new InfrastructureException(message);

View File

@ -122,7 +122,10 @@ public class AsyncStorageProvisionerTest {
sshPair = new SshPairImpl(USER, "internal", SSH_KEY_NAME, "", "");
}
@Test(expectedExceptions = InfrastructureException.class)
@Test(
expectedExceptions = InfrastructureException.class,
expectedExceptionsMessageRegExp =
"Workspace configuration not valid: Asynchronous storage available only for 'common' PVC strategy.*")
public void shouldThrowExceptionIfNotCommonStrategy() throws Exception {
AsyncStorageProvisioner asyncStorageProvisioner =
new AsyncStorageProvisioner(
@ -142,7 +145,10 @@ public class AsyncStorageProvisionerTest {
verifyNoMoreInteractions(identity);
}
@Test(expectedExceptions = InfrastructureException.class)
@Test(
expectedExceptions = InfrastructureException.class,
expectedExceptionsMessageRegExp =
"Workspace configuration not valid: Asynchronous storage available only if 'persistVolumes' attribute set to false")
public void shouldThrowExceptionIfAsyncStorageForNotEphemeralWorkspace() throws Exception {
Map attributes = new HashMap<>(2);
attributes.put(ASYNC_PERSIST_ATTRIBUTE, "true");