Skip to content

Commit

Permalink
(feat): Improve backend validation for resize
Browse files Browse the repository at this point in the history
  • Loading branch information
lasith-kg committed Nov 26, 2023
1 parent 351f315 commit 6fe11fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 0 additions & 1 deletion configs/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ devices:
group: ubuntu
user: ubuntu
permissions: 644
remount: true
resizeFs: true
7 changes: 6 additions & 1 deletion internal/backend/resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ func (dmb *LinuxDeviceResizeBackend) From(config *config.Config) error {
if err != nil {
return err
}
dmb.blockDevices[bd.Name] = bd
// Can not fetch file system metrics from a device with
// no file system. Therefore, we continue if this is the case
if bd.FileSystem == model.Unformatted {
continue
}
fs, err := dmb.fileSystemServiceFactory.Select(bd.FileSystem)
if err != nil {
return err
Expand All @@ -100,7 +106,6 @@ func (dmb *LinuxDeviceResizeBackend) From(config *config.Config) error {
if err != nil {
return err
}
dmb.blockDevices[bd.Name] = bd
dmb.blockDeviceMetrics[bd.Name] = &BlockDeviceMetrics{
BlockDeviceSize: bss,
FileSystemSize: fss,
Expand Down
4 changes: 4 additions & 0 deletions internal/layer/resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/reecetech/ebs-bootstrap/internal/action"
"github.com/reecetech/ebs-bootstrap/internal/backend"
"github.com/reecetech/ebs-bootstrap/internal/config"
"github.com/reecetech/ebs-bootstrap/internal/model"
)

type ResizeDeviceLayer struct {
Expand All @@ -33,6 +34,9 @@ func (fdl *ResizeDeviceLayer) Modify(c *config.Config) ([]action.Action, error)
if err != nil {
return nil, err
}
if bd.FileSystem == model.Unformatted {
return nil, fmt.Errorf("🔴 %s: Can not resize a device with no file system", bd.Name)
}
metrics, err := fdl.deviceResizeBackend.GetBlockDeviceMetrics(name)
if err != nil {
return nil, err
Expand Down

0 comments on commit 6fe11fb

Please sign in to comment.