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

It is documented that 'value' has default "" but it does not work #24983

Open
EugenKon opened this issue Jan 30, 2025 · 2 comments
Open

It is documented that 'value' has default "" but it does not work #24983

EugenKon opened this issue Jan 30, 2025 · 2 comments
Assignees
Labels
stage/waiting-reply theme/docs Documentation issues and enhancements

Comments

@EugenKon
Copy link

EugenKon commented Jan 30, 2025

Nomad version

1.8.2

Operating system and Environment details

Ubuntu 22.04

Issue

[....] Error during plan: Unexpected response code: 500 (1 error occurred:
[....] 	* Task group wi-api-group validation failed: 1 error occurred:
[....] 	* Task prepare-credentials-task validation failed: 1 error occurred:
[....] 	* Affinity 1 validation failed: 1 error occurred:
[....] 	* Operator "=" requires an RTarget)

https://developer.hashicorp.com/nomad/docs/job-specification/affinity#value

Even manual value="" does not help.

Reproduction steps

      affinity {
        attribute = "${node.unique.id}"
        weight    = -50
      }

Expected Result

No error should occur

Actual Result

Error happened

@gulducat gulducat self-assigned this Jan 31, 2025
@gulducat gulducat added theme/docs Documentation issues and enhancements and removed type/bug labels Jan 31, 2025
@gulducat
Copy link
Member

Hey there @EugenKon, thanks for reaching out.

The requirements for value depends on which operator is being used.

The default operator = requires a non-empty value, as indicated in the error message Operator "=" requires an RTarget. Admittedly, it's not obvious that RTarget means value. Perhaps we could improve the documentation here.

A value of "" is technically valid, for example, if operator = "regexp" (although it would effectively match everything, so wouldn't be much of an affinity). If you wanted to accomplish your example, where apparently node.unique.id = "", then I believe this would work:

affinity {
    attribute = "${node.unique.id}"
    operator  = "regexp"
    value     = "^$"
}

However in Nomad there is no such thing as an empty Node ID, so this seems pretty odd.

I don't believe we should change the code so that = would work with "", unless you have a specific attribute that would benefit from that, but perhaps we can improve the documentation. Does my explanation make sense to you? Do you have any suggestions for how we might better communicate this in the documentation?

@EugenKon
Copy link
Author

I agree with you that everything here is about more meaningfull error messages and the documentation.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/waiting-reply theme/docs Documentation issues and enhancements
Projects
Development

No branches or pull requests

2 participants