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

fix(): return error in case GwPodStatus is nil #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)

//create latency metrics which has to be populated when we receive latency from tunnel
// create latency metrics which has to be populated when we receive latency from tunnel
var (
sourceClusterId = os.Getenv("CLUSTER_ID")
remoteClusterId = os.Getenv("REMOTE_CLUSTER_ID")
Expand All @@ -50,7 +50,7 @@ var (
log *logger.Logger = logger.NewLogger()
)

//common method get gauge metrics alongwith labels
// common method get gauge metrics alongwith labels
func getGaugeMetrics(name string, help string) prometheus.Gauge {
return prometheus.NewGauge(
prometheus.GaugeOpts{
Expand All @@ -61,7 +61,7 @@ func getGaugeMetrics(name string, help string) prometheus.Gauge {
})
}

//method to register metrics to prometheus
// method to register metrics to prometheus
func StartMetricsCollector(metricCollectorPort string) {
metricCollectorPort = ":" + metricCollectorPort
log.Infof("Starting metric collector @ %s", metricCollectorPort)
Expand All @@ -86,7 +86,7 @@ func StartMetricsCollector(metricCollectorPort string) {
log.Info("Started Prometheus server at", metricCollectorPort)
}

//send http request
// send http request
func newHandlerWithHistogram(handler http.Handler, histogram *prometheus.HistogramVec) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
start := time.Now()
Expand Down
9 changes: 8 additions & 1 deletion pkg/sidecar/sidecarpb/gw_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
)

type GwSidecar struct {
Expand Down Expand Up @@ -73,10 +74,16 @@ func (s *GwSidecar) GetSliceGwRemotePodName(ctx context.Context, remoteGwVpnIP *
}
defer conn.Close()
client := NewGwSidecarServiceClient(conn)
res, err := client.GetStatus(context.Background(), &empty.Empty{})
res, err := client.GetStatus(context.Background(), new(emptypb.Empty))
if err != nil {
fmt.Println("err:", err.Error())
status.Errorf(codes.InvalidArgument, "Unable to get the remote pod status")
return &GwPodStatus{
Error: &Error{
Code: "5001",
Message: err.Error(),
},
}, err
}
log.Info("recieved response from remote cluster", res)
return res, nil
Expand Down
Loading