Skip to content

Commit

Permalink
Remove code that supports namespace strategies other than per-user (#…
Browse files Browse the repository at this point in the history
…19763)

* Remove code that supports namespace strategies other than per-user

Signed-off-by: Sergii Kabashniuk <[email protected]>
  • Loading branch information
skabashnyuk authored May 12, 2021
1 parent 754c2c8 commit 14107b5
Show file tree
Hide file tree
Showing 20 changed files with 149 additions and 954 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,6 @@ che.infra.kubernetes.singlehost.gateway.configmap_labels=app=che,component=che-g
# Used to generate domain for a server in a workspace in case property `che.infra.kubernetes.server_strategy` is set to `multi-host`
che.infra.kubernetes.ingress.domain=

# DEPRECATED - Do not change the value of this property otherwise the existing workspaces will loose data. Do not
# set it on new installations.
#
# Defines Kubernetes namespace in which all workspaces will be created.
# If not set, every workspace will be created in a new namespace, where namespace = workspace id
# It's possible to use `<username>` and `<userid>` placeholders (for example: `che-workspace-<username>`).
# In that case, new namespace will be created for each user. Service account with permission
# to create new namespace must be used.
#
# Ignored for OpenShift infra. Use `che.infra.openshift.project` instead
#
# If the namespace pointed to by this property exists, it will be used for all workspaces. If it does not exist,
# the namespace specified by `che.infra.kubernetes.namespace.default` will be created and used.
# This parameter is subject to removal in future releases.
# Legacy workspaces located in this namespace may become unreachable in future releases.
# See the documentation about possible next steps.
che.infra.kubernetes.namespace=

# Indicates whether {prod-short} server is allowed to create {orch-namespace} for user
# workspaces, or they're intended to be created manually by cluster administrator.
# This property is also used by the OpenShift infra.
Expand All @@ -315,9 +297,8 @@ che.infra.kubernetes.namespace.creation_allowed=true
# Defines Kubernetes default namespace in which user's workspaces are created
# if user does not override it.
# It's possible to use `<username>` and `<userid>` placeholders (for example: `che-workspace-<username>`).
# In that case, new namespace will be created for each user (or workspace).
# In that case, new namespace will be created for each user.
# Used by OpenShift infra as well to specify a Project.
# The `<workspaceid>` placeholder is deprecated and is subject to removal in future releases.
# The `<username>` or `<userid>` placeholder is mandatory.
che.infra.kubernetes.namespace.default=<username>-che

Expand All @@ -337,10 +318,6 @@ che.infra.kubernetes.namespace.labels=app.kubernetes.io/part-of=che.eclipse.org,
# It's possible to use `<username>` placeholder to specify the {orch-namespace} to concrete user.
che.infra.kubernetes.namespace.annotations=che.eclipse.org/username=<username>

# Defines if a user is able to specify {orch-namespace} different from the default.
# It's NOT RECOMMENDED to configured true without OAuth configured. This property is also used by the OpenShift infra.
che.infra.kubernetes.namespace.allow_user_defined=false

# Defines Kubernetes Service Account name which should be specified to be bound to all workspaces Pods.
# the {prod-short} Operator that Kubernetes Infrastructure will not create the service account and it should exist.
# OpenShift infrastructure will check if project is predefined(if `che.infra.openshift.project` is not empty):
Expand Down Expand Up @@ -561,25 +538,6 @@ che.infra.kubernetes.trusted_ca.dest_configmap_labels=

### OpenShift Infra parameters

# Since OpenShift infrastructure reuse Kubernetes infrastructure components
# OpenShift infrastructure reuse most of the Kubernetes configuration attributes.

# DEPRECATED - Do not change the value of this property otherwise the existing workspaces will loose data. Do not
# set it on new installations.
#
# Defines OpenShift namespace in which all workspaces will be created.
# If not set, every workspace will be created in a new project, where project name = workspace id
# It's possible to use `<username>` and `<userid>` placeholders (for example: `che-workspace-<username>`).
# In that case, new project will be created for each user. OpenShift OAuth or service account with
# permission to create new projects must be used.
#
# If the project pointed to by this property exists, it will be used for all workspaces. If it does not exist,
# the namespace specified by the `che.infra.kubernetes.namespace.default` will be created and used.
# This parameter is subject to removal in future releases.
# Legacy workspaces located in this namespace may become unreachable in future releases.
# See the documentation for possible next steps.
che.infra.openshift.project=

