Skip to content
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

Adding Logs On How We Calculate CSINode.allocatables in NodeGetInfo #2372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/cloud/metadata/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func EC2MetadataInstanceInfo(svc EC2Metadata, regionFromSession string) (*Metada
return nil, fmt.Errorf("could not read ENIs metadata content: %w", err)
}
attachedENIs := util.CountMACAddresses(string(enis))
klog.V(4).InfoS("Number of attached ENIs", "attachedENIs", attachedENIs)

blockDevMappings := 0
if !util.IsSBE(doc.Region) {
Expand Down
13 changes: 10 additions & 3 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,11 @@ func (d *NodeService) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoReque
}

topology := &csi.Topology{Segments: segments}

maxVolumesPerNode := d.getVolumesLimit()
klog.V(4).InfoS("NodeGetInfo:", "Node Allocatables", maxVolumesPerNode)
return &csi.NodeGetInfoResponse{
NodeId: d.metadata.GetInstanceID(),
MaxVolumesPerNode: d.getVolumesLimit(),
MaxVolumesPerNode: maxVolumesPerNode,
AccessibleTopology: topology,
}, nil
}
Expand Down Expand Up @@ -765,21 +766,26 @@ func (d *NodeService) nodePublishVolumeForFileSystem(req *csi.NodePublishVolumeR
// getVolumesLimit returns the limit of volumes that the node supports.
func (d *NodeService) getVolumesLimit() int64 {
if d.options.VolumeAttachLimit >= 0 {
klog.V(4).InfoS("getVolumesLimit: VolumeAttachLimit manually set to", d.options.VolumeAttachLimit, "overriding the default value")
return d.options.VolumeAttachLimit
}
if util.IsSBE(d.metadata.GetRegion()) {
return sbeDeviceVolumeAttachmentLimit
}

instanceType := d.metadata.GetInstanceType()
klog.V(4).InfoS("getVolumesLimit:", "instanceType", instanceType)

isNitro := cloud.IsNitroInstanceType(instanceType)
availableAttachments := cloud.GetMaxAttachments(isNitro)
klog.V(4).InfoS("getVolumesLimit:", "maxAttachments", availableAttachments)

reservedVolumeAttachments := d.options.ReservedVolumeAttachments
if reservedVolumeAttachments == -1 {
reservedVolumeAttachments = d.metadata.GetNumBlockDeviceMappings() + 1 // +1 for the root device
klog.V(4).InfoS("getVolumesLimit:", "numBlockDevices", (reservedVolumeAttachments - 1))
}
klog.V(4).InfoS("getVolumesLimit:", "reservedVolumeAttachments", reservedVolumeAttachments)

dedicatedLimit := cloud.GetDedicatedLimitForInstanceType(instanceType)
maxEBSAttachments, hasMaxVolumeLimit := cloud.GetEBSLimitForInstanceType(instanceType)
Expand All @@ -792,7 +798,9 @@ func (d *NodeService) getVolumesLimit() int64 {
availableAttachments = dedicatedLimit
} else if isNitro {
enis := d.metadata.GetNumAttachedENIs()
klog.V(4).InfoS("getVolumesLimit:", "numeENIs", enis)
Copy link
Member

Choose a reason for hiding this comment

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

typo: numeENIs

reservedSlots := cloud.GetReservedSlotsForInstanceType(instanceType)
klog.V(4).InfoS("getVolumesLimit:", "reservedSlots", reservedSlots)
if hasMaxVolumeLimit {
availableAttachments = availableAttachments - (enis - 1) - reservedSlots
} else {
Expand All @@ -803,7 +811,6 @@ func (d *NodeService) getVolumesLimit() int64 {
if availableAttachments <= 0 {
availableAttachments = 1
}

return int64(availableAttachments)
}

Expand Down