Skip to content

Commit

Permalink
fix bug where volume.ChangeQuota did not actually use mebibytes but b…
Browse files Browse the repository at this point in the history
…ytes
  • Loading branch information
joonas-fi committed Mar 16, 2019
1 parent 3bb8921 commit d1c405e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions pkg/varastoserver/commandhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (c *cHandlers) VolumeCreate(cmd *VolumeCreate, ctx *command.Ctx) error {
ID: len(allVolumes) + 1,
UUID: varastoutils.NewVolumeUuid(),
Label: cmd.Name,
Quota: int64(1024 * 1024 * cmd.Quota),
Quota: mebibytesToBytes(cmd.Quota),
}, tx); err != nil {
return err
}
Expand All @@ -57,7 +57,7 @@ func (c *cHandlers) VolumeChangeQuota(cmd *VolumeChangeQuota, ctx *command.Ctx)
return err
}

vol.Quota = int64(cmd.Quota) // FIXME
vol.Quota = mebibytesToBytes(cmd.Quota)

if err := VolumeRepository.Update(vol, tx); err != nil {
return err
Expand Down Expand Up @@ -376,3 +376,7 @@ func registerCommandEndpoints(
}
})).Methods(http.MethodPost)
}

func mebibytesToBytes(mebibytes int) int64 {
return int64(mebibytes * 1024 * 1024)
}
4 changes: 2 additions & 2 deletions pkg/varastoserver/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"title": "Create volume",
"fields": [
{ "key": "Name" },
{ "key": "Quota", "type": "integer", "help": "Quota in megabytes" }
{ "key": "Quota", "type": "integer", "help": "Quota in megabytes (MiB)" }
]
},
{
Expand All @@ -18,7 +18,7 @@
"title": "Change quota",
"fields": [
{ "key": "Id", "type": "integer", "hideIfDefaultValue": true },
{ "key": "Quota", "type": "integer", "help": "Quota in megabytes" }
{ "key": "Quota", "type": "integer", "help": "Quota in megabytes (MiB)" }
]
},
{
Expand Down

0 comments on commit d1c405e

Please sign in to comment.