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

Allow the ports for gRPC and REST to be configured for the allocator service #2272

Merged
merged 4 commits into from
Sep 24, 2021

Conversation

roberthbailey
Copy link
Member

@roberthbailey roberthbailey commented Sep 21, 2021

What type of PR is this?

Uncomment only one /kind <> line, press enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind hotfix

What this PR does / Why we need it: Makes it possible to disable the REST endpoint in the allocator service or to run gRPC and REST on different ports. This allows using the non-experimental gRPC server code.

Which issue(s) this PR fixes:

Closes #2263

Special notes for your reviewer:

This is currently a work-in-progress. I still need to update the documentation before this can be merged.

I've added documentation.

This is a breaking change because I'm renaming some helm parameters (which can be seen in the updates to the Makefile and the allocator service documentation). In the 1.18.0 release we should notify folks that if they rely on these helm parameters that they now have different names.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 9b245954-6b49-4557-bc11-16f9c4f60ef5

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2272/head:pr_2272 && git checkout pr_2272
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.18.0-f04224c

{{- end }}
spec:
selector:
multicluster.agones.dev/role: allocator
ports:
- port: {{ .Values.agones.allocator.http.port }}
{{- if .Values.agones.allocator.service.http.enabled }}
Copy link
Member Author

Choose a reason for hiding this comment

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

The logic here is similar to what is in cmd/allocator/main.go but is a bit harder to read due to the templating language.

There are 4 cases to cover:

  1. If http & grpc are both enabled and use the same port, only configure the http port
  2. If http & grpc are both enabled and use different ports, configure the http port and the grpc port
  3. If only http is enabled, only configure the http port
  4. If only grpc is enabled, only configure the grpc port

The logic to cover the 4 cases has three branches:

  1. If the http port is enabled, then use it (covers cases 1-3 & skipping covers 4)
    1. If the grpc port is also enabled and it is different from the http port, use it as well (case 2)
  2. If the http port is disabled but the grpc port is enabled, use it (case 4)

Locally I tested this by modifying my values.yaml file and running make gen-install to see the resulting yaml and verify that the correct number or ports were defined (1 or 2) with the correct values.

@roberthbailey roberthbailey added kind/breaking Breaking change kind/feature New features for Agones area/operations Installation, updating, metrics etc labels Sep 22, 2021
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 3a5fe140-13ad-4480-abe6-fc1fcf3b5b56

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: f2a04482-3eaf-4f29-b899-09ad9d4e329e

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2272/head:pr_2272 && git checkout pr_2272
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.18.0-691306d

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 6992a215-2a4a-4552-8aa4-f7ebd8b4e6f2

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2272/head:pr_2272 && git checkout pr_2272
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.18.0-56f6f57

Copy link
Collaborator

@rcreasey rcreasey left a comment

Choose a reason for hiding this comment

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

Leaving feedback, but not requiring them to be changed for the PR.

@@ -161,8 +184,19 @@ spec:
- name: FEATURE_GATES
value: {{ .Values.agones.featureGates | quote }}
ports:
{{- if .Values.agones.allocator.service.http.enabled }}
- name: https
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that name should also be a changeable attribute if we're already changing the port values. There are some use cases where changing the port to 80 and leaving the name as https would be disadvantageous. If not, then perhaps we should statically name this to just be http to be consistent with the nomenclature of the helm values label.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

containerPort: {{ .Values.agones.allocator.service.http.targetPort }}
{{- if .Values.agones.allocator.service.grpc.enabled }}
{{- if ne .Values.agones.allocator.service.grpc.port .Values.agones.allocator.service.http.port }}
- name: grpc
Copy link
Collaborator

Choose a reason for hiding this comment

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

Related to the above, it might be worth having this be defined via the helm value as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: dba18489-a5d6-4acc-8d6c-2fb08b16a49e

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: c4da79f8-b978-4d1f-90f0-45792e44c72b

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2272/head:pr_2272 && git checkout pr_2272
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.18.0-ce8ffd1

Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Couple of nits on logging, but otherwise LGTM

@@ -92,6 +91,10 @@ func main() {
runtime.SetLevel(logrus.InfoLevel)
}

if !validPort(conf.GRPCPort) && !validPort(conf.HTTPPort) {
logger.Fatalf("Must specify a valid gRPC port or an HTTP port for the allocator service. grpc port = %d, http port = %d", conf.GRPCPort, conf.HTTPPort)
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit:

Suggested change
logger.Fatalf("Must specify a valid gRPC port or an HTTP port for the allocator service. grpc port = %d, http port = %d", conf.GRPCPort, conf.HTTPPort)
logger.WithField("grpc-port", conf.GRPCPort).WithField("http-port", conf.HTTPPort).Fatal("Must specify a valid gRPC port or an HTTP port for the allocator service")

Since we have structured logging.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

}

func runREST(h *serviceHandler, httpPort int) {
logger.Infof("Running the rest handler on port %d", httpPort)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logger.Infof("Running the rest handler on port %d", httpPort)
logger.WithField("port", httpPort).Info("Running the rest handler")

Nit to prefer a structured log 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

err = http.ListenAndServe(":8080", http.DefaultServeMux)
logger.WithError(err).Fatal("allocation service crashed")
func runGRPC(h *serviceHandler, grpcPort int) {
logger.Infof("Running the grpc handler on port %d", grpcPort)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logger.Infof("Running the grpc handler on port %d", grpcPort)
logger.WithField("port", grpcPort).Info("Running the grpc handler on port")

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: b8475669-4045-4091-ac52-5c03d7749439

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2272/head:pr_2272 && git checkout pr_2272
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.18.0-e722921

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: c94a3e86-132d-44fd-8897-03092274cf82

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Flake:

--- FAIL: TestFleetRollingUpdate (0.00s)
    --- FAIL: TestFleetRollingUpdate/Use_fleet_Patch_false_10% (118.20s)
        fleet_test.go:331: 
            	Error Trace:	fleet_test.go:331
            	Error:      	Received unexpected error:
            	            	new replicas should be less than target + maxSurge + maxUnavailable + shift. Replicas: 11, Expected: 10
            	Test:       	TestFleetRollingUpdate/Use_fleet_Patch_false_10%

Retrying!

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markmandel, rcreasey, roberthbailey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [markmandel,roberthbailey]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 720b6260-928d-4f00-9bd7-0647d9e35da1

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2272/head:pr_2272 && git checkout pr_2272
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.18.0-8a23675

@markmandel markmandel added this to the 1.18.0 milestone Sep 24, 2021
@markmandel markmandel merged commit fbe5380 into googleforgames:main Sep 24, 2021
@roberthbailey roberthbailey deleted the allocator-service branch March 28, 2022 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/operations Installation, updating, metrics etc cla: yes kind/breaking Breaking change kind/feature New features for Agones lgtm size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow the allocator service to use the go http/2 server
5 participants