Skip to content

Commit

Permalink
restartless volume extension
Browse files Browse the repository at this point in the history
  • Loading branch information
lubien committed Jun 30, 2023
1 parent b27384f commit d7ed4bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
7 changes: 4 additions & 3 deletions api/resource_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *Client) CreateVolume(ctx context.Context, input CreateVolumeInput) (*Vo
return &data.CreateVolume.Volume, nil
}

func (c *Client) ExtendVolume(ctx context.Context, input ExtendVolumeInput) (*Volume, error) {
func (c *Client) ExtendVolume(ctx context.Context, input ExtendVolumeInput) (*Volume, bool, error) {
query := `
mutation($input: ExtendVolumeInput!) {
extendVolume(input: $input) {
Expand All @@ -108,6 +108,7 @@ func (c *Client) ExtendVolume(ctx context.Context, input ExtendVolumeInput) (*Vo
id
}
}
needsRestart
}
}
`
Expand All @@ -118,10 +119,10 @@ func (c *Client) ExtendVolume(ctx context.Context, input ExtendVolumeInput) (*Vo

data, err := c.RunWithContext(ctx, req)
if err != nil {
return nil, err
return nil, false, err
}

return &data.ExtendVolume.Volume, nil
return &data.ExtendVolume.Volume, data.ExtendVolume.NeedsRestart, nil
}

func (c *Client) DeleteVolume(ctx context.Context, volID string, lockId string) (App *App, err error) {
Expand Down
5 changes: 3 additions & 2 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,9 @@ type CreateVolumePayload struct {
}

type ExtendVolumePayload struct {
App App
Volume Volume
App App
Volume Volume
NeedsRestart bool
}

type DeleteVolumeInput struct {
Expand Down
8 changes: 6 additions & 2 deletions internal/command/volumes/extend.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func runExtend(ctx context.Context) error {
SizeGb: flag.GetInt(ctx, "size"),
}

volume, err := client.ExtendVolume(ctx, input)
volume, needsRestart, err := client.ExtendVolume(ctx, input)
if err != nil {
return fmt.Errorf("failed to extend volume: %w", err)
}
Expand All @@ -110,7 +110,11 @@ func runExtend(ctx context.Context) error {
}

if app.PlatformVersion == "machines" {
fmt.Fprintln(out, colorize.Yellow("You will need to stop and start your machine to increase the size of the FS"))
if needsRestart {
fmt.Fprintln(out, colorize.Yellow("You will need to stop and start your machine to increase the size of the FS"))
} else {
fmt.Fprintln(out, colorize.Green("Your machine got its file size extended without a restart"))
}
}

return nil
Expand Down

0 comments on commit d7ed4bb

Please sign in to comment.