# Comma separated list of labels to add to the CA certificates ConfigMap in user workspace.
# See `che.infra.kubernetes.trusted_ca.dest_configmap` property.
# This default value is used for automatic cluster CA bundle injection in OpenShift 4.
Expand Down Expand Up @@ -652,7 +610,6 @@ che.workspace.devfile_registry_internal_url=NULL
# Will work only if:
# - `che.infra.kubernetes.pvc.strategy='common'`
# - `che.limits.user.workspaces.run.count=1`
# - `che.infra.kubernetes.namespace.allow_user_defined=false`
# - `che.infra.kubernetes.namespace.default` contains `<username>`
# in other cases remove `async` from the list.
che.workspace.storage.available_types=persistent,ephemeral,async
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
*
* <ul>
* <li>che.infra.kubernetes.namespace.default=<username>-che
* <li>che.infra.kubernetes.namespace.allow_user_defined=false
* <li>che.infra.kubernetes.pvc.strategy=common
* <li>che.limits.user.workspaces.run.count=1
* </ul>
Expand All @@ -56,7 +55,6 @@ public class AsyncStorageModeValidator implements WorkspaceAttributeValidator {
private static final Logger LOG = LoggerFactory.getLogger(AsyncStorageModeValidator.class);

private final String pvcStrategy;
private final boolean allowUserDefinedNamespaces;
private final int runtimesPerUser;
private final boolean isNamespaceStrategyNotValid;
private final boolean isPvcStrategyNotValid;
Expand All @@ -65,13 +63,10 @@ public class AsyncStorageModeValidator implements WorkspaceAttributeValidator {
@Inject
public AsyncStorageModeValidator(
@Named("che.infra.kubernetes.pvc.strategy") String pvcStrategy,
@Named("che.infra.kubernetes.namespace.allow_user_defined")
boolean allowUserDefinedNamespaces,
@Nullable @Named("che.infra.kubernetes.namespace.default") String defaultNamespaceName,
@Named("che.limits.user.workspaces.run.count") int runtimesPerUser) {

this.pvcStrategy = pvcStrategy;
this.allowUserDefinedNamespaces = allowUserDefinedNamespaces;
this.runtimesPerUser = runtimesPerUser;

this.isPvcStrategyNotValid = !COMMON_STRATEGY.equals(pvcStrategy);
Expand All @@ -85,7 +80,6 @@ public void validate(Map<String, String> attributes) throws ValidationException
if (parseBoolean(attributes.get(ASYNC_PERSIST_ATTRIBUTE))) {
isEphemeralAttributeValidation(attributes);
pvcStrategyValidation();
alowUserDefinedNamespaceValidation();
nameSpaceStrategyValidation();
runtimesPerUserValidation();
}
Expand All @@ -97,7 +91,6 @@ public void validateUpdate(Map<String, String> existing, Map<String, String> upd
if (parseBoolean(update.get(ASYNC_PERSIST_ATTRIBUTE))) {
if (isEphemeral(existing) || isEphemeral(update)) {
pvcStrategyValidation();
alowUserDefinedNamespaceValidation();
nameSpaceStrategyValidation();
runtimesPerUserValidation();
} else {
Expand Down Expand Up @@ -139,17 +132,6 @@ private void nameSpaceStrategyValidation() throws ValidationException {
}
}

private void alowUserDefinedNamespaceValidation() throws ValidationException {
if (allowUserDefinedNamespaces) {
String message =
format(
"Workspace configuration not valid: Asynchronous storage available only if 'che.infra.kubernetes.namespace.allow_user_defined' set to 'false', but got '%s'",
allowUserDefinedNamespaces);
LOG.warn(message);
throw new ValidationException(message);
}
}

private void pvcStrategyValidation() throws ValidationException {
if (isPvcStrategyNotValid) {
String message =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ public String evaluateInfraNamespace(NamespaceResolutionContext resolutionCtx)
return namespaceFactory.evaluateNamespaceName(resolutionCtx);
}

@Override
public String evaluateLegacyInfraNamespace(NamespaceResolutionContext resolutionContext)
throws InfrastructureException {
return namespaceFactory.evaluateLegacyNamespaceName(resolutionContext);
}

@Override
public boolean isNamespaceValid(String name) {
return NamespaceNameValidator.isValid(name);
Expand Down
Loading

0 comments on commit 14107b5

Please sign in to comment.