openconfig / gnmi-gateway

A modular, distributed, and highly available service for modern network telemetry via OpenConfig and gNMI
Apache License 2.0
138 stars 32 forks source link

Gateway exited with an error: could not open simple config file #29

Closed agardnerIT closed 3 years ago

agardnerIT commented 3 years ago

I'm on Windows. I have a simple custom server built as follows running on localhost:50051 and I'm trying to follow the instructions in this blog post. I'd like to create an Exporter but getting the error:

{"level":"error","time":"...","message":"Gateway exited with an error: could not open simple config file \"\": open : The system cannot find the file specified."}

looper.proto

syntax = "proto3";

option go_package = "example.com/looper/protobuf";

package looper;

// The greeting service definition.
service Looper {
  rpc GetValue(ValueRequest) returns (ValueReply) {}
}

message ValueRequest {}

message ValueReply {
  int32 value = 1;
}

server/main.go

package main

import (
    "context"
    "log"
    "net"
    "google.golang.org/grpc"
    pb "example.com/looper/protobuf"
)

const (
    port = ":50051"
)

type server struct {
    pb.UnimplementedLooperServer
}

func (s *server) GetValue(ctx context.Context, in *pb.ValueRequest) (*pb.ValueReply, error) {
    return &pb.ValueReply{Value: 23}, nil
}

func main() {
    lis, err := net.Listen("tcp", port)
    if err != nil {
        log.Fatalf("failed to listen: %v", err)
    }
    s := grpc.NewServer()
    pb.RegisterLooperServer(s, &server{})
    if err := s.Serve(lis); err != nil {
        log.Fatalf("failed to serve: %v", err)
    }
}

I've created all the files:

/path/to/repo/gnmi-gateway/gnmi-gateway
$ ls -l
CONTRIBUTING.md
LICENSE
Makefile
README.md
docs/
examples/
gateway/
gateway-config-example.json
gnmi-gateway*
go.mod
go.sum
main.go
server.crt
server.key
targets-example.json
targets-example.yaml
targets.yaml

My targets.yaml looks like this:

---
connection:
  localhost:
    addresses:
      - localhost:50051
    #credentials:
      #username: myusername
      #password: mypassword
    request: demo-request
    meta: {}
request:
  demo-request:
    target: "*"
    paths:
      - "/"
    #  - /components
    #  - /interfaces/interface[name=*]/state/counters
    #  - /interfaces/interface[name=*]/ethernet/state/counters
    #  - /interfaces/interface[name=*]/subinterfaces/subinterface[index=*]/state/counters
    #  - /qos/interfaces/interface[interface-id=*]/output/queues/queue[name=*]/state

Running with:

make build && ./gnmi-gateway -EnableGNMIServer     -ServerTLSCert=server.crt     -ServerTLSKey=server.key     -TargetLoaders=simple     -TargetJSONFile=targets.yaml -Exporters=debug
agardnerIT commented 3 years ago

I got a little bit further with the JSON loader:

