Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f233324
Add support for GKE Accelerator Network Profile
ellenjzh Oct 22, 2025
5d92815
Merge branch 'main' into GKE-ANP-support
ellenjzh Oct 22, 2025
34ed6bb
Unset the local container client
ellenjzh Oct 22, 2025
9a150ce
changing the visibility to private
ellenjzh Oct 22, 2025
b157711
chang visibility of the TestAccContainerNodePool_acceleratorNetworkPr…
ellenjzh Oct 23, 2025
5dcce91
change visibility of accelerator_network_profile in meta.yaml file to…
ellenjzh Oct 23, 2025
4142462
chang visibility of the TestAccContainerNodePool_acceleratorNetworkPr…
ellenjzh Oct 23, 2025
a632037
change visibility of accelerator_network_profile in meta.yaml file to…
ellenjzh Oct 23, 2025
22c5448
Merge branch 'main' into GKE-ANP-support
ellenjzh Oct 28, 2025
c84be68
Add ForceNew to additional_node_network_configs
ellenjzh Nov 4, 2025
d6db86b
Change accelerator_network_profile Version Guard to V1Beta1
ellenjzh Nov 4, 2025
0279c7c
change config for accelerator_network_profile
ellenjzh Nov 4, 2025
ddcb650
Adding test for checking accelerator_network_profile and additional_n…
ellenjzh Nov 5, 2025
7f217ab
Update Test Case
ellenjzh Nov 5, 2025
5306804
Update Test Case
ellenjzh Nov 6, 2025
8ac77f8
Update Test Case
ellenjzh Nov 6, 2025
6d59673
Update Test Case
ellenjzh Nov 6, 2025
07b8147
Merge branch 'main' into GKE-ANP-support
ellenjzh Nov 7, 2025
9030c54
Update machine type to a2-highgpu-1g
ellenjzh Nov 7, 2025
b991e1c
Change machine type
ellenjzh Nov 7, 2025
04c946f
Change machine type to a3-highgpu-8g
ellenjzh Nov 8, 2025
57fb041
add test
ellenjzh Dec 8, 2025
e239557
Added ANP CustomizeDiff
ellenjzh Dec 15, 2025
f93ce25
Added ANP CustomizeDiff function
ellenjzh Dec 15, 2025
a5feeda
Updated ANP tests
ellenjzh Dec 17, 2025
9b26e66
Added version guard to nodePoolAcceleratorNetworkProfileCustomizeDiff
ellenjzh Dec 17, 2025
6ac4b40
Enable Flex-start for A3-highgpu-8g machine
ellenjzh Jan 8, 2026
acdbfef
Enable Flex-start for A3-highgpu-8g machine
ellenjzh Jan 8, 2026
da880fa
Enable Flex-start for A3-highgpu-8g machine
ellenjzh Jan 8, 2026
92f631b
Enable Flex-start for A3-highgpu-8g machine
ellenjzh Jan 8, 2026
afe6d83
Enable Flex-start for A3-highgpu-8g machine
ellenjzh Jan 8, 2026
15788a5
Enable Flex-start for A3-highgpu-8g machine
ellenjzh Jan 9, 2026
7eb4e4c
acctest.VcrTest to enable request recording
ellenjzh Jan 13, 2026
6b19f15
acctest.VcrTest to enable request recording
ellenjzh Jan 13, 2026
e0daabc
Added ANP in cluster meta.yaml
ellenjzh Jan 13, 2026
a2fea2f
Updated ANP in cluster meta yaml
ellenjzh Jan 13, 2026
f8d272a
Added ANP cluster tests
ellenjzh Jan 14, 2026
326b968
Merge branch 'main' into GKE-ANP-support
ellenjzh Jan 14, 2026
da20cba
Added ANP clusters tests
ellenjzh Jan 14, 2026
d577f38
Added ANP clusters tests
ellenjzh Jan 15, 2026
6c9e632
Updated ANP cluster customizeDiff func
ellenjzh Jan 15, 2026
a7e075d
Merge branch 'main' into GKE-ANP-support
ellenjzh Jan 15, 2026
256c83c
Added api field in node pool meta yaml
ellenjzh Jan 16, 2026
3045323
Fix: restore missing node_drain_config schema and add ANP api_field
ellenjzh Jan 16, 2026
02e46af
Fix: restore missing node_drain_config schema
ellenjzh Jan 16, 2026
06e9dde
Updated test cases
ellenjzh Jan 20, 2026
65081de
Updated test cases
ellenjzh Jan 20, 2026
024be3e
Separate config/import steps
melinath Jan 20, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ func ResourceContainerCluster() *schema.Resource {
containerClusterEnableK8sBetaApisCustomizeDiff,
containerClusterNodeVersionCustomizeDiff,
tpgresource.SetDiffForLabelsWithCustomizedName("resource_labels"),
{{ if ne $.TargetVersionName `ga` }}
clusterAcceleratorNetworkProfileCustomizeDiff,
{{- end }}
),

