-
Notifications
You must be signed in to change notification settings - Fork 101
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
False drift with nomad variables containing newlines #476
Comments
Actually it's worse than just newlines. The HCL file is also not handling quotes properly. Input file:
settings_file="blah blah\nsome_string="foobar"\nsome_other_string="foo&bar"" Attempting to restart a job such as the above fails with an error that bitwise AND is not supported. It's not possible to restart a job which has been stopped if one of the input variables contained quotes and other symbols, which is a repeat of #23560. |
@optiz0r the bug fix you linked to hashicorp/nomad#23560 landed in Nomad 1.8.2 (ref changelog) but looking at the releases for the provider that API didn't land until v2.3.1. Provider v2.3.0 has the 1.8.0 API. Can you verify you're seeing this with a more recent version of the provider? |
I was running on 2.3.0 of the provider, but having just tested, I am seeing the same behaviour on 2.3.1 and 2.4.0. On reflection I think the quoting escape is actually a problem in the hashicorp/nomad#23560 implementation (improper encoding of user input), rather than a problem with the provider. The drift relating to encoded newlines might fall either in nomad core or this provider. |
Ok, thanks @optiz0r, we'll take a look. (Leaving a note that this is being tracked internally as https://hashicorp.atlassian.net/browse/NET-11421) |
Hi @optiz0r I have been unsuccessfully trying to reproduce this bug with the following configuration: Terraform file:
Nomad job:
I have run |
Hi @Juanadelacuesta , Principle difference is we're seeding the hcl2 variables via the resource "nomad_job" "foo" {
jobspec = file("${path.module}/foo.nomad.hcl")
hcl2 {
vars = {
settings_file = file("${path.module}/settings_file.conf")
}
}
} Under Nomad 1.8.3, looking at the Definition tab in the UI, using my example inputs from previous comment, this shows within
The quotes in the output of the I see the same with both the previous and current version of terraform-provider-nomad. |
Hello @optiz0r thank you for the pointer, I will revisit it and hopefully we will solve it this time around. |
@optiz0r I see the error now, lets start working on fixing it! |
Hi there,
Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.
Terraform Version
Only tested on 1.5.1 but very likely to be the same on newer versions, due to relevant logic being in nomad core and this provider only.
Nomad Version
Provider Configuration
Environment Variables
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Configuration Files
Debug Output
Omitted, includes sensitive data
Expected Behavior
If the example variable has not changed, no drift should be detected and no change to be made.
Actual Behavior
Since Nomad 1.8.2, Nomad re-encodes the newlines in variables received in JobSubmission so that the internal variables file is well formed, and the job once stopped through the UI can be started again.
This provider retrieves the modified variable definitions from the Nomad API, and then compares it to the unmodified content of the example variable in the terraform code. Since they no longer match, this is reported as a drift, and the nomad_job resource is refreshed.
This doesn't appear actually cause nomad to interrupt the running job, but does cause false reporting of changes.
Steps to Reproduce
terraform apply
terraform apply
Important Factoids
It's unclear if this is a fault in nomad core itself (i.e. the values returned by the read API should be unmodified to match what terraform would have already submitted), or if a fault in the provider (i.e. it should be pre-encoding the newlines before submission, or handling the diff ignoring changes in newline encoding).
References
The text was updated successfully, but these errors were encountered: