Skip to content

Commit

Permalink
feat: Add per-user storage-class option
Browse files Browse the repository at this point in the history
The 'per-user' storage type is an alternate storage-class name for the 'common' storage class.
In other words, it is an alias for the 'common' storage class and behaves in the same manner.

Part of eclipse-che/che#21405

Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
  • Loading branch information
AObuchow committed Jul 15, 2022
1 parent 2a44ff6 commit be6d181
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion controllers/workspace/devworkspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func (r *DevWorkspaceReconciler) dwPVCHandler(obj client.Object) []reconcile.Req
var reconciles []reconcile.Request
for _, workspace := range dwList.Items {
storageType := workspace.Spec.Template.Attributes.GetString(constants.DevWorkspaceStorageTypeAttribute, nil)
if storageType == constants.CommonStorageClassType || storageType == "" {
if storageType == constants.CommonStorageClassType || storageType == constants.PerUserStorageClassType || storageType == "" {
reconciles = append(reconciles, reconcile.Request{
NamespacedName: types.NamespacedName{
Name: workspace.GetName(),
Expand Down
7 changes: 5 additions & 2 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ const (

// Constants describing storage classes supported by the controller

// CommonStorageClassType defines the 'common' storage policy -- one PVC is provisioned per namespace and all devworkspace storage
// is mounted in it on subpaths according to devworkspace ID.
// CommonStorageClassType defines the 'common' storage policy, which is an alias of the 'per-user' storage policy, and operates in the same fashion as the 'per-user' storage policy.
// The 'common' storage policy exists only for legacy compatibility.
CommonStorageClassType = "common"
// PerUserStorageClassType defines the 'per-user' storage policy -- one PVC is provisioned per namespace and all devworkspace storage
// is mounted in it on subpaths according to devworkspace ID.
PerUserStorageClassType = "per-user"
// AsyncStorageClassType defines the 'asynchronous' storage policy. An rsync sidecar is added to devworkspaces that uses SSH to connect
// to a storage deployment that mounts a common PVC for the namespace.
AsyncStorageClassType = "async"
Expand Down
3 changes: 3 additions & 0 deletions pkg/provision/storage/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func GetProvisioner(workspace *dw.DevWorkspace) (Provisioner, error) {
return &AsyncStorageProvisioner{}, nil
case constants.EphemeralStorageClassType:
return &EphemeralStorageProvisioner{}, nil
case constants.PerUserStorageClassType:
workspace.Spec.Template.Attributes.PutString(constants.DevWorkspaceStorageTypeAttribute, constants.CommonStorageClassType)
return &CommonStorageProvisioner{}, nil
default:
return nil, UnsupportedStorageStrategy
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provision/storage/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func getSharedPVCWorkspaceCount(namespace string, api sync.ClusterAPI) (total in
}
storageClass := workspace.Spec.Template.Attributes.GetString(constants.DevWorkspaceStorageTypeAttribute, nil)
// Note, if the storageClass attribute isn't set (ie. storageClass == ""), then the storage class being used is "common"
if storageClass == constants.AsyncStorageClassType || storageClass == constants.CommonStorageClassType || storageClass == "" {
if storageClass == constants.AsyncStorageClassType || storageClass == constants.CommonStorageClassType || storageClass == constants.PerUserStorageClassType || storageClass == "" {
total++
}
}
Expand Down

0 comments on commit be6d181

Please sign in to comment.