-
Notifications
You must be signed in to change notification settings - Fork 190
Support Downward API node name override #2277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ type GCENodeServer struct { | |
| EnableDataCache bool | ||
| DataCacheEnabledNodePool bool | ||
| SysfsPath string | ||
| nodeName string | ||
|
|
||
| // A map storing all volumes with ongoing operations so that additional operations | ||
| // for that same volume (as defined by VolumeID) return an Aborted error | ||
|
|
@@ -103,6 +104,8 @@ type NodeServerArgs struct { | |
| // SysfsPath defaults to "/sys", except if it's a unit test. | ||
| SysfsPath string | ||
|
|
||
| NodeName string | ||
|
|
||
| MetricsManager *metrics.MetricsManager | ||
| DeviceCache *linkcache.DeviceCache | ||
|
|
||
|
|
@@ -187,6 +190,15 @@ func (ns *GCENodeServer) WithSerializedFormatAndMount(timeout time.Duration, max | |
| return ns | ||
| } | ||
|
|
||
| // GetNodeName returns the node name, prioritizing the override value (from Downward API) | ||
| // over the metadata service if available. | ||
| func (ns *GCENodeServer) GetNodeName() string { | ||
| if ns.nodeName != "" { | ||
| return ns.nodeName | ||
| } | ||
| return ns.MetadataService.GetName() | ||
| } | ||
|
|
||
| func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { | ||
| // Validate Arguments | ||
| targetPath := req.GetTargetPath() | ||
|
|
@@ -731,9 +743,9 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe | |
| Segments: map[string]string{constants.TopologyKeyZone: ns.MetadataService.GetZone()}, | ||
| } | ||
|
|
||
| node, err := k8sclient.GetNodeWithRetry(ctx, ns.MetadataService.GetName()) | ||
| node, err := k8sclient.GetNodeWithRetry(ctx, ns.GetNodeName()) | ||
| if err != nil { | ||
| klog.Errorf("Failed to get node %s: %v. The error is ignored so that the driver can register", ns.MetadataService.GetName(), err.Error()) | ||
| klog.Errorf("Failed to get node %s: %v. The error is ignored so that the driver can register", ns.GetNodeName(), err.Error()) | ||
| } | ||
|
|
||
| if ns.EnableDynamicVolumes { | ||
|
|
@@ -747,7 +759,7 @@ func (ns *GCENodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRe | |
| } | ||
| } | ||
|
|
||
| nodeID := common.CreateNodeID(ns.MetadataService.GetProject(), ns.MetadataService.GetZone(), ns.MetadataService.GetName()) | ||
| nodeID := common.CreateNodeID(ns.MetadataService.GetProject(), ns.MetadataService.GetZone(), ns.GetNodeName()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This chanage is causing the following error: i think for nodeID it should keep getting the name from MetadataService
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hey @sunnylovestiramisu , I've tried the following fix from my forked repo: There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| volumeLimits, err := ns.getVolumeLimits(ctx, node) | ||
| if err != nil { | ||
|
|
||
There was a problem hiding this comment.
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
nodeNameandnodeIdfor data cache. @sunnylovestiramisu can you help review?There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.