Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/cmd/scale/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func Runscale(t *terminal.Terminal, args []string, gpu string, cpu string, sstor
if err != nil {
return breverrors.WrapAndTrace(err)
}
if err = validateWorkspaceScalable(workspace); err != nil {
return err
}

var modifyBody store.ModifyWorkspaceRequest

Expand Down Expand Up @@ -98,3 +101,13 @@ func Runscale(t *terminal.Terminal, args []string, gpu string, cpu string, sstor

return nil
}

// Dev-plane sets SubLocationTypeChangeable only when the provider can change an existing instance's type.
func validateWorkspaceScalable(workspace *entity.Workspace) error {
if workspace.InstanceTypeInfo != nil && workspace.InstanceTypeInfo.SubLocationTypeChangeable {
return nil
}
return breverrors.NewValidationError(fmt.Sprintf(
"instance %q does not support scale; create a new instance with the desired type instead",
workspace.Name))
}
3 changes: 2 additions & 1 deletion pkg/entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ const (
)

type InstanceTypeInfo struct {
Stoppable bool `json:"stoppable"`
Stoppable bool `json:"stoppable"`
SubLocationTypeChangeable bool `json:"sub_location_type_changeable"`
}

type Workspace struct {
Expand Down
Loading