Skip to content

Commit 316d14f

Browse files
committed
2 parents c3f8da8 + fb5178b commit 316d14f

11 files changed

Lines changed: 226 additions & 26 deletions

File tree

.ci/magician/github/membership_data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,6 @@ var (
200200
// This is for new team members who are onboarding
201201
trustedContributors = map[string]struct{}{
202202
"bbasata": struct{}{},
203+
"tavasyag": struct{}{},
203204
}
204205
)

mmv1/templates/terraform/constants/disk.tmpl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,6 @@ func ExpandStoragePoolUrl(v interface{}, d tpgresource.TerraformResourceData, co
317317
if err != nil {
318318
return "", err
319319
}
320-
zone, err := tpgresource.GetZone(d, config)
321-
if err != nil {
322-
return "", err
323-
}
324320
325321
formattedStr := v.(string)
326322
if strings.HasPrefix(v.(string), "/") {
@@ -338,8 +334,14 @@ func ExpandStoragePoolUrl(v interface{}, d tpgresource.TerraformResourceData, co
338334
// For regional or zonal resources which include their region or zone, just put the project in front.
339335
replacedStr = config.ComputeBasePath + "projects/" + project + "/" + formattedStr
340336
} else {
337+
// Resources like instance template do not have a zone argument.
338+
// In this case, run GetZone when it is strictly necessary.
339+
zone, err := tpgresource.GetZone(d, config)
340+
if err != nil {
341+
return "", err
342+
}
341343
// Anything else is assumed to be a zonal resource, with a partial link that begins with the resource name.
342344
replacedStr = config.ComputeBasePath + "projects/" + project + "/zones/" + zone + "/storagePools/" + formattedStr
343345
}
344346
return replacedStr, nil
345-
}
347+
}

mmv1/third_party/terraform/registry/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (p Product) Register() {
3535
products.m[p.Name] = p
3636
}
3737

38-
// Product returns the product information for the given product name. The function panics
38+
// GetProduct returns the product information for the given product name. The function panics
3939
// if the requested product is not registered. This function is called during provider
4040
// intitialization when the absence of a product is an unrecoverable error.
4141
func GetProduct(name string) Product {

mmv1/third_party/terraform/services/container/node_config.go.tmpl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,21 @@ func schemaNodeConfig() *schema.Schema {
11431143
},
11441144
},
11451145
},
1146+
"accurate_time_config": {
1147+
Type: schema.TypeList,
1148+
Optional: true,
1149+
MaxItems: 1,
1150+
Description: `The settings for the accurate time configuration.`,
1151+
Elem: &schema.Resource{
1152+
Schema: map[string]*schema.Schema{
1153+
"enable_ptp_kvm_time_sync": {
1154+
Type: schema.TypeBool,
1155+
Optional: true,
1156+
Description: `Whether to enable accurate time synchronization with PTP-KVM.`,
1157+
},
1158+
},
1159+
},
1160+
},
11461161
},
11471162
},
11481163
},
@@ -2145,6 +2160,10 @@ func expandLinuxNodeConfig(v interface{}) *container.LinuxNodeConfig {
21452160
linuxNodeConfig.SwapConfig = expandSwapConfig(v)
21462161
}
21472162

2163+
if v, ok := cfg["accurate_time_config"]; ok {
2164+
linuxNodeConfig.AccurateTimeConfig = expandAccurateTimeConfig(v)
2165+
}
2166+
21482167
return linuxNodeConfig
21492168
}
21502169

@@ -2235,6 +2254,28 @@ func expandNodeKernelModuleLoading(v interface{}) *container.NodeKernelModuleLoa
22352254
return NodeKernelModuleLoading
22362255
}
22372256

