Skip to content

Commit a28b950

Browse files
authored
KUBE-1393: EKS config - threads per cpu added (#557)
1 parent 1cf4e2c commit a28b950

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

castai/resource_node_configuration.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ func resourceNodeConfiguration() *schema.Resource {
273273
return oldValue == newValue
274274
},
275275
},
276+
"threads_per_cpu": {
277+
Type: schema.TypeInt,
278+
Optional: true,
279+
Description: "Number of threads per core.",
280+
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 256)),
281+
},
276282
FieldNodeConfigurationEKSImageFamily: {
277283
Type: schema.TypeString,
278284
Optional: true,
@@ -935,6 +941,10 @@ func toEKSConfig(obj map[string]interface{}) *sdk.NodeconfigV1EKSConfig {
935941
out.IpsPerPrefix = toPtr(int32(v))
936942
}
937943

944+
if v, ok := obj["threads_per_cpu"].(int); ok && v != 0 {
945+
out.ThreadsPerCpu = toPtr(int32(v))
946+
}
947+
938948
if v, ok := obj[FieldNodeConfigurationEKSTargetGroup].([]any); ok && len(v) > 0 {
939949
resultTGs := make([]sdk.NodeconfigV1TargetGroup, 0, len(v))
940950
for _, tgRaw := range v {
@@ -1024,6 +1034,10 @@ func flattenEKSConfig(config *sdk.NodeconfigV1EKSConfig) []map[string]interface{
10241034
m["ips_per_prefix"] = *config.IpsPerPrefix
10251035
}
10261036

1037+
if v := config.ThreadsPerCpu; v != nil {
1038+
m["threads_per_cpu"] = *config.ThreadsPerCpu
1039+
}
1040+
10271041
if v := config.TargetGroups; v != nil && len(*v) > 0 {
10281042
tgs := make([]any, 0, len(*v))
10291043
for _, tg := range *v {
@@ -1162,7 +1176,6 @@ func toAKSNodePublicIP(obj any) *sdk.NodeconfigV1AKSConfigPublicIP {
11621176
}
11631177

11641178
return publicIP
1165-
11661179
}
11671180

11681181
func toAKSEphemeralOSDisk(obj any) *sdk.NodeconfigV1AKSConfigOsDiskEphemeral {
@@ -1359,7 +1372,6 @@ func fromAKSNodePublicIP(sdkPublicIp *sdk.NodeconfigV1AKSConfigPublicIP) []map[s
13591372
}
13601373

13611374
return []map[string]any{m}
1362-
13631375
}
13641376

13651377
func fromAKSEphemeralOSDisk(sdkEph *sdk.NodeconfigV1AKSConfigOsDiskEphemeral) []map[string]interface{} {
@@ -1578,7 +1590,6 @@ func toGkeUnmanagedInstanceGroups(obj []interface{}) *[]sdk.NodeconfigV1GKEConfi
15781590
}
15791591

15801592
return &out
1581-
15821593
}
15831594

15841595
func flattenGKEConfig(config *sdk.NodeconfigV1GKEConfig) []map[string]interface{} {

castai/resource_node_configuration_eks_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func TestAccResourceNodeConfiguration_eks(t *testing.T) {
5656
resource.TestCheckResourceAttr(resourceName, "kops.#", "0"),
5757
resource.TestCheckResourceAttr(resourceName, "gke.#", "0"),
5858
resource.TestCheckResourceAttr(resourceName, "eks.0.node_group_arn", "arn:aws:iam::000000000000:role/aws_node_group"),
59+
resource.TestCheckResourceAttr(resourceName, "eks.0.threads_per_cpu", "1"),
5960
),
6061
},
6162
{
@@ -146,6 +147,7 @@ resource "castai_node_configuration" "test" {
146147
target_group {
147148
arn = "arn:aws:test"
148149
}
150+
threads_per_cpu = 1
149151
}
150152
}
151153

castai/sdk/api.gen.go

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

docs/resources/node_configuration.md

Lines changed: 1 addition & 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)