-
Notifications
You must be signed in to change notification settings - Fork 2k
Add NodeMaxAllocations to client configuration #25785
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2facd99
Set MaxAllocations in client config
tehut 9c98a2b
set up cli config parsing
tehut 48496f3
integrate maxAllocs into AllocatedResources view
tehut c48d6bd
update docs
tehut ddaf97d
cleanup
tehut 482f038
fixup: review changes
tehut 4e4b0de
Apply suggestions from code review
tehut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
client: add ability to set maximum allocation count by adding node_max_allocs to client configuration | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
client { | ||
enabled = true | ||
node_max_allocs = 5 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"client": { | ||
"enabled": true, | ||
"node_max_allocs": 5 | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -954,16 +954,21 @@ func getAllocatedResources(client *api.Client, runningAllocs []*api.Allocation, | |
mem += *alloc.Resources.MemoryMB | ||
disk += *alloc.Resources.DiskMB | ||
} | ||
allocCount := strconv.Itoa(len(runningAllocs)) | ||
|
||
if node.NodeMaxAllocs != 0 { | ||
allocCount = fmt.Sprintf("%d/%d", len(runningAllocs), node.NodeMaxAllocs) | ||
} | ||
Comment on lines
+957
to
+961
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a nice little detail, leaving out the fraction if the node doesn't have this config 👍 |
||
resources := make([]string, 2) | ||
resources[0] = "CPU|Memory|Disk" | ||
resources[1] = fmt.Sprintf("%d/%d MHz|%s/%s|%s/%s", | ||
resources[0] = "CPU|Memory|Disk|Alloc Count" | ||
resources[1] = fmt.Sprintf("%d/%d MHz|%s/%s|%s/%s|%s", | ||
cpu, | ||
*total.CPU, | ||
humanize.IBytes(uint64(mem*bytesPerMegabyte)), | ||
humanize.IBytes(uint64(*total.MemoryMB*bytesPerMegabyte)), | ||
humanize.IBytes(uint64(disk*bytesPerMegabyte)), | ||
humanize.IBytes(uint64(*total.DiskMB*bytesPerMegabyte))) | ||
humanize.IBytes(uint64(*total.DiskMB*bytesPerMegabyte)), | ||
allocCount) | ||
|
||
return resources | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Context, not a request for change)
Here we do need the conditional that I've recommended we remove elsewhere, because we're merging two config files and the second one we read might have the value unset (so it has the default value of 0).
Note that this does make it impossible to have configuration like this result in a value of 0:
00.hcl
01.hcl (loads second)
You can work around it by having the config be a pointer to an int and treating the nil pointer differently from 0. But that's not how most of our configuration parsing works, so I'd suggest we avoid that complexity and keep what you have here. But again, just for context 😁