Skip to content

Commit

Permalink
Adding logs On How We Calculate CSINode.allocatables in NodeGetInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
mdzraf committed Feb 28, 2025
1 parent fd95d0a commit fce85e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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)
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

0 comments on commit fce85e4

Please sign in to comment.