diff --git a/internal/validation/suite.go b/internal/validation/suite.go index dfcf2f9..c4e04e1 100644 --- a/internal/validation/suite.go +++ b/internal/validation/suite.go @@ -79,15 +79,17 @@ func RunInstanceLifecycleValidation(t *testing.T, config ProviderConfig) { t.Run("ValidateCreateInstance", func(t *testing.T) { attrs := v1.CreateInstanceAttrs{} + selectedType := v1.InstanceType{} for _, typ := range types { if typ.IsAvailable { attrs.InstanceType = typ.Type attrs.Location = typ.Location attrs.PublicKey = ssh.GetTestPublicKey() + selectedType = typ break } } - instance, err := v1.ValidateCreateInstance(ctx, client, attrs) + instance, err := v1.ValidateCreateInstance(ctx, client, attrs, selectedType) if err != nil { t.Fatalf("ValidateCreateInstance failed: %v", err) } diff --git a/v1/instance.go b/v1/instance.go index 82f4afb..d56a5e0 100644 --- a/v1/instance.go +++ b/v1/instance.go @@ -28,7 +28,7 @@ type CloudCreateTerminateInstance interface { CloudInstanceReader } -func ValidateCreateInstance(ctx context.Context, client CloudCreateTerminateInstance, attrs CreateInstanceAttrs) (*Instance, error) { +func ValidateCreateInstance(ctx context.Context, client CloudCreateTerminateInstance, attrs CreateInstanceAttrs, selectedType InstanceType) (*Instance, error) { //nolint:gocyclo // ok t0 := time.Now().Add(-time.Minute) attrs.RefID = uuid.New().String() name, err := makeDebuggableName(attrs.Name) @@ -67,6 +67,9 @@ func ValidateCreateInstance(ctx context.Context, client CloudCreateTerminateInst if attrs.InstanceType != "" && attrs.InstanceType != i.InstanceType { validationErr = errors.Join(validationErr, fmt.Errorf("instanceType mismatch: %s != %s", attrs.InstanceType, i.InstanceType)) } + if selectedType.ID != "" && selectedType.ID != i.InstanceTypeID { + validationErr = errors.Join(validationErr, fmt.Errorf("instanceTypeID mismatch: %s != %s", selectedType.ID, i.InstanceTypeID)) + } return i, validationErr } diff --git a/v1/providers/nebius/instance.go b/v1/providers/nebius/instance.go index 5047341..6593313 100644 --- a/v1/providers/nebius/instance.go +++ b/v1/providers/nebius/instance.go @@ -334,15 +334,14 @@ func (c *NebiusClient) convertNebiusInstanceToV1(ctx context.Context, instance * sshUser = "admin" } - return &v1.Instance{ + inst := &v1.Instance{ RefID: refID, CloudCredRefID: c.refID, Name: instance.Metadata.Name, CloudID: instanceID, Location: location, CreatedAt: createdAt, - InstanceType: instanceTypeID, // Full instance type ID (e.g., "gpu-h100-sxm.8gpu-128vcpu-1600gb") - InstanceTypeID: v1.InstanceTypeID(instanceTypeID), // Same as InstanceType - required for dev-plane lookup + InstanceType: instanceTypeID, // Full instance type ID (e.g., "gpu-h100-sxm.8gpu-128vcpu-1600gb") ImageID: imageFamily, DiskSize: units.Base2Bytes(diskSize), DiskSizeBytes: v1.NewBytes(v1.BytesValue(diskSize), v1.Byte), // diskSize is already in bytes from getBootDiskSize @@ -355,7 +354,9 @@ func (c *NebiusClient) convertNebiusInstanceToV1(ctx context.Context, instance * Hostname: hostname, SSHUser: sshUser, SSHPort: 22, // Standard SSH port - }, nil + } + inst.InstanceTypeID = v1.MakeGenericInstanceTypeIDFromInstance(*inst) + return inst, nil } // waitForInstanceRunning polls the instance until it reaches RUNNING state or fails