Skip to content

Commit 87534cb

Browse files
Add support for volume size in MiB (#49)
1 parent 504c8ff commit 87534cb

10 files changed

Lines changed: 32 additions & 27 deletions

File tree

app/controller/server/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (c *Controller) Init(ctx context.Context) (*types.Server, error) {
7676
MaxConcurrentBuilds: 3,
7777
MaxCPUPerBuild: 1,
7878
MaxMemoryPerBuild: 2,
79-
VolumeMinSize: 1,
79+
VolumeMinSize: 1024,
8080
}
8181

8282
manager, err := c.resolveServerManager(server)

app/controller/volume/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ func (c *Controller) sanitizeCreateInput(in *types.VolumeCreateInput) error {
5858
func (c *Controller) validateRestrictions(in *types.VolumeCreateInput, restrictions *types.VolumeRestriction) error {
5959
err := check.NewValidationErrors()
6060
if in.Size < restrictions.MinVolumeSize {
61-
err.AddValidationError("size", check.NewValidationErrorf("Volume is below min allowed limit of %dGB", restrictions.MinVolumeSize))
61+
err.AddValidationError("size", check.NewValidationErrorf("Volume is below min allowed limit of %dMiB", restrictions.MinVolumeSize))
6262
}
6363
if in.Size > restrictions.MaxVolumeSize {
64-
err.AddValidationError("size", check.NewValidationErrorf("Volume is above max allowed limit of %dGB", restrictions.MaxVolumeSize))
64+
err.AddValidationError("size", check.NewValidationErrorf("Volume is above max allowed limit of %dMiB", restrictions.MaxVolumeSize))
6565
}
6666

6767
if err.HasError() {

app/pipeline/convert/deploy_step.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func getTemplateInput(image string, input *pipeline.RunnerContextInput, spec *ty
157157
for _, v := range input.Volumes {
158158
in.Volumes = append(in.Volumes, &templates.Volume{
159159
VolumeName: v.GetIdentifierStr(),
160-
Storage: fmt.Sprintf("%dGi", v.Size),
160+
Storage: fmt.Sprintf("%dMi", v.Size),
161161
MountPath: v.MountPath,
162162
})
163163
}

app/services/config/volume.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
func (s *Service) GetVolumeRestrictions(server *types.Server, tenant *types.Tenant) *types.VolumeRestriction {
99
return &types.VolumeRestriction{
1010
MaxVolumes: tenant.MaxVolumes,
11-
MinVolumeSize: helpers.Max(tenant.MinVolumeSize, server.VolumeMinSize),
11+
MinVolumeSize: helpers.Min(tenant.MinVolumeSize, server.VolumeMinSize),
1212
MaxVolumeSize: tenant.MaxVolumeSize,
1313
}
1414
}

app/services/spec/input_mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
defaultTCPPort = 8000
2323
defaultMountName = "Storage"
2424
defaultMountPath = "/data"
25-
defaultMountSize = 1
25+
defaultMountSize = 1024
2626
defaultReplicas = 1
2727
defaultMemory = 0.5
2828
defaultCPU = 1

app/web/views/components/vserver/limits.templ

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ templ limits(server *types.Server) {
3636
@shared.Input(&shared.InputProps{
3737
Name: "min_volume_size",
3838
Label: "Min Volume Size",
39-
Tooltip: `Minimum size of the volume in GB, this is to handle the limitations of the underlying cloud
39+
Tooltip: `Minimum size of the volume in MiB, this is to handle the limitations of the underlying cloud
4040
providers if any. E.g. linode cannot have volumes less than 10GB.`,
41+
Description: "Volume size is in MiB",
4142
Type: "number",
4243
Placeholder: "1",
4344
Required: true,

app/web/views/components/vtenant/limits.templ

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,38 @@ templ Limits(tenant *types.Tenant, restrictions *types.TenantRestrictions, canEd
106106
<h3>Volume Limits</h3>
107107
<div class="flex flex-wrap gap-1 sm:gap-2 md:gap-4">
108108
@shared.Input(&shared.InputProps{
109-
Name: "max_volumes",
110-
Label: "Max Volumes",
111-
Type: "number",
112-
Tooltip: "Maximum number of volumes allowed to be created in this team.",
113-
Disabled: !canEdit,
109+
Name: "max_volumes",
110+
Label: "Max Volumes",
111+
Type: "number",
112+
Tooltip: "Maximum number of volumes allowed to be created in this team.",
113+
Description: "Volume size is in MiB",
114+
Disabled: !canEdit,
114115
Attrs: templ.Attributes{
115116
"x-model.number": "form.max_volumes",
116117
"x-bind:min": "1",
117118
"x-bind:max": "100",
118119
},
119120
})
120121
@shared.Input(&shared.InputProps{
121-
Name: "min_volume_size",
122-
Label: "Min Volume Size",
123-
Type: "number",
124-
Tooltip: "Minimum size allowed per volume in this team.",
125-
Disabled: !canEdit,
122+
Name: "min_volume_size",
123+
Label: "Min Volume Size",
124+
Type: "number",
125+
Tooltip: "Minimum size allowed per volume in this team.",
126+
Description: "Volume size is in MiB",
127+
Disabled: !canEdit,
126128
Attrs: templ.Attributes{
127129
"x-model.number": "form.min_volume_size",
128130
"x-bind:min": "1",
129131
"x-bind:max": "100",
130132
},
131133
})
132134
@shared.Input(&shared.InputProps{
133-
Name: "max_volume_size",
134-
Label: "Max Volume Size",
135-
Type: "number",
136-
Tooltip: "Maximum size allowed per volume in this team.",
137-
Disabled: !canEdit,
135+
Name: "max_volume_size",
136+
Label: "Max Volume Size",
137+
Type: "number",
138+
Tooltip: "Maximum size allowed per volume in this team.",
139+
Description: "Volume size is in MiB",
140+
Disabled: !canEdit,
138141
Attrs: templ.Attributes{
139142
"x-model.number": "form.max_volume_size",
140143
"x-bind:min": "1",

app/web/views/components/vvolume/form.templ

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ templ form(action enum.VolumeFormAction, in *types.VolumeCreateInput, uid int64)
6969
})
7070
@shared.Input(&shared.InputProps{
7171
Label: "Size",
72-
Tooltip: "Size of the volume in GB, cannot be downsized",
72+
Tooltip: "Size of the volume in MiB, cannot be downsized",
73+
Description: "Volume size is in MiB",
7374
Name: "size",
7475
Type: "number",
75-
Placeholder: "1",
76+
Placeholder: "1024",
7677
Required: true,
7778
Readonly: action == enum.VolumeFormActionDelete || action == enum.VolumeFormActionAttach,
7879
Attrs: templ.Attributes{

app/web/views/components/vvolume/tile.templ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ templ tile(volume *types.Volume, action enum.VolumeFormAction) {
2020
<div class="flex items-center justify-between gap-1">
2121
<p class="font-medium truncate">{ volume.Name }</p>
2222
<p class="text-tx-secondary">{ volume.MountPath }</p>
23-
<p class="text-tx-secondary text-xs">{ fmt.Sprintf("%d",volume.Size) } GB</p>
23+
<p class="text-tx-secondary text-xs">{ fmt.Sprintf("%d",volume.Size) } MiB</p>
2424
</div>
2525
</div>
2626
</div>

types/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ type TenantConfig struct {
173173
DefaultMaxCPUPerApplication int64 `envconfig:"CLOUDNESS_TENANT_MAX_CPU" default:"2"`
174174
DefaultMaxMemoryPerApplication float64 `envconfig:"CLOUDNESS_TENANT_MAX_MEMORY" default:"2"`
175175
DefaultMaxVolumeCount int64 `envconfig:"CLOUDNESS_TENANT_MAX_VOLUME_COUNT" default:"10"`
176-
DefaultMinVolumeSize int64 `envconfig:"CLOUDNESS_TENANT_MIN_VOLUME_SIZE" default:"1"`
177-
DefaultMaxVolumeSize int64 `envconfig:"CLOUDNESS_TENANT_MAX_VOLUME_SIZE" default:"10"`
176+
DefaultMinVolumeSize int64 `envconfig:"CLOUDNESS_TENANT_MIN_VOLUME_SIZE" default:"1024"`
177+
DefaultMaxVolumeSize int64 `envconfig:"CLOUDNESS_TENANT_MAX_VOLUME_SIZE" default:"10240"`
178178
}
179179

180180
type KubeServerConfig struct {

0 commit comments

Comments
 (0)