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 skeleton for gRPC Commander Service #408

Merged

Conversation

kate-osborn
Copy link
Contributor

@kate-osborn kate-osborn commented Feb 2, 2023

Fixes #377

Adds a gRPC server and the skeleton for the Commander service.

The Commander service implementation is a version of this example. It's the least amount of code required to get the agent and control plane to communicate without errors. The Commander code is for demo purposes only and will change once I add the config push and registration functionality. The agent requests exercise both the CommandChannel and Upload functions but not the Download function. To exercise the Download function, I would have to add a fair amount of code that would just be removed later. I think the current functionality is enough to demonstrate that the agent and control plane can communicate.

The purpose of this PR is to show the general skeleton of the server and Commander service and get early feedback before adding a bunch of business logic.

Here are some of the logs of the nginx-gateway container showing the agent messages:

{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"Commander CommandChannel"}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"ignoring command","command data type":"*proto.Command_EventReport"}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"ignoring command","command data type":"*proto.Command_EventReport"}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"ignoring command","command data type":"*proto.Command_DataplaneStatus"}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"Received a connection request from an agent","data":"version:\"v2.22.1\" display_name:\"nginx-gateway-d8d6d5477-sl6fh\" updated:<seconds:1675196537 > system_uid:\"badd8659-67fb-3525-a40f-b25a6af4b7cd\" agent_details:<features:\"features_registration\" features:\"features_nginx-config\" features:\"features_nginx-ssl-config\" features:\"features_nginx-counting\" features:\"features_nginx-config-async\" features:\"features_metrics\" features:\"features_metrics-throttle\" features:\"features_dataplane-status\" features:\"features_process-watcher\" features:\"features_file-watcher\" features:\"features_activity-events\" features:\"features_agent-api\" > "}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"Commander Upload requested"}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"Received chunk from upload channel","chunk":REDACTED}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"Received chunk from upload channel","chunk":"<nil>"}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"Commander Upload completed"}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"ignoring command","command data type":"*proto.Command_EventReport"}
{"level":"info","ts":"2023-02-02T22:58:50Z","logger":"commanderService","msg":"ignoring command","command data type":"*proto.Command_EventReport"}
{"level":"info","ts":"2023-02-02T22:59:20Z","logger":"commanderService","msg":"ignoring command","command data type":"*proto.Command_DataplaneStatus"}

and here are some of the logs of the nginx-with-agent container that show the successful connection to the control plane:

time="2023-02-02T22:58:50Z" level=info msg="Commander received meta:<timestamp:<seconds:1675378730 nanos:417763900 > message_id:\"84cc33a2-7505-4ea6-95c7-c7323e8cae0c\" > agent_connect_response:<agent_config:<configs:<meta:<timestamp:<seconds:1675378730 nanos:417748700 > message_id:\"84cc33a2-7505-4ea6-95c7-c7323e8cae0c\" > configs:<system_id:\"badd8659-67fb-3525-a40f-b25a6af4b7cd\" nginx_id:\"b636d4376dea15405589692d3c5d3869ff3a9b26b0e7bb4bb1aa7e658ace1437\" > > > status:<statusCode:CONNECT_OK message:\"Connected\" > > , <nil>"
127.0.0.1 - - [02/Feb/2023:22:58:50 +0000] "HEAD /api HTTP/1.1" 200 0 "-" "Go-http-client/1.1" "-"
time="2023-02-02T22:58:50Z" level=info msg="config command &{agent_config:<configs:<meta:<timestamp:<seconds:1675378730 nanos:417748700 > message_id:\"84cc33a2-7505-4ea6-95c7-c7323e8cae0c\" > configs:<system_id:\"badd8659-67fb-3525-a40f-b25a6af4b7cd\" nginx_id:\"b636d4376dea15405589692d3c5d3869ff3a9b26b0e7bb4bb1aa7e658ace1437\" > > > status:<statusCode:CONNECT_OK message:\"Connected\" > }"
time="2023-02-02T22:58:50Z" level=info msg="Upload: Sending data chunk data 0 (messageId=29fa97af-11e8-46ee-a1a8-085f95ffe360)"
time="2023-02-02T22:58:50Z" level=info msg="Upload sending done 29fa97af-11e8-46ee-a1a8-085f95ffe360 (chunks=1)"

The nginx-with-agent container is currently running as a third container inside the nginx-gateway Pod, alongside the nginx and nginx-gateway containers. Once #378 and #379 are complete, I'll remove the nginx container.

@kate-osborn kate-osborn requested a review from a team as a code owner February 2, 2023 23:27
@github-actions github-actions bot added dependencies Pull requests that update a dependency file enhancement New feature or request labels Feb 2, 2023
@kate-osborn kate-osborn requested a review from pleshakov February 2, 2023 23:27
@kate-osborn kate-osborn linked an issue Feb 3, 2023 that may be closed by this pull request
deploy/manifests/nginx-gateway.yaml Outdated Show resolved Hide resolved
internal/grpc/service/commander.go Show resolved Hide resolved
internal/grpc/server.go Outdated Show resolved Hide resolved
@kate-osborn kate-osborn requested a review from pleshakov February 6, 2023 17:50
@kate-osborn kate-osborn merged this pull request into feature/cp-dp-separation Feb 6, 2023
@kate-osborn kate-osborn deleted the feature/grpc-commander-skeleton branch February 6, 2023 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gRPC server and skeleton for Commander Service
2 participants