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

Support new gnmi config interface in telemetry container. #7

Merged
merged 15 commits into from
Nov 28, 2022
Merged

Support new gnmi config interface in telemetry container. #7

merged 15 commits into from
Nov 28, 2022

Conversation

ganglyu
Copy link
Contributor

@ganglyu ganglyu commented Aug 10, 2022

Signed-off-by: Gang Lv ganglv@microsoft.com

Why I did it

Update telemetry container to support new gnmi config interface.

How I did it

Use new target to support mixed schema, and we can enable/disable telemetry and gnmi config interface.

How to verify it

Build target and run unit test.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 24, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@@ -40,7 +40,7 @@ stages:
DIFF_COVER_WORKING_DIRECTORY: $(System.DefaultWorkingDirectory)/sonic-gnmi

container:
image: sonicdev-microsoft.azurecr.io:443/sonic-slave-buster:latest
image: sonicdev-microsoft.azurecr.io:443/sonic-slave-bullseye:latest
Copy link
Collaborator

@qiluo-msft qiluo-msft Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bullseye

image: sonicdev-microsoft.azurecr.io:443/sonic-slave-bullseye:latest


Let's separate irrelevant changes such as "bullseye" to another PR and focus "native mode gnmi service" in this PR.

If you mix, it's challenge to revert anything in case. #Closed

go.mod Outdated
@@ -5,10 +5,11 @@ go 1.12
require (
github.com/Azure/sonic-mgmt-common v0.0.0-00010101000000-000000000000
github.com/Workiva/go-datastructures v1.0.50
github.com/agiledragon/gomonkey/v2 v2.8.0
github.com/agiledragon/gomonkey/v2 v2.9.0
Copy link
Collaborator

@qiluo-msft qiluo-msft Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gomonkey

github.com/agiledragon/gomonkey/v2 v2.9.0


Upgrade existing dep version in another PR.
You can keep newly introduced dep in this PR. #Closed

Makefile Outdated
@@ -18,7 +18,15 @@ TEST_FILES=$(wildcard *_test.go)
TELEMETRY_TEST_DIR = build/tests/gnmi_server
TELEMETRY_TEST_BIN = $(TELEMETRY_TEST_DIR)/server.test
ifeq ($(ENABLE_TRANSLIB_WRITE),y)
BLD_FLAGS := -tags gnmi_translib_write
ifeq ($(ENABLE_NATIVE_WRITE),y)
Copy link
Collaborator

@qiluo-msft qiluo-msft Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENABLE_NATIVE_WRITE

ifeq ($(ENABLE_NATIVE_WRITE),y)


You may check each ENABLE_XXX flag, and append to string, and finally set BLD_FLAGS by the string. Current nested if-else is not scalable for future extra flags. #Closed

Makefile Outdated
@@ -41,38 +49,48 @@ $(GO_DEPS): go.mod $(PATCHES)
patch -d vendor -p0 < patches/gnmi_cli.all.patch
patch -d vendor -p0 < patches/gnmi_set.patch
patch -d vendor -p0 < patches/gnmi_get.patch
patch -d vendor -p0 < patches/path.patch
Copy link
Collaborator

@qiluo-msft qiluo-msft Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.patch

patch -d vendor -p0 < patches/path.patch


The patch filename is too general. #Closed

Makefile Outdated
endif

# TODO: Create a new repo for this lib, sonic-restapi and sonic-gnmi can share this lib
Copy link
Collaborator

@qiluo-msft qiluo-msft Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

# TODO: Create a new repo for this lib, sonic-restapi and sonic-gnmi can share this lib


Instead of todo, let's do it now? #Closed

"google.golang.org/grpc/status"
"google.golang.org/grpc/codes"
"os/user"
"encoding/json"
jwt "github.com/dgrijalva/jwt-go"
)

