@@ -411,8 +411,17 @@ func TestAccContainerNodePool_withLinuxNodeConfig(t *testing.T) {
411
411
ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
412
412
CheckDestroy : testAccCheckContainerClusterDestroyProducer (t ),
413
413
Steps : []resource.TestStep {
414
+ // Create a node pool with empty `linux_node_config.sysctls`.
414
415
{
415
- Config : testAccContainerNodePool_withLinuxNodeConfig (cluster , np , 10000 , 12800 , "1000 20000 100000" , 1 ),
416
+ Config : testAccContainerNodePool_withLinuxNodeConfig (cluster , np , "" ),
417
+ },
418
+ {
419
+ ResourceName : "google_container_node_pool.with_linux_node_config" ,
420
+ ImportState : true ,
421
+ ImportStateVerify : true ,
422
+ },
423
+ {
424
+ Config : testAccContainerNodePool_withLinuxNodeConfig (cluster , np , "1000 20000 100000" ),
416
425
},
417
426
{
418
427
ResourceName : "google_container_node_pool.with_linux_node_config" ,
@@ -421,7 +430,7 @@ func TestAccContainerNodePool_withLinuxNodeConfig(t *testing.T) {
421
430
},
422
431
// Perform an update.
423
432
{
424
- Config : testAccContainerNodePool_withLinuxNodeConfig (cluster , np , 10000 , 12800 , "1000 20000 200000" , 1 ),
433
+ Config : testAccContainerNodePool_withLinuxNodeConfig (cluster , np , "1000 20000 200000" ),
425
434
},
426
435
{
427
436
ResourceName : "google_container_node_pool.with_linux_node_config" ,
@@ -2353,7 +2362,30 @@ resource "google_container_node_pool" "with_kubelet_config" {
2353
2362
` , cluster , np , policy , quota , period , podPidsLimit )
2354
2363
}
2355
2364
2356
- func testAccContainerNodePool_withLinuxNodeConfig (cluster , np string , maxBacklog , soMaxConn int , tcpMem string , twReuse int ) string {
2365
+ func testAccContainerNodePool_withLinuxNodeConfig (cluster , np string , tcpMem string ) string {
2366
+ linuxNodeConfig := `
2367
+ linux_node_config {
2368
+ sysctls = {}
2369
+ }
2370
+ `
2371
+ if len (tcpMem ) != 0 {
2372
+ linuxNodeConfig = fmt .Sprintf (`
2373
+ linux_node_config {
2374
+ sysctls = {
2375
+ "net.core.netdev_max_backlog" = "10000"
2376
+ "net.core.rmem_max" = 10000
2377
+ "net.core.wmem_default" = 10000
2378
+ "net.core.wmem_max" = 20000
2379
+ "net.core.optmem_max" = 10000
2380
+ "net.core.somaxconn" = 12800
2381
+ "net.ipv4.tcp_rmem" = "%s"
2382
+ "net.ipv4.tcp_wmem" = "%s"
2383
+ "net.ipv4.tcp_tw_reuse" = 1
2384
+ }
2385
+ }
2386
+ ` , tcpMem , tcpMem )
2387
+ }
2388
+
2357
2389
return fmt .Sprintf (`
2358
2390
data "google_container_engine_versions" "central1a" {
2359
2391
location = "us-central1-a"
@@ -2373,26 +2405,14 @@ resource "google_container_node_pool" "with_linux_node_config" {
2373
2405
initial_node_count = 1
2374
2406
node_config {
2375
2407
image_type = "COS_CONTAINERD"
2376
- linux_node_config {
2377
- sysctls = {
2378
- "net.core.netdev_max_backlog" = "%d"
2379
- "net.core.rmem_max" = 10000
2380
- "net.core.wmem_default" = 10000
2381
- "net.core.wmem_max" = 20000
2382
- "net.core.optmem_max" = 10000
2383
- "net.core.somaxconn" = %d
2384
- "net.ipv4.tcp_rmem" = "%s"
2385
- "net.ipv4.tcp_wmem" = "%s"
2386
- "net.ipv4.tcp_tw_reuse" = %d
2387
- }
2388
- }
2408
+ %s
2389
2409
oauth_scopes = [
2390
2410
"https://www.googleapis.com/auth/logging.write",
2391
2411
"https://www.googleapis.com/auth/monitoring",
2392
2412
]
2393
2413
}
2394
2414
}
2395
- ` , cluster , np , maxBacklog , soMaxConn , tcpMem , tcpMem , twReuse )
2415
+ ` , cluster , np , linuxNodeConfig )
2396
2416
}
2397
2417
2398
2418
func testAccContainerNodePool_withNetworkConfig (cluster , np , network string ) string {
0 commit comments