Skip to content

Commit

Permalink
Merge pull request #112 from dell/bugfix/max-snapshot-name-length
Browse files Browse the repository at this point in the history
Truncate snapshot name to max characters length
  • Loading branch information
falfaroc authored Jul 19, 2022
2 parents 2305155 + 04a76fa commit c313f7f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"errors"
"fmt"
"math"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -1704,7 +1705,8 @@ func (s *service) CreateSnapshot(
if req.Name != "" && len(req.Name) > 31 {
name := req.Name
name = strings.Replace(name, "snapshot-", "sn-", 1)
name = name[0:31]
length := int(math.Min(float64(len(name)), 31))
name = name[0:length]
Log.Printf("Requested name %s longer than 31 character max, truncated to %s\n", req.Name, name)
req.Name = name
}
Expand Down

0 comments on commit c313f7f

Please sign in to comment.