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

grpc: use default resolver scheme for grpc dialing #7617

Merged
merged 1 commit into from
May 20, 2020

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Apr 8, 2020

Currently checks of type gRPC will emit log messages such as,

2020/02/12 13:48:22 [INFO] parsed scheme: ""
2020/02/12 13:48:22 [INFO] scheme "" not registered, fallback to default scheme

Without adding full support for using custom gRPC schemes (perhaps that's
right long-term option) we can just supply the default scheme as provided
by the grpc library.

Fixes #7274
and transitively hashicorp/nomad#7415

Did some manual testing.

Without Proxy

Toy gRPC HC service
$ docker run --net=host --rm shoenig/grpc-healthcheck-example:v0.0.0
Consul config w/ check on service
# consul.hcl

log_level = "INFO"
data_dir = "/tmp/consul"
server = true
bootstrap_expect = 1
bind_addr = "127.0.0.1"
addresses {
  http = "0.0.0.0"
}

services = {
  name = "grpc-healthcheck-example"
  port = 3333

  check = {
    "id"           = "example-check"
    "name"         = "gRPC Check Example"
    "grpc"         = "127.0.0.1:3333/example"
    "grpc_use_tls" = false
    "interval"     = "7s"
  }
}
Run Consul
$  consul agent -config-file=consul.hcl
Verify check passes
$ curl -s localhost:8500/v1/agent/checks | jq .
{
  "example-check": {
    "Node": "x1",
    "CheckID": "example-check",
    "Name": "gRPC Check Example",
    "Status": "passing",
    "Notes": "",
    "Output": "gRPC check 127.0.0.1:3333/example: success",
    "ServiceID": "grpc-healthcheck-example",
    "ServiceName": "grpc-healthcheck-example",
    "ServiceTags": [],
    "Type": "grpc",
    "Definition": {},
    "CreateIndex": 0,
    "ModifyIndex": 0
  }
}

With Proxy (using Nomad)

Run Consul
$ consul agent -dev
Run Nomad
$ sudo nomad agent -dev-connect
Nomad job file w/ Connect enabled, exposed gRPC HC service
# example.nomad

job "grpc-check-example" {
  datacenters = ["dc1"]

  group "group1" {
    network {
      mode = "bridge"

      port "healthcheck" {
	to = -1
      }
    }



    service {
      name = "grpc-healthcheck-example"
      port = "healthcheck"

      connect {
	sidecar_service {}
      }

      check {
	name = "example-check"
	type = "grpc"
	port = "healthcheck"
	interval = "5s"
	timeout = "3s"
	expose = true
      }
    }

    task "example" {
      driver = "docker"

      env {
	GRPCHC_PORT = "${NOMAD_PORT_healthcheck}"
      }

      config {
	image = "shoenig/grpc-healthcheck-example:v0.0.0"
      }
    }
  }
}
Wait for job to become healthy
$ nomad job status grpc-check-example
ID            = grpc-check-example
Name          = grpc-check-example
Submit Date   = 2020-04-08T13:46:44-06:00
Type          = service
Priority      = 50
Datacenters   = dc1
Namespace     = default
Status        = running
Periodic      = false
Parameterized = false

Summary
Task Group  Queued  Starting  Running  Failed  Complete  Lost
group1      0       0         1        0       0         0

Latest Deployment
ID          = cf59d40b
Status      = successful
Description = Deployment completed successfully

Deployed
Task Group  Desired  Placed  Healthy  Unhealthy  Progress Deadline
group1      1        1       1        0          2020-04-08T13:56:59-06:00

Allocations
ID        Node ID   Task Group  Version  Desired  Status   Created  Modified
51972858  d3aa3a10  group1      0        run      running  31s ago  16s ago
Verify check is passing
$ curl -s localhost:8500/v1/agent/checks | jq '.[] | select(.Name=="example-check")'
{
  "Node": "x1",
  "CheckID": "_nomad-check-a20c0d5a5e2abd9d953c1731fbdcb5b185b7ef79",
  "Name": "example-check",
  "Status": "passing",
  "Notes": "",
  "Output": "gRPC check 192.168.1.252:30697/: success",
  "ServiceID": "_nomad-task-51972858-e1bd-0329-437a-81a942e34cd5-group-group1-grpc-healthcheck-example-healthcheck",
  "ServiceName": "grpc-healthcheck-example",
  "ServiceTags": [],
  "Type": "grpc",
  "Definition": {},
  "CreateIndex": 0,
  "ModifyIndex": 0
}

Currently checks of type gRPC will emit log messages such as,

    2020/02/12 13:48:22 [INFO] parsed scheme: ""
    2020/02/12 13:48:22 [INFO] scheme "" not registered, fallback to default scheme

Without adding full support for using custom gRPC schemes (maybe that's
right long-term path) we can just supply the default scheme as provided
by the grpc library.

Fixes #7274
and hashicorp/nomad#7415
Copy link
Member

@hanshasselberg hanshasselberg left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for submitting a PR!

@hanshasselberg hanshasselberg merged commit 44ee818 into master May 20, 2020
@hanshasselberg hanshasselberg deleted the b-set-grpc-check-scheme branch May 20, 2020 20:26
hashicorp-ci pushed a commit that referenced this pull request May 21, 2020
Currently checks of type gRPC will emit log messages such as,

    2020/02/12 13:48:22 [INFO] parsed scheme: ""
    2020/02/12 13:48:22 [INFO] scheme "" not registered, fallback to default scheme

Without adding full support for using custom gRPC schemes (maybe that's
right long-term path) we can just supply the default scheme as provided
by the grpc library.

Fixes #7274
and hashicorp/nomad#7415
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.

gRPC Healthcheck unable to parse scheme
3 participants