func RebootSystem(fileName string) error {
Copy link
Collaborator

@qiluo-msft qiluo-msft Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RebootSystem

Is it "reboot" or "config reload"? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use reboot to implement "config reload", and please refer to: https://github.com/openconfig/gnoi/blob/main/system/system.proto#L131

func (srv *Server) Reboot(ctx context.Context, req *gnoi_system_pb.RebootRequest) (*gnoi_system_pb.RebootResponse, error) {
fileName := common_utils.GNMI_WORK_PATH + "/config_db.json.tmp"
//return nil, status.Errorf(codes.Unimplemented, "hit test point")
Copy link
Collaborator

@qiluo-msft qiluo-msft Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//return nil, status.Errorf(codes.Unimplemented, "hit test point")

//return nil, status.Errorf(codes.Unimplemented, "hit test point")


Remove test code, not just commented. #Closed

@@ -274,26 +284,32 @@ func (s *Server) checkEncodingAndModel(encoding gnmipb.Encoding, models []*gnmip

// Get implements the Get RPC in gNMI spec.
func (s *Server) Get(ctx context.Context, req *gnmipb.GetRequest) (*gnmipb.GetResponse, error) {
common_utils.IncCounter("GNMI get")
Copy link
Collaborator

@qiluo-msft qiluo-msft Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IncCounter

common_utils.IncCounter("GNMI get")


The counter and dump are quite useful new features, not directly tie to the native mode gnmi service feature. Could you separate them into separate PR(s)? #Closed

@qiluo-msft
Copy link
Collaborator

qiluo-msft commented Sep 26, 2022

func (srv *Server) CancelReboot(ctx context.Context, req *gnoi_system_pb.CancelRebootRequest) (*gnoi_system_pb.CancelRebootResponse, error) {

Is it a placeholder function (with TODO comment)? or how did you cancel a reboot?


In reply to: 1258650635


In reply to: 1258650635


In reply to: 1258650635


In reply to: 1258650635


In reply to: 1258650635


Refers to: gnmi_server/gnoi.go:66 in 71e5e09. [](commit_id = 71e5e09, deletion_comment = False)

@@ -0,0 +1,37 @@
--- ./github.com/jipanyang/gnxi/utils/xpath/path.go
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

---

Could you add some file level comment to explain why a patch is needed, and how do you achieve it?
ref: https://stackoverflow.com/a/20911434/2514803

@@ -275,7 +275,7 @@ func get_events(evtc *EventClient) {
for {

rc, evt := C_recv_evt(evtc.subs_handle)
log.V(7).Infof("C.event_receive_wrap rc=%d evt:%s", rc, (*C.char)(str_ptr))
log.V(7).Infof("C.event_receive_wrap rc=%d evt:%v", rc, (*C.char)(str_ptr))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v

For valid bug fix, separate into a separate PR.

@@ -204,7 +204,7 @@ func (c *TranslClient) StreamRun(q *queue.PriorityQueue, stop chan struct{}, w *
return
}
default:
log.V(1).Infof("Bad Subscription Mode for client %s ", c)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s

The same

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 14, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

typedef void *db_connector_t;

// DBConnector::DBConnector(int db, std::string hostname, int port, unsigned int timeout)
db_connector_t db_connector_new(int db, const char *hostname, int port, unsigned int timeout);
Copy link
Collaborator

@qiluo-msft qiluo-msft Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgtm-com
Copy link

lgtm-com bot commented Nov 24, 2022

This pull request introduces 1 alert when merging 81700b4 into 6b0253a - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

@ganglyu
Copy link
Contributor Author

ganglyu commented Nov 25, 2022

/azp run sonic-net.sonic-gnmi

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

}

func IsNativeOrigin(origin string) bool {
return origin == "sonic-db" || origin == "sonic-yang"
Copy link
Collaborator

@qiluo-msft qiluo-msft Nov 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"sonic-db"

Origin sonic-db is named as native since the gnmi client directly manipulate raw ConfigDB. sonic-yang is not considered native because there will be a translation between sonic-yang payload to ConfigDB schema. #Closed

return origin, nil
}
for i, path := range paths {
if origin == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

origin

Why treat empty input origin differently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this.

@@ -274,6 +277,26 @@ func (s *Server) checkEncodingAndModel(encoding gnmipb.Encoding, models []*gnmip
return nil
}

func ParseOrigin(origin string, paths []*gnmipb.Path) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

origin

why a parse function has an extra input parameter origin? Could you add a function level comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this.

@ganglyu
Copy link
Contributor Author

ganglyu commented Nov 28, 2022

/azp run sonic-net.sonic-gnmi

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ganglyu
Copy link
Contributor Author

ganglyu commented Nov 28, 2022

/azp run sonic-net.sonic-gnmi

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ganglyu ganglyu merged commit 54806a8 into sonic-net:master Nov 28, 2022
ganglyu added a commit to sonic-net/sonic-buildimage that referenced this pull request Nov 29, 2022
Why I did it
Submodule update for sonic-gnmi
Incorporates:

8226e46 Upgrade pipeline to use bullseye. (sonic-net/sonic-gnmi#58)
ae72767 Add gnmi_dump tool for debug and unit test (sonic-net/sonic-gnmi#60)
6b0253a Add conditional check for split (sonic-net/sonic-gnmi#55)
99bfa8f Remove LOGLEVEL DB since is no longer used (sonic-net/sonic-gnmi#56)
54806a8 Support new gnmi config interface in telemetry container. (sonic-net/sonic-gnmi#7)

How I did it
Move submodule

How to verify it
Check build pipeline.
StormLiangMS pushed a commit to StormLiangMS/sonic-buildimage that referenced this pull request Dec 8, 2022
Why I did it
Submodule update for sonic-gnmi
Incorporates:

8226e46 Upgrade pipeline to use bullseye. (sonic-net/sonic-gnmi#58)
ae72767 Add gnmi_dump tool for debug and unit test (sonic-net/sonic-gnmi#60)
6b0253a Add conditional check for split (sonic-net/sonic-gnmi#55)
99bfa8f Remove LOGLEVEL DB since is no longer used (sonic-net/sonic-gnmi#56)
54806a8 Support new gnmi config interface in telemetry container. (sonic-net/sonic-gnmi#7)

How I did it
Move submodule

How to verify it
Check build pipeline.
StormLiangMS pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Dec 10, 2022
Why I did it
Submodule update for sonic-gnmi
Incorporates:

8226e46 Upgrade pipeline to use bullseye. (sonic-net/sonic-gnmi#58)
ae72767 Add gnmi_dump tool for debug and unit test (sonic-net/sonic-gnmi#60)
6b0253a Add conditional check for split (sonic-net/sonic-gnmi#55)
99bfa8f Remove LOGLEVEL DB since is no longer used (sonic-net/sonic-gnmi#56)
54806a8 Support new gnmi config interface in telemetry container. (sonic-net/sonic-gnmi#7)

How I did it
Move submodule

How to verify it
Check build pipeline.
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.

None yet

2 participants