diff --git a/app/controller/server/controller.go b/app/controller/server/controller.go index 866431a..15fe361 100644 --- a/app/controller/server/controller.go +++ b/app/controller/server/controller.go @@ -76,7 +76,7 @@ func (c *Controller) Init(ctx context.Context) (*types.Server, error) { MaxConcurrentBuilds: 3, MaxCPUPerBuild: 1, MaxMemoryPerBuild: 2, - VolumeMinSize: 1, + VolumeMinSize: 1024, } manager, err := c.resolveServerManager(server) diff --git a/app/controller/volume/create.go b/app/controller/volume/create.go index 3c11c17..c6270df 100644 --- a/app/controller/volume/create.go +++ b/app/controller/volume/create.go @@ -58,10 +58,10 @@ func (c *Controller) sanitizeCreateInput(in *types.VolumeCreateInput) error { func (c *Controller) validateRestrictions(in *types.VolumeCreateInput, restrictions *types.VolumeRestriction) error { err := check.NewValidationErrors() if in.Size < restrictions.MinVolumeSize { - err.AddValidationError("size", check.NewValidationErrorf("Volume is below min allowed limit of %dGB", restrictions.MinVolumeSize)) + err.AddValidationError("size", check.NewValidationErrorf("Volume is below min allowed limit of %dMiB", restrictions.MinVolumeSize)) } if in.Size > restrictions.MaxVolumeSize { - err.AddValidationError("size", check.NewValidationErrorf("Volume is above max allowed limit of %dGB", restrictions.MaxVolumeSize)) + err.AddValidationError("size", check.NewValidationErrorf("Volume is above max allowed limit of %dMiB", restrictions.MaxVolumeSize)) } if err.HasError() { diff --git a/app/pipeline/convert/deploy_step.go b/app/pipeline/convert/deploy_step.go index 11a5ba3..f7311fb 100644 --- a/app/pipeline/convert/deploy_step.go +++ b/app/pipeline/convert/deploy_step.go @@ -157,7 +157,7 @@ func getTemplateInput(image string, input *pipeline.RunnerContextInput, spec *ty for _, v := range input.Volumes { in.Volumes = append(in.Volumes, &templates.Volume{ VolumeName: v.GetIdentifierStr(), - Storage: fmt.Sprintf("%dGi", v.Size), + Storage: fmt.Sprintf("%dMi", v.Size), MountPath: v.MountPath, }) } diff --git a/app/services/config/volume.go b/app/services/config/volume.go index cc42ea5..acd204c 100644 --- a/app/services/config/volume.go +++ b/app/services/config/volume.go @@ -8,7 +8,7 @@ import ( func (s *Service) GetVolumeRestrictions(server *types.Server, tenant *types.Tenant) *types.VolumeRestriction { return &types.VolumeRestriction{ MaxVolumes: tenant.MaxVolumes, - MinVolumeSize: helpers.Max(tenant.MinVolumeSize, server.VolumeMinSize), + MinVolumeSize: helpers.Min(tenant.MinVolumeSize, server.VolumeMinSize), MaxVolumeSize: tenant.MaxVolumeSize, } } diff --git a/app/services/spec/input_mapper.go b/app/services/spec/input_mapper.go index 0093213..4c10920 100644 --- a/app/services/spec/input_mapper.go +++ b/app/services/spec/input_mapper.go @@ -22,7 +22,7 @@ const ( defaultTCPPort = 8000 defaultMountName = "Storage" defaultMountPath = "/data" - defaultMountSize = 1 + defaultMountSize = 1024 defaultReplicas = 1 defaultMemory = 0.5 defaultCPU = 1 diff --git a/app/web/views/components/vserver/limits.templ b/app/web/views/components/vserver/limits.templ index b13cea7..7e1d350 100644 --- a/app/web/views/components/vserver/limits.templ +++ b/app/web/views/components/vserver/limits.templ @@ -36,8 +36,9 @@ templ limits(server *types.Server) { @shared.Input(&shared.InputProps{ Name: "min_volume_size", Label: "Min Volume Size", - Tooltip: `Minimum size of the volume in GB, this is to handle the limitations of the underlying cloud + Tooltip: `Minimum size of the volume in MiB, this is to handle the limitations of the underlying cloud providers if any. E.g. linode cannot have volumes less than 10GB.`, + Description: "Volume size is in MiB", Type: "number", Placeholder: "1", Required: true, diff --git a/app/web/views/components/vtenant/limits.templ b/app/web/views/components/vtenant/limits.templ index 766ab1d..ed2de3e 100644 --- a/app/web/views/components/vtenant/limits.templ +++ b/app/web/views/components/vtenant/limits.templ @@ -106,11 +106,12 @@ templ Limits(tenant *types.Tenant, restrictions *types.TenantRestrictions, canEd

Volume Limits

@shared.Input(&shared.InputProps{ - Name: "max_volumes", - Label: "Max Volumes", - Type: "number", - Tooltip: "Maximum number of volumes allowed to be created in this team.", - Disabled: !canEdit, + Name: "max_volumes", + Label: "Max Volumes", + Type: "number", + Tooltip: "Maximum number of volumes allowed to be created in this team.", + Description: "Volume size is in MiB", + Disabled: !canEdit, Attrs: templ.Attributes{ "x-model.number": "form.max_volumes", "x-bind:min": "1", @@ -118,11 +119,12 @@ templ Limits(tenant *types.Tenant, restrictions *types.TenantRestrictions, canEd }, }) @shared.Input(&shared.InputProps{ - Name: "min_volume_size", - Label: "Min Volume Size", - Type: "number", - Tooltip: "Minimum size allowed per volume in this team.", - Disabled: !canEdit, + Name: "min_volume_size", + Label: "Min Volume Size", + Type: "number", + Tooltip: "Minimum size allowed per volume in this team.", + Description: "Volume size is in MiB", + Disabled: !canEdit, Attrs: templ.Attributes{ "x-model.number": "form.min_volume_size", "x-bind:min": "1", @@ -130,11 +132,12 @@ templ Limits(tenant *types.Tenant, restrictions *types.TenantRestrictions, canEd }, }) @shared.Input(&shared.InputProps{ - Name: "max_volume_size", - Label: "Max Volume Size", - Type: "number", - Tooltip: "Maximum size allowed per volume in this team.", - Disabled: !canEdit, + Name: "max_volume_size", + Label: "Max Volume Size", + Type: "number", + Tooltip: "Maximum size allowed per volume in this team.", + Description: "Volume size is in MiB", + Disabled: !canEdit, Attrs: templ.Attributes{ "x-model.number": "form.max_volume_size", "x-bind:min": "1", diff --git a/app/web/views/components/vvolume/form.templ b/app/web/views/components/vvolume/form.templ index 1cbb309..a22d207 100644 --- a/app/web/views/components/vvolume/form.templ +++ b/app/web/views/components/vvolume/form.templ @@ -69,10 +69,11 @@ templ form(action enum.VolumeFormAction, in *types.VolumeCreateInput, uid int64) }) @shared.Input(&shared.InputProps{ Label: "Size", - Tooltip: "Size of the volume in GB, cannot be downsized", + Tooltip: "Size of the volume in MiB, cannot be downsized", + Description: "Volume size is in MiB", Name: "size", Type: "number", - Placeholder: "1", + Placeholder: "1024", Required: true, Readonly: action == enum.VolumeFormActionDelete || action == enum.VolumeFormActionAttach, Attrs: templ.Attributes{ diff --git a/app/web/views/components/vvolume/tile.templ b/app/web/views/components/vvolume/tile.templ index 4b2cb5d..cc86210 100644 --- a/app/web/views/components/vvolume/tile.templ +++ b/app/web/views/components/vvolume/tile.templ @@ -20,7 +20,7 @@ templ tile(volume *types.Volume, action enum.VolumeFormAction) {

{ volume.Name }

{ volume.MountPath }

-

{ fmt.Sprintf("%d",volume.Size) } GB

+

{ fmt.Sprintf("%d",volume.Size) } MiB

diff --git a/types/config.go b/types/config.go index dbfcbf2..0ba6c0b 100644 --- a/types/config.go +++ b/types/config.go @@ -173,8 +173,8 @@ type TenantConfig struct { DefaultMaxCPUPerApplication int64 `envconfig:"CLOUDNESS_TENANT_MAX_CPU" default:"2"` DefaultMaxMemoryPerApplication float64 `envconfig:"CLOUDNESS_TENANT_MAX_MEMORY" default:"2"` DefaultMaxVolumeCount int64 `envconfig:"CLOUDNESS_TENANT_MAX_VOLUME_COUNT" default:"10"` - DefaultMinVolumeSize int64 `envconfig:"CLOUDNESS_TENANT_MIN_VOLUME_SIZE" default:"1"` - DefaultMaxVolumeSize int64 `envconfig:"CLOUDNESS_TENANT_MAX_VOLUME_SIZE" default:"10"` + DefaultMinVolumeSize int64 `envconfig:"CLOUDNESS_TENANT_MIN_VOLUME_SIZE" default:"1024"` + DefaultMaxVolumeSize int64 `envconfig:"CLOUDNESS_TENANT_MAX_VOLUME_SIZE" default:"10240"` } type KubeServerConfig struct {