Skip to content

Commit

Permalink
update Che CRD for DWO per-user strategy storage configuration (#1442)
Browse files Browse the repository at this point in the history
* update Che CRD for DWO per-user strategy storage configuration

Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
Co-authored-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
AObuchow and tolusha authored Aug 30, 2022
1 parent 95b8b62 commit aa27398
Show file tree
Hide file tree
Showing 17 changed files with 241 additions and 73 deletions.
10 changes: 8 additions & 2 deletions api/checluster_conversion_from_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,14 @@ func TestConvertFrom(t *testing.T) {
GitTrustedCertsConfigMapName: "che-git-self-signed-cert",
},
Storage: chev2.WorkspaceStorage{
Pvc: &chev2.PVC{
PerUserStrategyPvcConfig: &chev2.PVC{
ClaimSize: "StorageClaimSize",
StorageClass: "StorageClass",
},
PerWorkspaceStrategyPvcConfig: &chev2.PVC{
ClaimSize: "PerWorkspaceStorageClaimSize",
StorageClass: "PerWorkspaceStorageClass",
},
PvcStrategy: "PvcStrategy",
},
DefaultPlugins: []chev2.WorkspaceDefaultPlugins{
Expand Down Expand Up @@ -554,8 +558,10 @@ func TestConvertFrom(t *testing.T) {
})
assert.Equal(t, checlusterv1.Spec.Server.WorkspacesDefaultPlugins, []chev1.WorkspacesDefaultPlugins{{Editor: "Editor", Plugins: []string{"Plugins_1", "Plugins_2"}}})

assert.Equal(t, checlusterv1.Spec.Storage.PvcStrategy, "PvcStrategy")
assert.Equal(t, checlusterv1.Spec.Storage.PostgresPVCStorageClassName, "DatabaseStorageClass")
assert.Equal(t, checlusterv1.Spec.Storage.PvcClaimSize, "StorageClaimSize")
assert.Equal(t, checlusterv1.Spec.Storage.PvcStrategy, "PvcStrategy")
assert.Equal(t, checlusterv1.Spec.Storage.WorkspacePVCStorageClassName, "StorageClass")
assert.Equal(t, checlusterv1.Spec.Storage.PerWorkspaceStrategyPvcClaimSize, "PerWorkspaceStorageClaimSize")
assert.Equal(t, checlusterv1.Spec.Storage.PerWorkspaceStrategyPVCStorageClassName, "PerWorkspaceStorageClass")
}
16 changes: 10 additions & 6 deletions api/checluster_conversion_to_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,12 @@ func TestConvertTo(t *testing.T) {
},
},
Storage: chev1.CheClusterSpecStorage{
PvcStrategy: "PvcStrategy",
PvcClaimSize: "WorkspacePvcClaimSize",
PostgresPVCStorageClassName: "PostgresPVCStorageClassName",
WorkspacePVCStorageClassName: "WorkspacePVCStorageClassName",
PvcStrategy: "PvcStrategy",
PvcClaimSize: "WorkspacePvcClaimSize",
PostgresPVCStorageClassName: "PostgresPVCStorageClassName",
WorkspacePVCStorageClassName: "WorkspacePVCStorageClassName",
PerWorkspaceStrategyPVCStorageClassName: "PerWorkspaceStrategyPVCStorageClassName",
PerWorkspaceStrategyPvcClaimSize: "PerWorkspaceStrategyPvcClaimSize",
},
Metrics: chev1.CheClusterSpecMetrics{
Enable: true,
Expand Down Expand Up @@ -496,8 +498,10 @@ func TestConvertTo(t *testing.T) {
assert.Equal(t, checlusterv2.Spec.Components.PluginRegistry.OpenVSXURL, "open-vsx-registry")
assert.Equal(t, checlusterv2.Spec.Components.PluginRegistry.ExternalPluginRegistries, []chev2.ExternalPluginRegistry{{Url: "PluginRegistryUrl"}})

assert.Equal(t, checlusterv2.Spec.DevEnvironments.Storage.Pvc.ClaimSize, "WorkspacePvcClaimSize")
assert.Equal(t, checlusterv2.Spec.DevEnvironments.Storage.Pvc.StorageClass, "WorkspacePVCStorageClassName")
assert.Equal(t, checlusterv2.Spec.DevEnvironments.Storage.PerUserStrategyPvcConfig.ClaimSize, "WorkspacePvcClaimSize")
assert.Equal(t, checlusterv2.Spec.DevEnvironments.Storage.PerUserStrategyPvcConfig.StorageClass, "WorkspacePVCStorageClassName")
assert.Equal(t, checlusterv2.Spec.DevEnvironments.Storage.PerWorkspaceStrategyPvcConfig.ClaimSize, "PerWorkspaceStrategyPvcClaimSize")
assert.Equal(t, checlusterv2.Spec.DevEnvironments.Storage.PerWorkspaceStrategyPvcConfig.StorageClass, "PerWorkspaceStrategyPVCStorageClassName")
assert.Equal(t, checlusterv2.Spec.DevEnvironments.Storage.PvcStrategy, "PvcStrategy")
assert.Equal(t, checlusterv2.Spec.DevEnvironments.SecondsOfInactivityBeforeIdling, pointer.Int32Ptr(1800))
assert.Equal(t, checlusterv2.Spec.DevEnvironments.SecondsOfRunBeforeIdling, pointer.Int32Ptr(-1))
Expand Down
2 changes: 1 addition & 1 deletion api/checluster_round_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func TestRoundConvertCheClusterV2(t *testing.T) {
GitTrustedCertsConfigMapName: "che-git-self-signed-cert",
},
Storage: chev2.WorkspaceStorage{
Pvc: &chev2.PVC{
PerUserStrategyPvcConfig: &chev2.PVC{
ClaimSize: "StorageClaimSize",
StorageClass: "StorageClass",
},
Expand Down
11 changes: 8 additions & 3 deletions api/v1/checluster_conversion_from.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,14 @@ func (dst *CheCluster) convertFrom_Storage(src *chev2.CheCluster) error {
}

dst.Spec.Storage.PvcStrategy = src.Spec.DevEnvironments.Storage.PvcStrategy
if src.Spec.DevEnvironments.Storage.Pvc != nil {
dst.Spec.Storage.PvcClaimSize = src.Spec.DevEnvironments.Storage.Pvc.ClaimSize
dst.Spec.Storage.WorkspacePVCStorageClassName = src.Spec.DevEnvironments.Storage.Pvc.StorageClass
if src.Spec.DevEnvironments.Storage.PerUserStrategyPvcConfig != nil {
dst.Spec.Storage.PvcClaimSize = src.Spec.DevEnvironments.Storage.PerUserStrategyPvcConfig.ClaimSize
dst.Spec.Storage.WorkspacePVCStorageClassName = src.Spec.DevEnvironments.Storage.PerUserStrategyPvcConfig.StorageClass
}

if src.Spec.DevEnvironments.Storage.PerWorkspaceStrategyPvcConfig != nil {
dst.Spec.Storage.PerWorkspaceStrategyPvcClaimSize = src.Spec.DevEnvironments.Storage.PerWorkspaceStrategyPvcConfig.ClaimSize
dst.Spec.Storage.PerWorkspaceStrategyPVCStorageClassName = src.Spec.DevEnvironments.Storage.PerWorkspaceStrategyPvcConfig.StorageClass
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion api/v1/checluster_conversion_to.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ func (src *CheCluster) convertTo_DevEnvironments(dst *chev2.CheCluster) error {
}

func (src *CheCluster) convertTo_Workspaces_Storage(dst *chev2.CheCluster) error {
dst.Spec.DevEnvironments.Storage.Pvc = toCheV2Pvc(src.Spec.Storage.PvcClaimSize, src.Spec.Storage.WorkspacePVCStorageClassName)
dst.Spec.DevEnvironments.Storage.PerUserStrategyPvcConfig = toCheV2Pvc(src.Spec.Storage.PvcClaimSize, src.Spec.Storage.WorkspacePVCStorageClassName)
dst.Spec.DevEnvironments.Storage.PerWorkspaceStrategyPvcConfig = toCheV2Pvc(src.Spec.Storage.PerWorkspaceStrategyPvcClaimSize, src.Spec.Storage.PerWorkspaceStrategyPVCStorageClassName)
dst.Spec.DevEnvironments.Storage.PvcStrategy = src.Spec.Storage.PvcStrategy
return nil
}
Expand Down
6 changes: 6 additions & 0 deletions api/v1/checluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,12 @@ type CheClusterSpecStorage struct {
// Storage class for the Persistent Volume Claims dedicated to the Che workspaces. When omitted or left blank, a default storage class is used.
// +optional
WorkspacePVCStorageClassName string `json:"workspacePVCStorageClassName,omitempty"`
// Size of the persistent volume claim for workspaces.
// +optional
PerWorkspaceStrategyPvcClaimSize string `json:"perWorkspaceStrategyPvcClaimSize,omitempty"`
// Storage class for the Persistent Volume Claims dedicated to the Che workspaces. When omitted or left blank, a default storage class is used.
// +optional
PerWorkspaceStrategyPVCStorageClassName string `json:"perWorkspaceStrategyPVCStorageClassName,omitempty"`
}

// +k8s:openapi-gen=true
Expand Down
18 changes: 11 additions & 7 deletions api/v2/checluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type CheClusterSpec struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=1
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Development environments"
// +kubebuilder:default:={defaultComponents: {{name: universal-developer-image, container: {image: "quay.io/devfile/universal-developer-image:ubi8-38da5c2"}}}, defaultEditor: eclipse/che-theia/latest, storage: {pvcStrategy: common}, defaultNamespace: {template: <username>-che}, secondsOfInactivityBeforeIdling:1800, secondsOfRunBeforeIdling:-1}
// +kubebuilder:default:={defaultComponents: {{name: universal-developer-image, container: {image: "quay.io/devfile/universal-developer-image:ubi8-38da5c2"}}}, defaultEditor: eclipse/che-theia/latest, storage: {pvcStrategy: per-user}, defaultNamespace: {template: <username>-che}, secondsOfInactivityBeforeIdling:1800, secondsOfRunBeforeIdling:-1}
DevEnvironments CheClusterDevEnvironments `json:"devEnvironments"`
// Che components configuration.
// +optional
Expand All @@ -63,7 +63,7 @@ type CheClusterSpec struct {
type CheClusterDevEnvironments struct {
// Workspaces persistent storage.
// +optional
// +kubebuilder:default:={pvcStrategy: common}
// +kubebuilder:default:={pvcStrategy: per-user}
Storage WorkspaceStorage `json:"storage,omitempty"`
// Default plug-ins applied to DevWorkspaces.
// +optional
Expand Down Expand Up @@ -368,15 +368,19 @@ type TrustedCerts struct {

// Configuration settings related to the workspaces persistent storage.
type WorkspaceStorage struct {
// PVC settings.
// PVC settings when using the `per-user` PVC strategy.
// +optional
Pvc *PVC `json:"pvc,omitempty"`
PerUserStrategyPvcConfig *PVC `json:"perUserStrategyPvcConfig,omitempty"`
// PVC settings when using the `per-workspace` PVC strategy.
// +optional
PerWorkspaceStrategyPvcConfig *PVC `json:"perWorkspaceStrategyPvcConfig,omitempty"`
// Persistent volume claim strategy for the Che server.
// Only the `common` strategy (all workspaces PVCs in one volume) is supported .
// The supported strategies are: `per-user` (all workspaces PVCs in one volume)
// and 'per-workspace' (each workspace is given its own individual PVC).
// For details, see https://github.com/eclipse/che/issues/21185.
// +optional
// +kubebuilder:default:="common"
// +kubebuilder:validation:Enum=common;per-workspace
// +kubebuilder:default:="per-user"
// +kubebuilder:validation:Enum=common;per-user;per-workspace
PvcStrategy string `json:"pvcStrategy,omitempty"`
}

Expand Down
9 changes: 7 additions & 2 deletions api/v2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ metadata:
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/eclipse-che/che-operator
support: Eclipse Foundation
name: eclipse-che-preview-openshift.v7.53.0-662.next
name: eclipse-che-preview-openshift.v7.53.0-664.next
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -1389,7 +1389,7 @@ spec:
maturity: stable
provider:
name: Eclipse Foundation
version: 7.53.0-662.next
version: 7.53.0-664.next
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3785,6 +3785,14 @@ spec:
description: Configuration settings related to the persistent storage
used by the Che installation.
properties:
perWorkspaceStrategyPVCStorageClassName:
description: Storage class for the Persistent Volume Claims
dedicated to the Che workspaces. When omitted or left blank,
a default storage class is used.
type: string
perWorkspaceStrategyPvcClaimSize:
description: Size of the persistent volume claim for workspaces.
type: string
postgresPVCStorageClassName:
description: Storage class for the Persistent Volume Claim dedicated
to the PostgreSQL database. When omitted or left blank, a
Expand Down Expand Up @@ -5536,7 +5544,7 @@ spec:
secondsOfInactivityBeforeIdling: 1800
secondsOfRunBeforeIdling: -1
storage:
pvcStrategy: common
pvcStrategy: per-user
description: Development environment default configuration options.
properties:
defaultComponents:
Expand Down Expand Up @@ -7102,11 +7110,27 @@ spec:
type: integer
storage:
default:
pvcStrategy: common
pvcStrategy: per-user
description: Workspaces persistent storage.
properties:
pvc:
description: PVC settings.
perUserStrategyPvcConfig:
description: PVC settings when using the `per-user` PVC
strategy.
properties:
claimSize:
description: Persistent Volume Claim size. To update
the claim size, the storage class that provisions
it must support resizing.
type: string
storageClass:
description: Storage class for the Persistent Volume
Claim. When omitted or left blank, a default storage
class is used.
type: string
type: object
perWorkspaceStrategyPvcConfig:
description: PVC settings when using the `per-workspace`
PVC strategy.
properties:
claimSize:
description: Persistent Volume Claim size. To update
Expand All @@ -7120,12 +7144,15 @@ spec:
type: string
type: object
pvcStrategy:
default: common
description: Persistent volume claim strategy for the Che
server. Only the `common` strategy (all workspaces PVCs
in one volume) is supported . For details, see https://github.com/eclipse/che/issues/21185.
default: per-user
description: 'Persistent volume claim strategy for the Che
server. The supported strategies are: `per-user` (all
workspaces PVCs in one volume) and ''per-workspace'' (each
workspace is given its own individual PVC). For details,
see https://github.com/eclipse/che/issues/21185.'
enum:
- common
- per-user
- per-workspace
type: string
type: object
Expand Down
41 changes: 33 additions & 8 deletions config/crd/bases/org.eclipse.che_checlusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3669,6 +3669,14 @@ spec:
description: Configuration settings related to the persistent storage
used by the Che installation.
properties:
perWorkspaceStrategyPVCStorageClassName:
description: Storage class for the Persistent Volume Claims dedicated
to the Che workspaces. When omitted or left blank, a default
storage class is used.
type: string
perWorkspaceStrategyPvcClaimSize:
description: Size of the persistent volume claim for workspaces.
type: string
postgresPVCStorageClassName:
description: Storage class for the Persistent Volume Claim dedicated
to the PostgreSQL database. When omitted or left blank, a default
Expand Down Expand Up @@ -5393,7 +5401,7 @@ spec:
secondsOfInactivityBeforeIdling: 1800
secondsOfRunBeforeIdling: -1
storage:
pvcStrategy: common
pvcStrategy: per-user
description: Development environment default configuration options.
properties:
defaultComponents:
Expand Down Expand Up @@ -6908,11 +6916,26 @@ spec:
type: integer
storage:
default:
pvcStrategy: common
pvcStrategy: per-user
description: Workspaces persistent storage.
properties:
pvc:
description: PVC settings.
perUserStrategyPvcConfig:
description: PVC settings when using the `per-user` PVC strategy.
properties:
claimSize:
description: Persistent Volume Claim size. To update the
claim size, the storage class that provisions it must
support resizing.
type: string
storageClass:
description: Storage class for the Persistent Volume Claim.
When omitted or left blank, a default storage class
is used.
type: string
type: object
perWorkspaceStrategyPvcConfig:
description: PVC settings when using the `per-workspace` PVC
strategy.
properties:
claimSize:
description: Persistent Volume Claim size. To update the
Expand All @@ -6926,12 +6949,14 @@ spec:
type: string
type: object
pvcStrategy:
default: common
description: Persistent volume claim strategy for the Che
server. Only the `common` strategy (all workspaces PVCs
in one volume) is supported . For details, see https://github.com/eclipse/che/issues/21185.
default: per-user
description: 'Persistent volume claim strategy for the Che
server. The supported strategies are: `per-user` (all workspaces
PVCs in one volume) and ''per-workspace'' (each workspace
is given its own individual PVC). For details, see https://github.com/eclipse/che/issues/21185.'
enum:
- common
- per-user
- per-workspace
type: string
type: object
Expand Down
Loading

0 comments on commit aa27398

Please sign in to comment.