2257+
func expandAccurateTimeConfig(v interface{}) *container.AccurateTimeConfig {
2258+
if v == nil {
2259+
return nil
2260+
}
2261+
ls := v.([]interface{})
2262+
if len(ls) == 0 {
2263+
return nil
2264+
}
2265+
if ls[0] == nil {
2266+
return &container.AccurateTimeConfig{}
2267+
}
2268+
cfg := ls[0].(map[string]interface{})
2269+
2270+
accurateTimeConfig := &container.AccurateTimeConfig{}
2271+
2272+
if v, ok := cfg["enable_ptp_kvm_time_sync"]; ok {
2273+
accurateTimeConfig.EnablePtpKvmTimeSync = v.(bool)
2274+
}
2275+
2276+
return accurateTimeConfig
2277+
}
2278+
22382279
func expandSwapConfig(v interface{}) *container.SwapConfig {
22392280
if v == nil {
22402281
return nil
@@ -3225,6 +3266,17 @@ func flattenLinuxNodeConfig(c *container.LinuxNodeConfig) []map[string]interface
32253266
"transparent_hugepage_defrag": c.TransparentHugepageDefrag,
32263267
"node_kernel_module_loading": flattenNodeKernelModuleLoading(c.NodeKernelModuleLoading),
32273268
"swap_config": flattenSwapConfig(c.SwapConfig),
3269+
"accurate_time_config": flattenAccurateTimeConfig(c.AccurateTimeConfig),
3270+
})
3271+
}
3272+
return result
3273+
}
3274+
3275+
func flattenAccurateTimeConfig(c *container.AccurateTimeConfig) []map[string]interface{} {
3276+
result := []map[string]interface{}{}
3277+
if c != nil {
3278+
result = append(result, map[string]interface{}{
3279+
"enable_ptp_kvm_time_sync": c.EnablePtpKvmTimeSync,
32283280
})
32293281
}
32303282
return result

mmv1/third_party/terraform/services/container/resource_container_cluster_meta.yaml.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ fields:
358358
- api_field: 'nodeConfig.kubeletConfig.topologyManager.policy'
359359
- api_field: 'nodeConfig.kubeletConfig.topologyManager.scope'
360360
- api_field: 'nodeConfig.labels'
361+
- api_field: 'nodeConfig.linuxNodeConfig.accurateTimeConfig.enablePtpKvmTimeSync'
361362
- api_field: 'nodeConfig.linuxNodeConfig.cgroupMode'
362363
- field: 'node_config.linux_node_config.hugepages_config.hugepage_size_1g'
363364
api_field: 'nodeConfig.linuxNodeConfig.hugepages.hugepageSize1g'
@@ -642,6 +643,8 @@ fields:
642643
api_field: 'nodePools.config.kubeletConfig.topologyManager.scope'
643644
- field: 'node_pool.node_config.labels'
644645
api_field: 'nodePools.config.labels'
646+
- field: 'node_pool.node_config.linux_node_config.accurate_time_config.enable_ptp_kvm_time_sync'
647+
api_field: 'nodePools.config.linuxNodeConfig.accurateTimeConfig.enablePtpKvmTimeSync'
645648
- field: 'node_pool.node_config.linux_node_config.cgroup_mode'
646649
api_field: 'nodePools.config.linuxNodeConfig.cgroupMode'
647650
- field: 'node_pool.node_config.linux_node_config.hugepages_config.hugepage_size_1g'

mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,7 @@ func TestAccContainerCluster_withNodeConfigLinuxNodeConfig(t *testing.T) {
23122312
Steps: []resource.TestStep{
23132313
// First test with empty `node_config.linux_node_config` (should result in "CGROUP_MODE_UNSPECIFIED")
23142314
{
2315-
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "", false, ""),
2315+
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "", false, false, ""),
23162316
ConfigPlanChecks: resource.ConfigPlanChecks{
23172317
PreApply: []plancheck.PlanCheck{
23182318
acctest.ExpectNoDelete(),
@@ -2327,7 +2327,7 @@ func TestAccContainerCluster_withNodeConfigLinuxNodeConfig(t *testing.T) {
23272327
},
23282328
// Then add a config and make sure it updates.
23292329
{
2330-
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "CGROUP_MODE_V2", false, ""),
2330+
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "CGROUP_MODE_V2", false, false, ""),
23312331
Check: resource.ComposeTestCheckFunc(
23322332
resource.TestCheckResourceAttr(
23332333
"google_container_cluster.with_linux_node_config",
@@ -2349,12 +2349,12 @@ func TestAccContainerCluster_withNodeConfigLinuxNodeConfig(t *testing.T) {
23492349
// Lastly, update the setting in-place. V1 since UNSPECIFIED is default
23502350
// From version 1.35+, cgroup mode v1 will be blocked.
23512351
{
2352-
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "CGROUP_MODE_V1", false, ""),
2352+
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "CGROUP_MODE_V1", false, false, ""),
23532353
ExpectError: regexp.MustCompile("Node pools with cgroupv1 is not supported"),
23542354
},
23552355
// Update linux config transparent hugepage
23562356
{
2357-
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "", true, ""),
2357+
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "", true, false, ""),
23582358
Check: resource.ComposeTestCheckFunc(
23592359
resource.TestCheckResourceAttr(
23602360
"google_container_cluster.with_linux_node_config",
@@ -2379,7 +2379,7 @@ func TestAccContainerCluster_withNodeConfigLinuxNodeConfig(t *testing.T) {
23792379
},
23802380
// Update node kernel module loading policy
23812381
{
2382-
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "CGROUP_MODE_V2", false, "ENFORCE_SIGNED_MODULES"),
2382+
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "CGROUP_MODE_V2", false, false, "ENFORCE_SIGNED_MODULES"),
23832383
Check: resource.ComposeTestCheckFunc(
23842384
resource.TestCheckResourceAttr(
23852385
"google_container_cluster.with_linux_node_config",
@@ -2404,7 +2404,7 @@ func TestAccContainerCluster_withNodeConfigLinuxNodeConfig(t *testing.T) {
24042404
},
24052405
// Unset node kernel module loading policy
24062406
{
2407-
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "", false, "DO_NOT_ENFORCE_SIGNED_MODULES"),
2407+
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "", false, false, "DO_NOT_ENFORCE_SIGNED_MODULES"),
24082408
Check: resource.ComposeTestCheckFunc(
24092409
resource.TestCheckResourceAttr(
24102410
"google_container_cluster.with_linux_node_config",
@@ -2423,6 +2423,27 @@ func TestAccContainerCluster_withNodeConfigLinuxNodeConfig(t *testing.T) {
24232423
ImportStateVerify: true,
24242424
ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"},
24252425
},
2426+
// Update node accurate time config
2427+
{
2428+
Config: testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, "CGROUP_MODE_V2", false, true, ""),
2429+
Check: resource.ComposeTestCheckFunc(
2430+
resource.TestCheckResourceAttr(
2431+
"google_container_cluster.with_linux_node_config",
2432+
"node_config.0.linux_node_config.0.accurate_time_config.0.enable_ptp_kvm_time_sync", "true",
2433+
),
2434+
),
2435+
ConfigPlanChecks: resource.ConfigPlanChecks{
2436+
PreApply: []plancheck.PlanCheck{
2437+
acctest.ExpectNoDelete(),
2438+
},
2439+
},
2440+
},
2441+
{
2442+
ResourceName: "google_container_cluster.with_linux_node_config",
2443+
ImportState: true,
2444+
ImportStateVerify: true,
2445+
ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"},
2446+
},
24262447
},
24272448
})
24282449
}
@@ -9987,11 +10008,11 @@ resource "google_container_cluster" "with_node_config" {
998710008
`, clusterName, networkName, subnetworkName)
998810009
}
998910010

9990-
func testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, cgroupMode string, thpEnabled bool, nkmlPolicy string) string {
10011+
func testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkName, subnetworkName, cgroupMode string, thpEnabled, ptpEnabled bool, nkmlPolicy string) string {
999110012
// Empty block inside node_config if sub-fields are empty
999210013
linuxNodeConfig := ""
999310014

9994-
if cgroupMode != "" || thpEnabled || nkmlPolicy != "" {
10015+
if cgroupMode != "" || thpEnabled || nkmlPolicy != "" || ptpEnabled {
999510016
linuxNodeConfig = `linux_node_config {
999610017
`
999710018
if cgroupMode != "" {
@@ -10010,6 +10031,12 @@ func testAccContainerCluster_withNodeConfigLinuxNodeConfig(clusterName, networkN
1001010031
}
1001110032
`, nkmlPolicy)
1001210033
}
10034+
if ptpEnabled {
10035+
linuxNodeConfig = linuxNodeConfig + fmt.Sprintf(`accurate_time_config {
10036+
enable_ptp_kvm_time_sync = %t
10037+
}
10038+
`, ptpEnabled)
10039+
}
1001310040
linuxNodeConfig = linuxNodeConfig + "}"
1001410041
}
1001510042

mmv1/third_party/terraform/services/container/resource_container_node_pool_meta.yaml.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ fields:
212212
api_field: 'config.kubeletConfig.topologyManager.scope'
213213
- field: 'node_config.labels'
214214
api_field: 'config.labels'
215+
- field: 'node_config.linux_node_config.accurate_time_config.enable_ptp_kvm_time_sync'
216+
api_field: 'config.linuxNodeConfig.accurateTimeConfig.enablePtpKvmTimeSync'
215217
- field: 'node_config.linux_node_config.cgroup_mode'
216218
api_field: 'config.linuxNodeConfig.cgroupMode'
217219
- field: 'node_config.linux_node_config.hugepages_config.hugepage_size_1g'

mmv1/third_party/terraform/services/container/resource_container_node_pool_test.go.tmpl

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,45 @@ func TestAccContainerNodePool_withNodeDrainConfig(t *testing.T) {
16261626
})
16271627
}
16281628

