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

Add support for SignalTask. #64

Merged
merged 3 commits into from
Aug 28, 2020
Merged

Conversation

shishir-a412ed
Copy link
Contributor

Signed-off-by: Shishir Mahajan smahajan@roblox.com

Signed-off-by: Shishir Mahajan <smahajan@roblox.com>
@shishir-a412ed
Copy link
Contributor Author

shishir-a412ed commented Aug 20, 2020

This patch can be tested using the following example job.

job "example" {
  datacenters = ["dc1"]

  group "cache" {
    task "redis" {
      driver = "podman"

      config {
        image = "docker://shm32/signal_handler:1.0"

        port_map {
          db = 6379
        }
      }

      resources {
        cpu    = 500
        memory = 256

        network {
          mbits = 10
          port  "db"  {}
        }
      }
    }
  }
}
$ nomad job run example.nomad
<Second terminal>
$ nomad alloc signal -s SIGHUP 61036c06

<First terminal>
$ nomad alloc logs -f 61036c06
2020-08-18T23:12:30.081746628+00:00 stdout F Hello signal_handler. My PID is 1
2020-08-18T23:14:05.132489761+00:00 stdout F Received SIGHUP
<Second terminal>
$ nomad alloc signal -s SIGUSR1 61036c06

<First Terminal>
$ nomad alloc logs -f 61036c06
2020-08-18T23:12:30.081746628+00:00 stdout F Hello signal_handler. My PID is 1
2020-08-18T23:14:05.132489761+00:00 stdout F Received SIGHUP
2020-08-18T23:15:25.163521867+00:00 stdout F Received SIGUSR1

Copy link
Collaborator

@towe75 towe75 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution. I want to discuss about the SIGINT fallback, otherwise it looks good to me.

driver.go Outdated Show resolved Hide resolved
@shishir-a412ed
Copy link
Contributor Author

@towe75

[vagrant@fedora30 example]$ nomad alloc signal -s SIGHUP 08bef401
<On second terminal>
[vagrant@fedora30 example]$ nomad alloc logs -f -job example
2020-08-24T20:09:41.400344873+00:00 stdout F Hello signal_handler. My PID is 1
2020-08-24T20:10:46.421778893+00:00 stdout F Received SIGHUP


[vagrant@fedora30 example]$ nomad alloc signal -s HUP 08bef401
Error signalling allocation: Unexpected response code: 500 (1 error occurred:
	* Failed to signal task: redis, err: rpc error: code = Unknown desc = Error in looking up signal: HUP

)

@shishir-a412ed
Copy link
Contributor Author

@towe75 I am contemplating on the error message. Which one do you think would be better?

  1. Error in looking up signal: HUP

OR

  1. Invalid signal: HUP

@towe75
Copy link
Collaborator

towe75 commented Aug 27, 2020

@shishir-a412ed I would go for the second one. Less words are usually better ;-)
But i don't mind if you keep first one.

@shishir-a412ed
Copy link
Contributor Author

@towe75 Sounds good! I was leaning towards (2) as well.
Already made the same change in our containerd task driver: Roblox/nomad-driver-containerd#34

Let me update the PR.

@shishir-a412ed
Copy link
Contributor Author

@towe75 Updated the error message. PTAL.

Copy link
Collaborator

@towe75 towe75 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@towe75 towe75 merged commit 56ad1cb into hashicorp:master Aug 28, 2020
@towe75 towe75 mentioned this pull request Aug 31, 2020
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants