-
-
Notifications
You must be signed in to change notification settings - Fork 958
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
Forward SIGTERM signal to terraform #72
Conversation
Merged appropriate changes in terraform, see hashicorp/terraform@e9c35ea |
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.
Thanks for the PR! I left a bunch of comments.
Could you run the tests and paste the output here?
select { | ||
case s := <-c: | ||
if s == nil { | ||
return |
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.
Is this a normal case or indicate of an odd problem? Perhaps it should be logged?
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 is the case when the channel is closed
} | ||
} | ||
}() | ||
|
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.
Could you extract this code into a separate function with a clear name? Perhaps forwardSignals
?
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.
done in new commit
@@ -22,5 +23,26 @@ func RunShellCommand(terragruntOptions *options.TerragruntOptions, command strin | |||
|
|||
cmd.Dir = terragruntOptions.WorkingDir | |||
|
|||
c := make(chan os.Signal, 1) |
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.
Please use a more descriptive variable name than c
. Perhaps signalChannel
.
terragruntOptions.Logger.Printf("Forward signal %s to terraform.", s.String()) | ||
err := cmd.Process.Signal(s) | ||
if err != nil { | ||
terragruntOptions.Logger.Println(err) |
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.
Might want a slightly clearer error message, such as terragruntOptions.Logger.Printf("Error forwarding signal: %v", err)
.
@@ -22,5 +23,26 @@ func RunShellCommand(terragruntOptions *options.TerragruntOptions, command strin | |||
|
|||
cmd.Dir = terragruntOptions.WorkingDir | |||
|
|||
c := make(chan os.Signal, 1) | |||
signal.Notify(c, forwardSignals...) |
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.
It's worth mentioning that there is already code listening on some signals in Terragrunt here: https://github.com/gruntwork-io/terragrunt/blob/master/locks/lock.go#L49
Is it OK to listen in more than one place? Should the two be combined?
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.
Yes, the documentation explicitly says it's ok: https://golang.org/pkg/os/signal/#Notify
It is allowed to call Notify multiple times with different channels and the same signals: each channel receives copies of incoming signals independently.
I updated the code with your remarks. The tests are failing, But the parent commit does not pass them either. There are failures related to cli (which I didn't changed) and other changes failing because I can't access a S3 bucket.
|
The S3 bucket thing is expected. The code actually creates it for you. The other three errors are probably a silly bug. Out of curiosity, does one of the parent folders of where you have the terragrunt checked out happen to contain a |
None of the parent folders contains a
|
Hm, AFAIK, tests have been passing consistently in CI and other people's computers recently, so I'm a bit stumped why they would be failing on yours. It seems unlikely to be related to your change, so I'm going to try to merge it in. |
Looks like the tests passed. I just created a new release and the binaries should be there in a few minutes: https://github.com/gruntwork-io/terragrunt/releases/tag/v0.7.3. Thanks again for the PR! |
For #61