Skip to content

Commit 5398ac3

Browse files
committed
chore: add Node Template option to configure user-managed GPU drivers
1 parent e928019 commit 5398ac3

File tree

4 files changed

+54
-3
lines changed

4 files changed

+54
-3
lines changed

castai/resource_node_template.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const (
9090
FieldNodeTemplateEdgeLocationIDs = "edge_location_ids"
9191
FieldNodeTemplatePriceAdjustmentConfiguration = "price_adjustment_configuration"
9292
FieldNodeTemplateInstanceTypeAdjustments = "instance_type_adjustments"
93+
FieldNodeTemplateUserManagedGPUDrivers = "user_managed_gpu_drivers"
9394
)
9495

9596
const (
@@ -710,6 +711,12 @@ func resourceNodeTemplate() *schema.Resource {
710711
},
711712
},
712713
},
714+
FieldNodeTemplateUserManagedGPUDrivers: {
715+
Type: schema.TypeBool,
716+
Optional: true,
717+
Default: nil,
718+
Description: "Enable/disable user-managed GPU drivers (for GKE clusters only).",
719+
},
713720
},
714721
},
715722
},
@@ -871,6 +878,10 @@ func flattenGpuSettings(g *sdk.NodetemplatesV1GPU) ([]map[string]any, error) {
871878

872879
out := make(map[string]any)
873880

881+
if g.UserManagedGpuDrivers != nil {
882+
out[FieldNodeTemplateUserManagedGPUDrivers] = g.UserManagedGpuDrivers
883+
}
884+
874885
if g.EnableTimeSharing != nil {
875886
out[FieldNodeTemplateEnableTimeSharing] = g.EnableTimeSharing
876887
}
@@ -1170,6 +1181,7 @@ func updateNodeTemplate(ctx context.Context, d *schema.ResourceData, meta any, s
11701181
FieldNodeTemplateClmEnabled,
11711182
FieldNodeTemplateEdgeLocationIDs,
11721183
FieldNodeTemplatePriceAdjustmentConfiguration,
1184+
FieldNodeTemplateUserManagedGPUDrivers,
11731185
) {
11741186
log.Printf("[INFO] Nothing to update in node template")
11751187
return nil
@@ -1680,6 +1692,11 @@ func toTemplateGpu(obj map[string]any) *sdk.NodetemplatesV1GPU {
16801692
return nil
16811693
}
16821694

1695+
var userManagedGPUDrivers bool
1696+
if v, ok := obj[FieldNodeTemplateUserManagedGPUDrivers].(bool); ok {
1697+
userManagedGPUDrivers = v
1698+
}
1699+
16831700
var defaultSharedClientsPerGpu int32
16841701
if v, ok := obj[FieldNodeTemplateDefaultSharedClientsPerGpu].(int); ok {
16851702
defaultSharedClientsPerGpu = int32(v)
@@ -1711,15 +1728,14 @@ func toTemplateGpu(obj map[string]any) *sdk.NodetemplatesV1GPU {
17111728
// terraform treats nil values as zero values
17121729
// this condition checks whether the whole gpu configuration is deleted
17131730
// and gpu configuration should be set to nil
1714-
if defaultSharedClientsPerGpu == 0 &&
1715-
!enableTimeSharing &&
1716-
len(sharingConfig) == 0 {
1731+
if defaultSharedClientsPerGpu == 0 && !enableTimeSharing && len(sharingConfig) == 0 && !userManagedGPUDrivers {
17171732
return nil
17181733
}
17191734
return &sdk.NodetemplatesV1GPU{
17201735
DefaultSharedClientsPerGpu: &defaultSharedClientsPerGpu,
17211736
EnableTimeSharing: &enableTimeSharing,
17221737
SharingConfiguration: &sharingConfig,
1738+
UserManagedGpuDrivers: &userManagedGPUDrivers,
17231739
}
17241740
}
17251741

castai/sdk/api.gen.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

castai/sdk/client.gen.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

castai/sdk/organization_management/api.gen.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)