Skip to content

Commit

Permalink
Support new max-volumes-per-node error message
Browse files Browse the repository at this point in the history
A different message is going to be introduced soon.
  • Loading branch information
Timo Reimann committed Jun 3, 2024
1 parent 6f263da commit c415d10
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ const (
// Digital Ocean API. NOTE: some queries inherit the context timeout
doAPITimeout = 10 * time.Second

// maxVolumesPerDropletErrorMessage is the error message returned by the DO
// API when the per-droplet volume limit would be exceeded.
maxVolumesPerDropletErrorMessage = "cannot attach more than 7 volumes to a single Droplet"
// maxVolumesPerDropletErrorLegacyMessage is the old error message returned by
// the DO API when the per-droplet volume limit would be exceeded.
maxVolumesPerDropletErrorLegacyMessage = "cannot attach more than 7 volumes to a single Droplet"

// maxVolumesPerDropletErrorMessage is the error message returned by the DO API
// when the per-droplet volume limit would be exceeded.
maxVolumesPerDropletErrorMessage = "cannot attach more volumes to the Droplet"
)

var (
Expand Down Expand Up @@ -384,7 +388,8 @@ func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.Controlle
return nil, status.Errorf(codes.Aborted, "cannot attach because droplet %d has pending action for volume %q", dropletID, req.VolumeId)
}

if strings.Contains(err.Error(), maxVolumesPerDropletErrorMessage) {
if strings.Contains(err.Error(), maxVolumesPerDropletErrorMessage) ||
strings.Contains(err.Error(), maxVolumesPerDropletErrorLegacyMessage) {
return nil, status.Errorf(codes.ResourceExhausted, err.Error())
}
}
Expand Down

0 comments on commit c415d10

Please sign in to comment.