Timeouts: &schema.ResourceTimeout{
Expand Down Expand Up @@ -8495,3 +8498,154 @@ func containerClusterNodeVersionCustomizeDiffFunc(diff tpgresource.TerraformReso

return nil
}

{{ if ne $.TargetVersionName `ga` }}
func clusterAcceleratorNetworkProfileCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, meta any) error {
// 1. SKIP ON CREATE
if diff.Id() == "" {
return nil
}

// 2. PREPARE TO UPDATE THE FULL LIST
oldNodePools := diff.Get("node_pool").([]interface{})
newNodePools := make([]interface{}, len(oldNodePools))
listChanged := false

// We need Raw Config to check what the user actually wrote
rawConfig := diff.GetRawConfig()
rawNodePools := rawConfig.GetAttr("node_pool")

// 3. ITERATE OVER ALL POOLS IN STATE
for i, np := range oldNodePools {
// Deep copy the node pool map
npMap := np.(map[string]interface{})
newNpMap := make(map[string]interface{})
for k, v := range npMap {
newNpMap[k] = v
}

// Check if this specific node pool is actually defined in the Raw Config (Inline).
// If it is not in Raw Config, it is a Standalone resource (or API generated).
// We must not touch Standalone resources from the Cluster resource.
isInline := false
currentName := npMap["name"].(string)

// Iterate over Raw Config to find a match by name
if !rawNodePools.IsNull() && rawNodePools.Type().IsCollectionType() {
it := rawNodePools.ElementIterator()
for it.Next() {
_, val := it.Element()
rawNameVal := val.GetAttr("name")
if !rawNameVal.IsNull() && rawNameVal.AsString() == currentName {
isInline = true
break
}
}
}

// If this is NOT an inline pool, copy it as-is and skip logic.
if !isInline {
newNodePools[i] = newNpMap
continue
}

// A. DETECT USER CONFIG (Raw Config Check for this specific pool)
userHasAdditionalConfigs := false

// Re-find the specific raw block for logic checking
if !rawNodePools.IsNull() {
it := rawNodePools.ElementIterator()
for it.Next() {
_, val := it.Element()
rawNameVal := val.GetAttr("name")
if !rawNameVal.IsNull() && rawNameVal.AsString() == currentName {
// We found the matching raw block, now check its network config
rawNc := val.GetAttr("network_config")
if !rawNc.IsNull() && rawNc.Type().IsCollectionType() {
ncIt := rawNc.ElementIterator()
for ncIt.Next() {
_, ncVal := ncIt.Element()
userConfig := ncVal.GetAttr("additional_node_network_configs")
if !userConfig.IsNull() && userConfig.LengthInt() > 0 {
userHasAdditionalConfigs = true
}
}
}
break
}
}
}

// B. CHECK TRANSITION LOGIC
shouldClear := false
basePath := fmt.Sprintf("node_pool.%d", i)
networkConfigPath := basePath + ".network_config.0"

oldProfile, newProfile := diff.GetChange(networkConfigPath + ".accelerator_network_profile")

newProfileStr := ""
if newProfile != nil { newProfileStr = newProfile.(string) }
oldProfileStr := ""
if oldProfile != nil { oldProfileStr = oldProfile.(string) }

anpIsActive := newProfileStr != ""
anpIsChanging := oldProfileStr != newProfileStr

if !userHasAdditionalConfigs {
if anpIsActive && anpIsChanging {
shouldClear = true
}
if !anpIsActive {
shouldClear = true
}
}

// Check if additional configs currently exist to avoid no-op
currentCount := 0
if c, ok := diff.Get(networkConfigPath + ".additional_node_network_configs.#").(int); ok {
currentCount = c
}
if shouldClear && currentCount == 0 {
shouldClear = false
}

// C. APPLY FIX TO THE MAP
if shouldClear {
log.Printf("[DEBUG] Cluster ANP CustomizeDiff: Clearing additional configs for INLINE pool %s", currentName)

var newConfigMap map[string]interface{}

if ncList, ok := newNpMap["network_config"].([]interface{}); ok && len(ncList) > 0 {
if existingMap, ok := ncList[0].(map[string]interface{}); ok {
newConfigMap = make(map[string]interface{})
for k, v := range existingMap {
newConfigMap[k] = v
}
}
}

if newConfigMap == nil {
newConfigMap = make(map[string]interface{})
}

newConfigMap["additional_node_network_configs"] = []interface{}{}

if !anpIsActive {
newConfigMap["accelerator_network_profile"] = ""
}

newNpMap["network_config"] = []interface{}{newConfigMap}
listChanged = true
}

newNodePools[i] = newNpMap
}

// 4. WRITE THE FULL LIST BACK
if listChanged {
return diff.SetNew("node_pool", newNodePools)
}

return nil
}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ fields:
api_field: 'nodePools.name'
- field: 'node_pool.name_prefix'
provider_only: true
{{- if ne $.TargetVersionName "ga" }}
- field: 'node_pool.network_config.accelerator_network_profile'
api_field: 'nodePools.networkConfig.acceleratorNetworkProfile'
{{- end }}
- field: 'node_pool.network_config.additional_node_network_configs.network'
api_field: 'nodePools.networkConfig.additionalNodeNetworkConfigs.network'
- field: 'node_pool.network_config.additional_node_network_configs.subnetwork'
Expand Down
Loading
Loading