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 reflection to grpc service #388

Merged
merged 2 commits into from
Dec 11, 2020
Merged

Add reflection to grpc service #388

merged 2 commits into from
Dec 11, 2020

Conversation

gianarb
Copy link
Contributor

@gianarb gianarb commented Dec 11, 2020

I discovered this useful introspection technique trying to use grpcurl

https://github.com/fullstorydev/grpcurl

I know one of the use cases of the HTTP API is because they are easy to
use and more familiar.

I think we just need to write and share a bit more about how to use the
gRPC server. The gRPC community is pretty big and their tools can help
with that.

More about reflection https://github.com/grpc/grpc-go/blob/master/Documentation/server-reflection-tutorial.md

In practice

With this PR merged I am able to inspect the grpc server using grpcurl:

$ grpcurl -cacert ./../state/certs/ca.pem -key ../state/certs/server-key.pem -cert ../state/certs/server.pem localhost:42113 list

github.com.tinkerbell.tink.protos.events.EventsService
github.com.tinkerbell.tink.protos.hardware.HardwareService
github.com.tinkerbell.tink.protos.template.TemplateService
github.com.tinkerbell.tink.protos.workflow.WorkflowService
grpc.reflection.v1alpha.ServerReflection

And I can list hardware for example:

$ ~/Desktop/grpcurl_1.7.0_osx_x86_64/grpcurl -cacert ./deploy/state/certs/ca.pem -key ./deploy/state/certs/server-
key.pem -cert ./deploy/state/certs/server.pem localhost:42113 github.com.tinkerbell.tink.protos.hardware.HardwareService
.All
{
  "network": {
    "interfaces": [
      {
        "dhcp": {
          "mac": "08:00:27:00:00:01",
          "arch": "x86_64",
          "ip": {
            "address": "192.168.1.5",
            "netmask": "255.255.255.248",
            "gateway": "192.168.1.1"
          }
        },
        "netboot": {
          "allowPxe": true,
          "allowWorkflow": true
        }
      }
    ]
  },
  "id": "ce2e62ed-826f-4485-a39f-a82bb74338e2",
  "metadata": "{\"facility\":{\"facility_code\":\"onprem\"},\"instance\":{},\"state\":\"\"}"
}

Still have to figure out how to push values, grpcurl support a -d field as curl but i didn't have it working yet

Signed-off-by: Gianluca Arbezzano gianarb92@gmail.com

I discovered this useful introspection technique trying to use grpcurl

https://github.com/fullstorydev/grpcurl

I know one of the use case of the HTTP API is because they are easy to
use and more familiar.

I think we just need to write and share a bit more about how to use the
gRPC. The gRPC community is pretty big and there tools that can help
with that.

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
@gianarb gianarb requested a review from kqdeng December 11, 2020 12:52
@codecov
Copy link

codecov bot commented Dec 11, 2020

Codecov Report

Merging #388 (7b35400) into master (eb6ed72) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #388      +/-   ##
==========================================
- Coverage   28.73%   28.71%   -0.03%     
==========================================
  Files          19       19              
  Lines        1385     1386       +1     
==========================================
  Hits          398      398              
- Misses        960      961       +1     
  Partials       27       27              
Impacted Files Coverage Δ
grpc-server/grpc_server.go 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb6ed72...7b35400. Read the comment docs.

@gianarb gianarb added the ready-to-merge Signal to Mergify to merge the PR. label Dec 11, 2020
@mergify mergify bot merged commit 9ed69b7 into tinkerbell:master Dec 11, 2020
@mmlb mmlb removed the ready-to-merge Signal to Mergify to merge the PR. label Jan 25, 2021
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.

3 participants