Skip to content

Support Downward API node name override#2277

Merged
k8s-ci-robot merged 2 commits into
kubernetes-sigs:masterfrom
hajiler:get-name-fix-branch
Feb 26, 2026
Merged

Support Downward API node name override#2277
k8s-ci-robot merged 2 commits into
kubernetes-sigs:masterfrom
hajiler:get-name-fix-branch

Conversation

@hajiler
Copy link
Copy Markdown
Contributor

@hajiler hajiler commented Feb 25, 2026

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind bug

What this PR does / why we need it:
Implement Downward API node name override in PDCSI driver to prioritize the Kubernetes-provided node name via --node-name flag over the GCE metadata service. This ensures accurate node identification when interacting with the Kubernetes API, particularly for NodeGetInfo operations that fetch node labels and topology information.

Which issue(s) this PR fixes:

Fixes #2276
Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Override the GCE Metadata Service name by setting the node-name flag.

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Feb 25, 2026
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 25, 2026
@hajiler hajiler force-pushed the get-name-fix-branch branch from 8d54466 to fa9f638 Compare February 25, 2026 21:37
Comment thread cmd/gce-pd-csi-driver/main.go Outdated
}
if nsArgs.DataCacheEnabledNodePool {
if err := setupDataCache(ctx, *nodeName, nodeServer.MetadataService.GetName()); err != nil {
if err := setupDataCache(ctx, *nodeName, nodeServer.GetNodeName()); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the distinction is between nodeName and nodeId for data cache. @sunnylovestiramisu can you help review?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodeName is Kubernetes identifier and nodeId is GCE identifier. Most of the time they are same but back then probably just for robustness and decoupling.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should not change data cache to use the override until we can better understand if it is safe. If it is safe, I would rather merge to the two variables into one. Let's add a TODO to revisit this in the future

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted.

@sunnylovestiramisu
Copy link
Copy Markdown
Contributor

@suzezhang Please test in RH's env.

@hajiler
Copy link
Copy Markdown
Contributor Author

hajiler commented Feb 26, 2026

/retest

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

k8s-ci-robot commented Feb 26, 2026

@hajiler: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-gcp-compute-persistent-disk-csi-driver-e2e-windows-2019 fa9f638 link false /test pull-gcp-compute-persistent-disk-csi-driver-e2e-windows-2019
pull-gcp-compute-persistent-disk-csi-driver-e2e-windows-2022 fa9f638 link false /test pull-gcp-compute-persistent-disk-csi-driver-e2e-windows-2022

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@suzezhang
Copy link
Copy Markdown

@sunnylovestiramisu @hajiler verified in RH environment. After updating the env var, the override label works as expected now in RH env. Thanks for the quick fix!

@sunnylovestiramisu
Copy link
Copy Markdown
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 26, 2026
@msau42
Copy link
Copy Markdown
Contributor

msau42 commented Feb 26, 2026

/lgtm
/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hajiler, msau42

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 26, 2026
@k8s-ci-robot k8s-ci-robot merged commit 3b54ac9 into kubernetes-sigs:master Feb 26, 2026
8 of 10 checks passed
}

nodeID := common.CreateNodeID(ns.MetadataService.GetProject(), ns.MetadataService.GetZone(), ns.MetadataService.GetName())
nodeID := common.CreateNodeID(ns.MetadataService.GetProject(), ns.MetadataService.GetZone(), ns.GetNodeName())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This chanage is causing the following error:
Warning FailedAttachVolume 58m (x6 over 80m) attachdetach-controller AttachVolume.Attach failed for volume "pvc-507bb954-97fa-40aa-98c1-c78e849cac0d" : rpc error: code = InvalidArgument desc = ControllerPublish not permitted on node "projects/ocpstrat-1278/zones/us-central1-c/instances/test-gcp10-wf7zf-worker-c-6kgqn.c.ocpstrat-1278.internal" due to backoff condition Warning FailedAttachVolume 4m57s (x39 over 80m) attachdetach-controller AttachVolume.Attach failed for volume "pvc-507bb954-97fa-40aa-98c1-c78e849cac0d" : rpc error: code = InvalidArgument desc = Failed to get instance: googleapi: Error 400: Invalid value for field 'instance': 'test-gcp10-wf7zf-worker-c-6kgqn.c.ocpstrat-1278.internal'. Must be a match of regex '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?|[1-9][0-9]{0,19}', invalid

i think for nodeID it should keep getting the name from MetadataService

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already Get from MetadataService if you check the latest change, there is an additional commit merged.

Copy link
Copy Markdown

@noamasu noamasu Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @sunnylovestiramisu ,
are you reffering to d44bea1?
because this is a different code path, the error presented above comes specifically from nodeID.

I've tried the following fix from my forked repo:
https://github.com/noamasu/gcp-compute-persistent-disk-csi-driver/commit/2516027168b73db3060a42bebc4ccf04aff32e68
and it worked for me. i just want to make sure we are not missing something here :)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunnylovestiramisu I think Noam is talking about a different place for the bug.

The commit d44bea1 fixed the issue in main.go, but Noam is referring another wrong usage of GetNodeName() in node.go at line 762. It should be using the MetadataService.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node-restriction.kubernetes.io/gke-volume-attach-limit-override does not work if k8 cluster node name is different from VM instance name

6 participants