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

quota status and quota inspect commands fail if there are multiple prefix matches #13920

Closed
lgfa29 opened this issue Jul 25, 2022 · 2 comments · Fixed by #23502
Closed

quota status and quota inspect commands fail if there are multiple prefix matches #13920

lgfa29 opened this issue Jul 25, 2022 · 2 comments · Fixed by #23502
Assignees
Labels
hcc/jira stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/cli theme/ent/quotas type/bug

Comments

@lgfa29
Copy link
Contributor

lgfa29 commented Jul 25, 2022

Nomad version

Nomad v1.3.2+ent (c0cc8626b2284ff7cb8e2aaa2d7d6943bb376574)

Operating system and Environment details

macOS

Issue

When a quota has a name that mataches another quota name prefix it's impossible to use the quota status and quota inspect commands.

Reproduction steps

$ nomad agent -dev
...

$ nomad quota apply quota1.hcl
Successfully applied quota specification "default-quota"!

$ nomad quota apply quota2.hcl
Successfully applied quota specification "default-quota-2"!

$ nomad quota list
Name             Description
default-quota    Limit the shared default namespace
default-quota-2  Limit the shared default namespace

$ nomad quota status default-quota
Prefix matched multiple quotas

Name             Description
default-quota    Limit the shared default namespace
default-quota-2  Limit the shared default namespace

$ nomad quota inspect default-quota
Prefix matched multiple quotas

Name             Description
default-quota    Limit the shared default namespace
default-quota-2  Limit the shared default namespace

Expected Result

quota status and quota inspect returns the information for the specified quota.

Actual Result

Multiple prefix match error.

Quota files

# quota1.hcl
name        = "default-quota"
description = "Limit the shared default namespace"

limit {
  region = "global"
  region_limit {
    cpu        = 2500
    memory     = 1000
    memory_max = 1000
  }
}
# quota2.hcl
name        = "default-quota-2"
description = "Limit the shared default namespace"

limit {
  region = "global"
  region_limit {
    cpu        = 2500
    memory     = 1000
    memory_max = 1000
  }
}
@lgfa29 lgfa29 added type/bug theme/cli stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/ent/quotas labels Jul 25, 2022
@tgross
Copy link
Member

tgross commented Aug 1, 2022

Looks like nomad quota delete is similarly broken.

@tgross
Copy link
Member

tgross commented Jul 3, 2024

PR in progress here: #23502

tgross added a commit that referenced this issue Jul 8, 2024
Several commands that inspect objects where the names are user-controlled share
a bug where the user cannot inspect the object if it has a name that is an exact
prefix of the name of another object (in the same namespace, where
applicable). For example, the object "test" can't be inspected if there's an
object with the name "testing".

Copy existing logic we have for jobs, node pools, etc. to the impacted commands:

* `plugin status`
* `quota inspect`
* `quota status`
* `scaling policy info`
* `service info`
* `volume deregister`
* `volume detach`
* `volume status`

If we get multiple objects for the prefix query, we check if any of them are an
exact match and use that object instead of returning an error. Where possible
because the prefix query signatures are the same, use a generic function that
can be shared across multiple commands.

Fixes: #13920
Fixes: #17132
Fixes: #23236
Ref: https://hashicorp.atlassian.net/browse/NET-10054
Ref: https://hashicorp.atlassian.net/browse/NET-10055
@tgross tgross closed this as completed in b09c114 Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hcc/jira stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/cli theme/ent/quotas type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants