Skip to content

Commit

Permalink
feat: configmap option for perWorkspace PVC size
Browse files Browse the repository at this point in the history
Fix devfile#836

Signed-off-by: Andrew Obuchowicz <[email protected]>
  • Loading branch information
AObuchow committed May 18, 2022
1 parent 1d9ca22 commit c2aa8d0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/provision/storage/perWorkspaceStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import (
"github.com/devfile/devworkspace-operator/pkg/config"
"github.com/devfile/devworkspace-operator/pkg/constants"
devfileConstants "github.com/devfile/devworkspace-operator/pkg/library/constants"
nsconfig "github.com/devfile/devworkspace-operator/pkg/provision/config"
"github.com/devfile/devworkspace-operator/pkg/provision/sync"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

Expand Down Expand Up @@ -148,11 +150,18 @@ func (p *PerWorkspaceStorageProvisioner) rewriteContainerVolumeMounts(workspaceI
}

func syncPerWorkspacePVC(workspace *dw.DevWorkspace, clusterAPI sync.ClusterAPI) (*corev1.PersistentVolumeClaim, error) {
namespacedConfig, err := nsconfig.ReadNamespacedConfig(workspace.Namespace, clusterAPI)
if err != nil {
return nil, fmt.Errorf("failed to read namespace-specific configuration: %w", err)
}
// TODO: Determine the storage size that is needed by iterating through workspace volumes,
// adding the sizes specified and figuring out overrides/defaults
pvcSize := *config.Workspace.DefaultStorageSize.PerWorkspace
if namespacedConfig != nil && namespacedConfig.PerWorkspacePVCSize != "" {
pvcSize = namespacedConfig.PerWorkspacePVCSize
pvcSize, err = resource.ParseQuantity(namespacedConfig.PerWorkspacePVCSize)
if err != nil {
return nil, err
}
}

pvc, err := getPVCSpec(common.PerWorkspacePVCName(workspace.Status.DevWorkspaceId), workspace.Namespace, pvcSize)
Expand Down

0 comments on commit c2aa8d0

Please sign in to comment.