diff --git a/pkg/cmd/scale/scale.go b/pkg/cmd/scale/scale.go index 70e9d03c0..b97c1787e 100644 --- a/pkg/cmd/scale/scale.go +++ b/pkg/cmd/scale/scale.go @@ -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 @@ -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)) +} diff --git a/pkg/entity/entity.go b/pkg/entity/entity.go index c22e1ee42..7861da760 100644 --- a/pkg/entity/entity.go +++ b/pkg/entity/entity.go @@ -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 {