./gnmi-gateway -EnableGNMIServer     -ServerTLSCert=server.crt     -ServerTLSKey=server.key     -TargetLoaders=json     -TargetJSONFile=targets.json -Exporters=debug
./gnmi-gateway -EnableGNMIServer     -ServerTLSCert=server.crt     -ServerTLSKey=server.key     -TargetLoaders=json     -TargetJSONFile=targets.json -Exporters=debug
{"level":"info","time":"2021-05-14T14:03:35+10:00","message":"Starting GNMI Gateway."}
{"level":"info","time":"2021-05-14T14:03:35+10:00","message":"Clustering is NOT enabled. No locking or cluster coordination will happen."}
{"level":"info","time":"2021-05-14T14:03:35+10:00","message":"Starting connection manager."}
{"level":"info","time":"2021-05-14T14:03:35+10:00","message":"Starting gNMI server on 0.0.0.0:9339."}
{"level":"info","time":"2021-05-14T14:03:35+10:00","message":"Starting Debug exporter."}
{"level":"info","time":"2021-05-14T14:03:35+10:00","message":"Connection manager received a target control message: 1 inserts 0 removes"}
{"level":"info","time":"2021-05-14T14:03:35+10:00","message":"Initializing target localhost ([127.0.0.1:50051]) map[NoTLSVerify:yes]."}
{"level":"info","time":"2021-05-14T14:03:35+10:00","message":"Target localhost: Connecting"}
{"level":"info","time":"2021-05-14T14:03:35+10:00","message":"Target localhost: Subscribing"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"Target localhost: Disconnected"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/sync val:&{false} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/connected val:&{false} } ] }"}
E0514 14:03:45.564881   16648 reconnect.go:114] client.Subscribe (target "localhost") failed: client "gnmi" : client "gnmi" : Dialer(127.0.0.1:50051, 10s): context deadline exceeded; reconnecting in 552.330144ms
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/targetLeavesUpdated val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/targetLeavesSuppressed val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/latencyMax val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/targetSize val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/latestTimestamp val:&{-6795364578871345152} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/latencyMin val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/targetLeavesAdded val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/targetLeavesDeleted val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/targetLeaves val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/targetLeavesStale val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:45+10:00","message":"{ timestamp:1620965025564881800 prefix:/localhost update:[ { path:/meta/latencyAvg val:&{0} } ] }"}
{"level":"info","time":"2021-05-14T14:03:56+10:00","message":"Target localhost: Disconnected"}
E0514 14:03:56.155311   16648 reconnect.go:114] client.Subscribe (target "localhost") failed: client "gnmi" : client "gnmi" : Dialer(127.0.0.1:50051, 10s): context deadline exceeded; reconnecting in 1.080381816s
{"level":"info","time":"2021-05-14T14:04:05+10:00","message":"Connection manager received a target control message: 1 inserts 0 removes"}
{"level":"info","time":"2021-05-14T14:04:07+10:00","message":"Target localhost: Disconnected"}
E0514 14:04:07.250449   16648 reconnect.go:114] client.Subscribe (target "localhost") failed: client "gnmi" : client "gnmi" : Dialer(127.0.0.1:50051, 10s): context deadline exceeded; reconnecting in 1.31013006s
{"level":"info","time":"2021-05-14T14:04:18+10:00","message":"Target localhost: Disconnected"}
E0514 14:04:18.584978   16648 reconnect.go:114] client.Subscribe (target "localhost") failed: client "gnmi" : client "gnmi" : Dialer(127.0.0.1:50051, 10s): context deadline exceeded; reconnecting in 1.582392691s
{"level":"info","time":"2021-05-14T14:04:30+10:00","message":"Target localhost: Disconnected"}
E0514 14:04:30.202416   16648 reconnect.go:114] client.Subscribe (target "localhost") failed: client "gnmi" : client "gnmi" : Dialer(127.0.0.1:50051, 10s): context deadline exceeded; reconnecting in 2.340488664s
{"level":"info","time":"2021-05-14T14:04:35+10:00","message":"Connection manager received a target control message: 1 inserts 0 removes"}

targets.json

{
  "request": {
    "default": {
      "subscribe": {
        "prefix": {
        },
        "subscription": [{
            "path": {
              "elem": [{
                  "name": "GetValue"
                }]
            }
          }]
      }
    }
  },
  "target": {
    "localhost": {
      "addresses": [ "127.0.0.1:50051" ],
      "request": "default",
      "meta": {
        "NoTLSVerify": "yes"
      }
    }
  }
}
agardnerIT commented 3 years ago

Thinking about this further, all I need is a simple demo system so that I can create my exporter.

What's the easiest way to set this up?

Fake device > gnmi gateway

then I create:

Fake device > gnmi gateway > exporter > my service
0xmc commented 3 years ago

Hi Adam,

Your proposal of

device > gnmi-gateway > exporter > my service

is sound. We generally use real devices (either router hardware or containerized routers) for development. If you need help getting it running, I suggest creating the inaugural discussion :)

colinmcintosh commented 3 years ago

Looks like there is a good discussion taking place on #30 for dummy gNMI targets -- I'm going to close this issue.