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

GIDs are not allocated correctly above certain volume threshold #1217

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

RomanBednar
Copy link
Contributor

Is this a bug fix or adding new feature?

Bug fix.

What is this PR about? / Why do we need it?

There are two smaller issues addressed in this PR:

  • EFS client call DescribeAccessPointsRequest is limited to 100 results by default, so when more than 100 access points are created for a filesystem we don't get a full listing. Because of this allocator will assign GIDs that are already used which is incorrect.

  • When GID range exceeds the current access point limit, allocator picks the upper range, but it makes more sense to use lower GIDs first starting from gidRangeStart/gidMin.

Reproducer:

  1. Create StorageClass with GID range 10000-90000:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: mysc
provisioner: efs.csi.aws.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
parameters:
  basePath: "/basePath"
  directoryPerms: "777"
  fileSystemId: fs-068b18a45f696ada6
  gidRangeStart: "10000"
  gidRangeEnd: "90000"
  provisioningMode: efs-ap
  subPathPattern: /subPath/${.PVC.name}/foo
allowVolumeExpansion: false
  1. Create more than 100 volumes/access points, here we can observe that above 100 volumes the same GID was is getting reused. Also it started from 89000, but starting from 10000 makes more sense.
fsap-0357469ca94e8555c  /basePath/pvc-5ad04682-04e4-4946-8deb-e655b8afb104      89100 : 89100   89100 : 89100 (777)      Available
fsap-0cc2d107780c7b345  /basePath/pvc-b15acd33-9ffe-4d56-9dac-766ca2f3c894      89100 : 89100   89100 : 89100 (777)      Available
fsap-0b4590b20c00b0bcb  /basePath/pvc-da0aa6b8-ec6b-4822-a78f-63e3b0fb7cf6      89100 : 89100   89100 : 89100 (777)      Available

What testing is done?

Unit tests + manual verification.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 12, 2023
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 12, 2023
@RomanBednar
Copy link
Contributor Author

/test pull-aws-efs-csi-driver-external-test-eks

@RomanBednar
Copy link
Contributor Author

/assign @mskanth972 @Ashley-wenyizha
for approval

@mskanth972
Copy link
Contributor

Hi @RomanBednar can you squash the commits?

DescribeAccessPointsWithContext call returns only 100 results by
default.

Since this is used for discovering used GIDs on access points we must
not allow listing only a subset of access points. This is because
gid allocator relies on this call to filter out used GIDs and getting
next *free* GID. If we don't make sure to list every access point it
will cause allocator to pick GID that might already be taken.
@RomanBednar
Copy link
Contributor Author

@mskanth972 Done.

@mskanth972
Copy link
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 Jan 2, 2024
@mskanth972
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mskanth972, RomanBednar

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

The pull request process is described here

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 Jan 2, 2024
@mskanth972 mskanth972 merged commit e7b9ce6 into kubernetes-sigs:master Jan 2, 2024
8 checks passed
@joaocc
Copy link

joaocc commented Mar 28, 2024

Hi. Since we are effectively limiting the max value for gid, should the documentation also be updated to reflect that (instead of continuing to refer the 7000000 upper limit)? Or is there any catch and I got this wrong? Thx

@RomanBednar
Copy link
Contributor Author

@joaocc There is no new limit being introduced here, this was just a minor bug fix in GID allocations.

However there's a limit for number of access points for EFS itself, recently increased from 120 to 1000, documented here: https://docs.aws.amazon.com/efs/latest/ug/limits.html#limits-efs-resources-per-account-per-region

So this patch just makes sure we discover all possible GIDs allocated/used (max 1000) when calling AWS API to see what GIDs are currently used and new ones allocated correctly - this is because the call returns 100 records only by default even if more are present and would confuse GID allocator. Example: now if you set gidRangeStart to 1000 you should be able to allocate access points getting GIDs within 1000-1999 range.

@joaocc
Copy link

joaocc commented Apr 2, 2024

Thanks for the clarification.
However, and please excuse me if I got this wrong, but it seems the documentation in the documentation (gidRangeStart=50000 and gidRangeEnd=7000000) are not taking this into account.

@RomanBednar
Copy link
Contributor Author

I believe you are referring to this documentation - yes it's confusing since the internal limit is not obvious from driver doc. Maybe there's some use case where it makes sense to set higher range, not sure. Feel free to create an issue if you think this should be corrected so one of the maintainers can weight in on this.

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. 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.

5 participants