Skip to content

Commit

Permalink
[kueuectl] Fix resource flavor name pattern on create cq (kubernetes-…
Browse files Browse the repository at this point in the history
  • Loading branch information
trasc authored and kannon92 committed Nov 19, 2024
1 parent 21d3a88 commit af088b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/kueuectl/app/create/create_clusterqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (o *ClusterQueueOptions) parseResourceGroups() error {
func parseUserSpecifiedResourceQuotas(resources []string, quotaType string) ([]v1beta1.ResourceGroup, error) {
var resourceGroups []v1beta1.ResourceGroup

regex := regexp.MustCompile(`^(\w+):((\w+[\.-]?)*\/?\w+=\w+;)*(\w+[\.-]?)*\/?\w+=\w+;?$`)
regex := regexp.MustCompile(`^([a-z0-9][a-z0-9\-\.]{0,252}):((\w+[\.-]?)*\/?\w+=\w+;)*(\w+[\.-]?)*\/?\w+=\w+;?$`)
for _, r := range resources {
if !regex.MatchString(r) {
return resourceGroups, errInvalidResourcesSpec
Expand Down
7 changes: 4 additions & 3 deletions cmd/kueuectl/app/create/create_clusterqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,15 @@ func TestParseResourceQuotas(t *testing.T) {
wantResourceGroups []v1beta1.ResourceGroup
}{
"should create one resource group with one flavor and nominalQuota set": {
quotaArgs: []string{"alpha:cpu=1;memory=1"},
quotaArgs: []string{"alpha-2.0:cpu=1;memory=1;example-1.org/memory=5Gi"},
wantResourceGroups: []v1beta1.ResourceGroup{
{
CoveredResources: []corev1.ResourceName{"cpu", "memory"},
CoveredResources: []corev1.ResourceName{"cpu", "memory", "example-1.org/memory"},
Flavors: []v1beta1.FlavorQuotas{
*utiltesting.MakeFlavorQuotas("alpha").
*utiltesting.MakeFlavorQuotas("alpha-2.0").
Resource("cpu", "1").
Resource("memory", "1").
Resource("example-1.org/memory", "5Gi").
Obj(),
},
},
Expand Down

0 comments on commit af088b5

Please sign in to comment.