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

Fixed test and moved constants into standalone func #3536

Merged
merged 4 commits into from
Nov 13, 2017
Merged

Fixed test and moved constants into standalone func #3536

merged 4 commits into from
Nov 13, 2017

Conversation

angrycub
Copy link
Contributor

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.

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.
@angrycub
Copy link
Contributor Author

@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 {
Copy link
Contributor

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?

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))
Copy link
Contributor

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)

@dadgar
Copy link
Contributor

dadgar commented Nov 13, 2017

Build broken: github.com/hashicorp/nomad/nomad/structs nomad/structs/structs.go:4335:16: undefined: version

@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 Mar 18, 2023
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.

None yet

3 participants