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

api: add field filters to /v1/{allocations,nodes} #9055

Merged
merged 3 commits into from
Oct 14, 2020
Merged

Conversation

schmichael
Copy link
Member

@schmichael schmichael commented Oct 9, 2020

Fixes #9017

The ?resources=true query parameter includes resources in the object stub listings. Specifically:

  • For /v1/nodes?resources=true both the NodeResources and ReservedResources field are included.
  • For /v1/allocations?resources=true the AllocatedResources field is included.

The ?task_states=false query parameter removes TaskStates from
/v1/allocations responses. (By default TaskStates are included.)

Fixes #9017

The ?resources=true query parameter includes resources in the object
stub listings. Specifically:

- For `/v1/nodes?resources=true` both the `NodeResources` and
  `ReservedResources` field are included.
- For `/v1/allocations?resources=true` the `AllocatedResources` field is
  included.

The ?task_states=false query parameter removes TaskStates from
/v1/allocations responses. (By default TaskStates are included.)
@schmichael schmichael changed the title api: add ?resources=true to /v1/{allocations,nodes} api: add field filters to /v1/{allocations,nodes} Oct 14, 2020
@schmichael schmichael marked this pull request as ready for review October 14, 2020 17:43
Copy link
Member

@shoenig shoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

}

return false, nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golf: seems like these two could be combined into something like parseBool(req *http.Request, param string)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed. Mind taking another peek? My old approach let a bug sneak in that should be fixed now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug being parseTaskStates would return false by default if the field was absent?
(LGTM)

In the past I've used a [closed] library for extracting url parameters by providing a schema, providing the name, type, and default value into a call to lib.Parse. It helped cleanup a lot of this url parameter boilerplate - might be worth trying to recreate it sometime.

}

return false, nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug being parseTaskStates would return false by default if the field was absent?
(LGTM)

In the past I've used a [closed] library for extracting url parameters by providing a schema, providing the name, type, and default value into a call to lib.Parse. It helped cleanup a lot of this url parameter boilerplate - might be worth trying to recreate it sometime.

@schmichael schmichael merged commit 116b2b8 into master Oct 14, 2020
@schmichael schmichael deleted the f-9017-resources branch October 14, 2020 21:49
fredrikhgrelland pushed a commit to fredrikhgrelland/nomad that referenced this pull request Oct 22, 2020
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API Support for Topology Visualization
2 participants