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

Make volumes-per-node limit configurable [CON-10973] #575

Merged
merged 2 commits into from
Aug 7, 2024
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## unreleased

* Make volumes-per-node limit configurable
[[GH-575]](https://github.com/digitalocean/csi-digitalocean/pull/575)

## v4.10.0 - 2024.06.05

* Handle new max-volumes-per-node error message
Expand Down
2 changes: 2 additions & 0 deletions cmd/do-csi-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func main() {
defaultVolumesPageSize = flag.Uint("default-volumes-page-size", 0, "The default page size used when paging through volumes results (default: do not specify and let the DO API choose)")
doAPIRateLimitQPS = flag.Float64("do-api-rate-limit", 0, "Impose QPS rate limit on DigitalOcean API usage (default: do not rate limit)")
validateAttachment = flag.Bool("validate-attachment", false, "Validate if the attachment has fully completed before formatting/mounting the device")
volumeLimit = flag.Uint("volume-limit", 7, "Volumes per node limit to report; needs to match limit imposed by DO storage backend (honored by Node service only)")
version = flag.Bool("version", false, "Print the version and exit.")
)
flag.Parse()
Expand All @@ -64,6 +65,7 @@ func main() {
DefaultVolumesPageSize: *defaultVolumesPageSize,
DOAPIRateLimitQPS: *doAPIRateLimitQPS,
ValidateAttachment: *validateAttachment,
VolumeLimit: *volumeLimit,
})
if err != nil {
log.Fatalln(err)
Expand Down
11 changes: 8 additions & 3 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (
// DefaultDriverName defines the name that is used in Kubernetes and the CSI
// system for the canonical, official name of this plugin
DefaultDriverName = "dobs.csi.digitalocean.com"

defaultMaxVolumesPerNode = 7
)

var (
Expand Down Expand Up @@ -86,8 +88,9 @@ type Driver struct {

// ready defines whether the driver is ready to function. This value will
// be used by the `Identity` service via the `Probe()` method.
readyMu sync.Mutex // protects ready
ready bool
readyMu sync.Mutex // protects ready
ready bool
volumeLimit uint
}

// NewDriverParams defines the parameters that can be passed to NewDriver.
Expand All @@ -102,6 +105,7 @@ type NewDriverParams struct {
DefaultVolumesPageSize uint
DOAPIRateLimitQPS float64
ValidateAttachment bool
VolumeLimit uint
}

// NewDriver returns a CSI plugin that contains the necessary gRPC
Expand Down Expand Up @@ -167,6 +171,7 @@ func NewDriver(p NewDriverParams) (*Driver, error) {
endpoint: p.Endpoint,
debugAddr: p.DebugAddr,
defaultVolumesPageSize: p.DefaultVolumesPageSize,
volumeLimit: p.VolumeLimit,

hostID: func() string { return hostID },
region: region,
Expand Down Expand Up @@ -236,7 +241,7 @@ func (d *Driver) Run(ctx context.Context) error {
d.log.WithFields(logrus.Fields{
"limit": details.limit,
"num_volumes": details.numVolumes,
}).Warn("CSI plugin will not function correctly, please resolve volume limit")
}).Warn("CSI plugin may not function correctly, please resolve volume limit")
}

if d.debugAddr != "" {
Expand Down
2 changes: 1 addition & 1 deletion driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (f *fakeStorageActionsDriver) Attach(ctx context.Context, volumeID string,
return nil, resp, errors.New("droplet was not found")
}

if len(droplet.VolumeIDs) >= maxVolumesPerNode {
if len(droplet.VolumeIDs) >= defaultMaxVolumesPerNode {
resp.Response = &http.Response{
StatusCode: http.StatusUnprocessableEntity,
}
Expand Down
5 changes: 1 addition & 4 deletions driver/node.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading