hashicorp / hashicorp/nomad

Stats, restart and stop allocation API calls only use ID from full alloc object

Open
#7,955 0 comments 1 reaction 0 assignees View on GitHub
theme/allocation API theme/api type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version
master commit `54987b3e5837020dd4a0c451bd7ef535c52a7fd5`

### Issue
The [Stats](https://github.com/hashicorp/nomad/blob/54987b3e5837020dd4a0c451bd7ef535c52a7fd5/api/allocations.go#L281), [Restart](https://github.com/hashicorp/nomad/blob/54987b3e5837020dd4a0c451bd7ef535c52a7fd5/api/allocations.go#L299) and [Stop](https://github.com/hashicorp/nomad/blob/54987b3e5837020dd4a0c451bd7ef535c52a7fd5/api/allocations.go#L309) allocation API function signatures all require a full `Allocation` object to be passed, where only the `Alloc.ID` is used. This puts additional burden on callers to call [read allocation](https://www.nomadproject.io/api/allocations.html#read-allocation) after [list allocations](https://www.nomadproject.io/api/allocations.html#list-allocations) when the list could have all sufficient information.

It could therefore be beneficial if the functions accepted allocID as string, rather than the entire object.

The ACL permissions required for all the discussed endpoints are the same; `namespace:read-job` so I do not believe there are any security concerns in altering the behaviour.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in api/allocations.go at the Stats, Restart, and Stop allocation functions linked in the issue, then inspect their callers and the list/read allocation API flow. Done means those calls can use an allocation ID without requiring a full Allocation object, with affected callers and API behavior updated consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.