1629+
func TestAccContainerNodePool_withAccurateTimeConfig(t *testing.T) {
1630+
t.Parallel()
1631+
1632+
cluster := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
1633+
nodePool := fmt.Sprintf("tf-test-nodepool-%s", acctest.RandString(t, 10))
1634+
networkName := acctest.BootstrapSharedTestNetwork(t, "gke-cluster")
1635+
subnetworkName := acctest.BootstrapSubnet(t, "gke-cluster", networkName)
1636+
1637+
acctest.VcrTest(t, resource.TestCase{
1638+
PreCheck: func() { acctest.AccTestPreCheck(t) },
1639+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1640+
CheckDestroy: testAccCheckContainerNodePoolDestroyProducer(t),
1641+
Steps: []resource.TestStep{
1642+
{
1643+
Config: testAccContainerNodePool_withAccurateTimeConfig(cluster, nodePool, networkName, subnetworkName, true),
1644+
Check: resource.ComposeTestCheckFunc(
1645+
resource.TestCheckResourceAttr("google_container_node_pool.np_with_time_config", "node_config.0.linux_node_config.0.accurate_time_config.0.enable_ptp_kvm_time_sync", "true"),
1646+
),
1647+
},
1648+
{
1649+
ResourceName: "google_container_node_pool.np_with_time_config",
1650+
ImportState: true,
1651+
ImportStateVerify: true,
1652+
},
1653+
{
1654+
Config: testAccContainerNodePool_withAccurateTimeConfig(cluster, nodePool, networkName, subnetworkName, false),
1655+
Check: resource.ComposeTestCheckFunc(
1656+
resource.TestCheckResourceAttr("google_container_node_pool.np_with_time_config", "node_config.0.linux_node_config.0.accurate_time_config.0.enable_ptp_kvm_time_sync", "false"),
1657+
),
1658+
},
1659+
{
1660+
ResourceName: "google_container_node_pool.np_with_time_config",
1661+
ImportState: true,
1662+
ImportStateVerify: true,
1663+
},
1664+
},
1665+
})
1666+
}
1667+
16291668
func TestAccContainerNodePool_withNodeConfigScopeAlias(t *testing.T) {
16301669
t.Parallel()
16311670

@@ -4721,6 +4760,39 @@ resource "google_container_node_pool" "np_with_node_drain_config" {
47214760
`, cluster, networkName, subnetworkName, np)
47224761
}
47234762

4763+
func testAccContainerNodePool_withAccurateTimeConfig(cluster, np, networkName, subnetworkName string, enablePTP bool) string {
4764+
return fmt.Sprintf(`
4765+
data "google_container_engine_versions" "central1a" {
4766+
location = "us-central1-a"
4767+
}
4768+
4769+
resource "google_container_cluster" "cluster" {
4770+
name = "%s"
4771+
location = "us-central1-a"
4772+
initial_node_count = 1
4773+
min_master_version = data.google_container_engine_versions.central1a.latest_master_version
4774+
deletion_protection = false
4775+
network = "%s"
4776+
subnetwork = "%s"
4777+
}
4778+
4779+
resource "google_container_node_pool" "np_with_time_config" {
4780+
name = "%s"
4781+
location = "us-central1-a"
4782+
cluster = google_container_cluster.cluster.name
4783+
initial_node_count = 1
4784+
node_config {
4785+
image_type = "COS_CONTAINERD"
4786+
linux_node_config {
4787+
accurate_time_config {
4788+
enable_ptp_kvm_time_sync = %t
4789+
}
4790+
}
4791+
}
4792+
}
4793+
`, cluster, networkName, subnetworkName, np, enablePTP)
4794+
}
4795+
47244796
func testAccContainerNodePool_version(cluster, np, networkName, subnetworkName string) string {
47254797
return fmt.Sprintf(`
47264798
data "google_container_engine_versions" "central1a" {

mmv1/third_party/terraform/transport/provider_handwritten_endpoint.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,37 @@ var ContainerAzureCustomEndpointEntry = &schema.Schema{
6060
}
6161
var ApikeysEndpointEntryKey = "apikeys_custom_endpoint"
6262
var ApikeysEndpointEntry = &schema.Schema{
63-
Type: schema.TypeString,
64-
Optional: true,
63+
Type: schema.TypeString,
64+
Optional: true,
65+
ValidateFunc: ValidateCustomEndpoint,
6566
}
6667

6768
var AssuredWorkloadsEndpointEntryKey = "assured_workloads_custom_endpoint"
6869
var AssuredWorkloadsEndpointEntry = &schema.Schema{
69-
Type: schema.TypeString,
70-
Optional: true,
70+
Type: schema.TypeString,
71+
Optional: true,
72+
ValidateFunc: ValidateCustomEndpoint,
7173
}
7274

7375
var CloudResourceManagerEndpointEntryKey = "cloud_resource_manager_custom_endpoint"
7476
var CloudResourceManagerEndpointEntry = &schema.Schema{
75-
Type: schema.TypeString,
76-
Optional: true,
77+
Type: schema.TypeString,
78+
Optional: true,
79+
ValidateFunc: ValidateCustomEndpoint,
7780
}
7881

7982
var FirebaserulesEndpointEntryKey = "firebaserules_custom_endpoint"
8083
var FirebaserulesEndpointEntry = &schema.Schema{
81-
Type: schema.TypeString,
82-
Optional: true,
84+
Type: schema.TypeString,
85+
Optional: true,
86+
ValidateFunc: ValidateCustomEndpoint,
8387
}
8488

8589
var RecaptchaEnterpriseEndpointEntryKey = "recaptcha_enterprise_custom_endpoint"
8690
var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
87-
Type: schema.TypeString,
88-
Optional: true,
91+
Type: schema.TypeString,
92+
Optional: true,
93+
ValidateFunc: ValidateCustomEndpoint,
8994
}
9095

9196
func ValidateCustomEndpoint(v interface{}, k string) (ws []string, errors []error) {

0 commit comments

Comments
 (0)