pulumi / pulumi-google-native

Apache License 2.0
70 stars 18 forks source link

Can't update Container Node Pool k8s labels containing dots #909

Closed Ble4Ch closed 1 year ago

Ble4Ch commented 1 year ago

What happened?

Hello there !

We can't update container node pool labels right now, when we have dots in the new labels, especially in the key (dots in value works as expected).

On an existing node pool, if we try to add a (node) label, like key: "value", or key: "value.dot", it works. But we can't add a label like test.dot: "true" We end up with an error like: error: failed to flatten keys for detailed diff: failed to lookup value at path "config.labels.test.dot" on new inputs

Expected Behavior

I expect the labels validator to follow the labels syntax, so that we can add labels like test.dots/update: "true"

Steps to reproduce

  1. Create a simple stack:

    mkdir testTags && cd testTags && pulumi new kubernetes-gcp-typescript
  2. Update index.ts file with this one:

    
    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    import * as gnative from "@pulumi/google-native";

// Get some provider-namespaced configuration values const providerCfg = new pulumi.Config("gcp"); const gcpProject = providerCfg.require("project"); const gcpRegion = providerCfg.get("region") || "us-central1"; // Get some other configuration values or use defaults const cfg = new pulumi.Config(); const nodesPerZone = cfg.getNumber("nodesPerZone") || 1;

// Create a new network const gkeNetwork = new gcp.compute.Network("gke-network", { autoCreateSubnetworks: false, description: "A virtual network for your GKE cluster(s)", });

// Create a new subnet in the network created above const gkeSubnet = new gcp.compute.Subnetwork("gke-subnet", { ipCidrRange: "10.128.0.0/12", network: gkeNetwork.id, privateIpGoogleAccess: true, });

// Create a new GKE cluster const gkeCluster = new gcp.container.Cluster("gke-cluster", { addonsConfig: { dnsCacheConfig: { enabled: true, }, }, binaryAuthorization: { evaluationMode: "PROJECT_SINGLETON_POLICY_ENFORCE", }, datapathProvider: "ADVANCED_DATAPATH", description: "A GKE cluster", initialNodeCount: 1, ipAllocationPolicy: { clusterIpv4CidrBlock: "/14", servicesIpv4CidrBlock: "/20", }, location: gcpRegion, masterAuthorizedNetworksConfig: { cidrBlocks: [{ cidrBlock: "0.0.0.0/0", displayName: "All networks", }], }, network: gkeNetwork.name, networkingMode: "VPC_NATIVE", privateClusterConfig: { enablePrivateNodes: true, enablePrivateEndpoint: false, masterIpv4CidrBlock: "10.100.0.0/28", }, removeDefaultNodePool: true, releaseChannel: { channel: "STABLE", }, subnetwork: gkeSubnet.name, workloadIdentityConfig: { workloadPool: ${gcpProject}.svc.id.goog, }, });

const labels: { [id: string]: string } = {

["initDots"]: "true"

}

// Create a nodepool for the GKE cluster const gkeNodepool = new gnative.container.v1.NodePool("gke-nodepool", { name: "test", clusterId: gkeCluster.name, initialNodeCount: nodesPerZone, config: { labels: labels, }, });

// Export some values for use elsewhere export const networkName = gkeNetwork.name; export const networkId = gkeNetwork.id; export const clusterName = gkeCluster.name; export const clusterId = gkeCluster.id;

And launch the stack creation:

pulumi up


3. After cluster and nodepool creation, try to update the labels in the `index.ts` file with a new one:

const labels: { [id: string]: string } = {

["initDots"]: "true",
["init.Dots"]: "true"

}


3. Previewing the changes should show the error:

pulumi preview


### Output of `pulumi about`

```bash
❯ pulumi about                                                                                                                                                                                                                                                                            
CLI                                                                                                                                                                                                                                                                                       
Version      3.75.0                                                                                                                                                                                                                                                                      
Go Version   go1.19.2                                                                                                                                                                                                                                                                     
Go Compiler  gc                                                                                                                                                                                                                                                                           

Plugins                                                                                                                                                                                                                                                                                   
NAME           VERSION                                                                                                                                                                                                                                                                    
gcp            6.59.0                                                                                                                                                                                                                                                                     
google-native  0.31.0                                                                                                                                                                                                                                                                     
kubernetes     3.30.2                                                                                                                                                                                                                                                                     
nodejs         unknown                                                                                                                                                                                                                                                                    

Host                                                                                                                                                                                                                                                                                      
OS       arch                                                                                                                                                                                                                                                                             
Version  22.1.0                                                                                                                                                                                                                                                                           
Arch     x86_64

Additional context

I think the root cause is somewhere in this function

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

thomas11 commented 1 year ago

Thank you for reporting this, @Ble4Ch! This is indeed an oversight, but fortunately it will be fixed soon by #911.

Ble4Ch commented 1 year ago

Thanks for the quick replies and reviews. Did not have the time to work on a PR, great it's been resolved fast 🙏

thomas11 commented 1 year ago

@Ble4Ch, @rajiteh his fix is now released in version 0.31.1. Thank you for your report and PR!