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 client ID config variable #617

Closed
Closed
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.18
require (
github.com/antonfisher/nested-logrus-formatter v1.3.1
github.com/edwarnicke/grpcfd v1.1.2
github.com/google/uuid v1.2.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.7.2-0.20230123083145-4a6c3ec589e1
github.com/networkservicemesh/sdk v0.5.1-0.20230317102643-1c6df670c572
Expand All @@ -29,7 +30,6 @@ require (
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect
github.com/open-policy-agent/opa v0.44.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand Down
5 changes: 4 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Copyright (c) 2021-2022 Doc.ai and/or its affiliates.
// Copyright (c) 2021-2023 Doc.ai and/or its affiliates.
//
// Copyright (c) 2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -35,4 +37,5 @@ type Config struct {
AwarenessGroups awarenessgroups.Decoder `defailt:"" desc:"Awareness groups for mutually aware NSEs" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
OpenTelemetryEndpoint string `default:"otel-collector.observability.svc.cluster.local:4317" desc:"OpenTelemetry Collector Endpoint"`
ClientID string `default:"" desc:"Client ID which is used for creating connection ID"`
}
1 change: 1 addition & 0 deletions internal/imports/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
_ "fmt"
_ "github.com/antonfisher/nested-logrus-formatter"
_ "github.com/edwarnicke/grpcfd"
_ "github.com/google/uuid"
_ "github.com/kelseyhightower/envconfig"
_ "github.com/networkservicemesh/api/pkg/api/networkservice"
_ "github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
Expand Down
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Copyright (c) 2021-2022 Doc.ai and/or its affiliates.
// Copyright (c) 2021-2023 Doc.ai and/or its affiliates.
//
// Copyright (c) 2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -29,6 +31,7 @@ import (

nested "github.com/antonfisher/nested-logrus-formatter"
"github.com/edwarnicke/grpcfd"
"github.com/google/uuid"
"github.com/kelseyhightower/envconfig"
"github.com/sirupsen/logrus"
"github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig"
Expand Down Expand Up @@ -99,6 +102,10 @@ func main() {
logger.Fatalf("error processing rootConf from env: %+v", err)
}
setLogLevel(rootConf.LogLevel)

if rootConf.ClientID == "" {
rootConf.ClientID = uuid.NewString()
}
logger.Infof("rootConf: %+v", rootConf)

// ********************************************************************************
Expand Down Expand Up @@ -195,7 +202,7 @@ func main() {
// Construct a request
request := &networkservice.NetworkServiceRequest{
Connection: &networkservice.Connection{
Id: fmt.Sprintf("%s-%d", rootConf.Name, i),
Id: fmt.Sprintf("%s-%s-%d", rootConf.Name, rootConf.ClientID, i),
NetworkService: u.NetworkService(),
Labels: u.Labels(),
},
Expand Down