-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fixed test and moved constants into standalone func #3536
Fixed test and moved constants into standalone func #3536
Conversation
In #3520, work was done to true up the defaults for Nomad resource stanzas with the documentation. This fixes the tests that I accidentally broke in the process. Some questions were raised about using dynamic elements as part of expects, which is why I opted to copy the MinResources pattern. During this refactor I also noticed that structs.go had a similar issue and an inconsistent minium for CPU.
@chelseakomlo, this is the issue that we paired on, just for convenience to discuss. |
api/resources.go
Outdated
// absolute minimum resources that we will provide to an object. | ||
// This should not be confused with the defaults which are | ||
// provided in DefaultResources() --- THIS LOGIC IS REPLICATED | ||
// IN nomad/structs/structs.go and should be kept in sync. | ||
func MinResources() *Resources { |
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.
This was only used in unit tests and is now replaced by DefaultResources, so why do we need MinResources here again?
nomad/structs/structs.go
Outdated
func (r *Resources) MeetsMinResources() error { | ||
var mErr multierror.Error | ||
if r.CPU < 20 { | ||
minResources := MinResources() | ||
if r.CPU < minResources.CPU { | ||
mErr.Errors = append(mErr.Errors, fmt.Errorf("minimum CPU value is 20; got %d", r.CPU)) |
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.
This hard codes 20 but should use the value from the min resources. Same for all others.
fmt.Errorf("minimum CPU value is %d; got %d", minResources.CPU, r.CPU)
Build broken: |
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. |
In #3520, work was done to true up the defaults for Nomad resource stanzas with the documentation. This fixes the tests that I accidentally broke in the process. Some questions were raised about using dynamic elements as part of expects, which is why I opted to copy the MinResources pattern. During this refactor I also noticed that
structs.go
had a similar issue and an inconsistent minimum for CPU.