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 #545

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 @@ -6,6 +6,7 @@ require (
github.com/antonfisher/nested-logrus-formatter v1.3.1
github.com/edwarnicke/genericsync v0.0.0-20220910010113-61a344f9bc29
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 Down Expand Up @@ -35,7 +36,6 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.8 // 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/miekg/dns v1.1.50 // indirect
github.com/open-policy-agent/opa v0.44.0 // indirect
Expand Down
8 changes: 6 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2020-2022 Doc.ai and/or its affiliates.
// Copyright (c) 2021-2022 Nordix and/or its affiliates.
// Copyright (c) 2020-2023 Doc.ai and/or its affiliates.
// Copyright (c) 2021-2023 Nordix and/or its affiliates.
//
// Copyright (c) 2022-2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -49,6 +51,8 @@ type Config struct {
LivenessCheckEnabled bool `default:"true" desc:"Dataplane liveness check enabled/disabled"`
LivenessCheckInterval time.Duration `default:"200ms" desc:"Dataplane liveness check interval"`
LivenessCheckTimeout time.Duration `default:"1s" desc:"Dataplane liveness check timeout"`

ClientID string `default:"" desc:"Client ID which is used for creating connection ID"`
}

// IsValid - check if configuration is valid
Expand Down
1 change: 1 addition & 0 deletions internal/imports/imports_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2020-2022 Doc.ai and/or its affiliates.
// Copyright (c) 2021-2022 Nordix and/or its affiliates.
// Copyright (c) 2020-2023 Doc.ai and/or its affiliates.
// Copyright (c) 2021-2023 Nordix and/or its affiliates.
//
// Copyright (c) 2022-2023 Cisco and/or its affiliates.
//
Expand Down Expand Up @@ -33,6 +33,7 @@ import (
nested "github.com/antonfisher/nested-logrus-formatter"
"github.com/edwarnicke/genericsync"
"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 @@ -105,13 +106,16 @@ func main() {
if err := envconfig.Process("nsm", c); err != nil {
logger.Fatalf("error processing rootConf from env: %+v", err)
}

level, err := logrus.ParseLevel(c.LogLevel)
if err != nil {
logrus.Fatalf("invalid log level %s", c.LogLevel)
}
logrus.SetLevel(level)

if c.ClientID == "" {
c.ClientID = uuid.NewString()
}

logger.Infof("rootConf: %+v", c)

// ********************************************************************************
Expand Down Expand Up @@ -244,7 +248,7 @@ func main() {
// Update network services configs
u := (*nsurl.NSURL)(&c.NetworkServices[i])

id := fmt.Sprintf("%s-%d", c.Name, i)
id := fmt.Sprintf("%s-%s-%d", c.Name, c.ClientID, i)
var monitoredConnections map[string]*networkservice.Connection
monitorCtx, cancelMonitor := context.WithTimeout(signalCtx, c.RequestTimeout)
defer cancelMonitor()
Expand Down