Skip to content

Commit

Permalink
Update the default gRPC and HTTP ports for the sdkserver for the 1.2.…
Browse files Browse the repository at this point in the history
…0 release. (#1180)
  • Loading branch information
roberthbailey authored and markmandel committed Nov 15, 2019
1 parent 34c2afc commit 71383df
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 66 deletions.
6 changes: 3 additions & 3 deletions build/includes/sdk.mk
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ ensure-build-sdk-image:
run-sdk-conformance-local: TIMEOUT ?= 30
run-sdk-conformance-local: TESTS ?= ready,allocate,setlabel,setannotation,gameserver,health,shutdown,watch,reserve
run-sdk-conformance-local: ensure-agones-sdk-image
docker run -e "ADDRESS=" -p 59357:59357 -p 59358:59358 \
docker run -e "ADDRESS=" -p 9357:9357 -p 9358:9358 \
-e "TEST=$(TESTS)" -e "TIMEOUT=$(TIMEOUT)" $(sidecar_tag)

# Run SDK conformance test, previously built, for a specific SDK_FOLDER
Expand All @@ -132,8 +132,8 @@ run-sdk-conformance-no-build: TIMEOUT ?= 30
run-sdk-conformance-no-build: RANDOM := $(shell bash -c 'echo $$RANDOM')
run-sdk-conformance-no-build: DELAY ?= $(shell bash -c "echo $$[ ($(RANDOM) % 5 ) + 1 ]")
run-sdk-conformance-no-build: TESTS ?= ready,allocate,setlabel,setannotation,gameserver,health,shutdown,watch,reserve
run-sdk-conformance-no-build: GRPC_PORT ?= 59357
run-sdk-conformance-no-build: HTTP_PORT ?= 59358
run-sdk-conformance-no-build: GRPC_PORT ?= 9357
run-sdk-conformance-no-build: HTTP_PORT ?= 9358
run-sdk-conformance-no-build: ensure-agones-sdk-image
run-sdk-conformance-no-build: ensure-build-sdk-image
DOCKER_RUN_ARGS="--net host -e AGONES_SDK_GRPC_PORT=$(GRPC_PORT) -e AGONES_SDK_HTTP_PORT=$(HTTP_PORT) $(DOCKER_RUN_ARGS)" COMMAND=sdktest $(MAKE) run-sdk-command & \
Expand Down
4 changes: 2 additions & 2 deletions cmd/sdk-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import (
)

const (
defaultGRPCPort = 59357
defaultHTTPPort = 59358
defaultGRPCPort = 9357
defaultHTTPPort = 9358

// specifically env vars
gameServerNameEnv = "GAMESERVER_NAME"
Expand Down
8 changes: 4 additions & 4 deletions examples/gameserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ spec:
# - "Error" The SDK server will only output error messages
logLevel: Info
# grpcPort and httpPort control what ports the sdkserver listens on.
# The defaults in Agones 1.0 used high port numbers (in the ephemeral port
# range on most systems) which can conflict with other TCP connections
# within the pod. It is recommended to set these to a non-ephemeral port
# and the default port will be changed in a future release of Agones.
# Starting with Agones 1.2 the default grpcPort is 9357 and the default
# httpPort is 9358. In earlier releases, the defaults were 59357 and 59358
# respectively but as these were in the ephemeral port range they could
# conflict with other TCP connections.
grpcPort: 9357
httpPort: 9358
# Pod template configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,14 @@ properties:
grpcPort:
title: The port on which the SDK server binds the gRPC server to accept incoming connections
description: |
The default gRPC port in Agones 1.0 was 59357 which is in the ephemeral port range and can
encounter conflicts in rare cases. The default will be changed to 9357 in a future release
of Agones.
Starting with Agones 1.2 the default gRPC port is 9357. In earlier releases, the default was 59357.
type: integer
minimum: 1
maximum: 65535
httpPort:
title: The port on which the SDK server binds the HTTP gRPC gateway server to accept incoming connections
description: |
The default HTTP port in Agones 1.0 was 59358 which is in the ephemeral port range and can
encounter conflicts in rare cases. The default will be changed to 9358 in a future release
of Agones.
Starting with Agones 1.2 the default HTTP port is 9358. In earlier releases, the default was 59358.
type: integer
minimum: 1
maximum: 65535
Expand Down
24 changes: 6 additions & 18 deletions install/yaml/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,14 @@ spec:
grpcPort:
title: The port on which the SDK server binds the gRPC server to accept incoming connections
description: |
The default gRPC port in Agones 1.0 was 59357 which is in the ephemeral port range and can
encounter conflicts in rare cases. The default will be changed to 9357 in a future release
of Agones.
Starting with Agones 1.2 the default gRPC port is 9357. In earlier releases, the default was 59357.
type: integer
minimum: 1
maximum: 65535
httpPort:
title: The port on which the SDK server binds the HTTP gRPC gateway server to accept incoming connections
description: |
The default HTTP port in Agones 1.0 was 59358 which is in the ephemeral port range and can
encounter conflicts in rare cases. The default will be changed to 9358 in a future release
of Agones.
Starting with Agones 1.2 the default HTTP port is 9358. In earlier releases, the default was 59358.
type: integer
minimum: 1
maximum: 65535
Expand Down Expand Up @@ -645,18 +641,14 @@ spec:
grpcPort:
title: The port on which the SDK server binds the gRPC server to accept incoming connections
description: |
The default gRPC port in Agones 1.0 was 59357 which is in the ephemeral port range and can
encounter conflicts in rare cases. The default will be changed to 9357 in a future release
of Agones.
Starting with Agones 1.2 the default gRPC port is 9357. In earlier releases, the default was 59357.
type: integer
minimum: 1
maximum: 65535
httpPort:
title: The port on which the SDK server binds the HTTP gRPC gateway server to accept incoming connections
description: |
The default HTTP port in Agones 1.0 was 59358 which is in the ephemeral port range and can
encounter conflicts in rare cases. The default will be changed to 9358 in a future release
of Agones.
Starting with Agones 1.2 the default HTTP port is 9358. In earlier releases, the default was 59358.
type: integer
minimum: 1
maximum: 65535
Expand Down Expand Up @@ -944,18 +936,14 @@ spec:
grpcPort:
title: The port on which the SDK server binds the gRPC server to accept incoming connections
description: |
The default gRPC port in Agones 1.0 was 59357 which is in the ephemeral port range and can
encounter conflicts in rare cases. The default will be changed to 9357 in a future release
of Agones.
Starting with Agones 1.2 the default gRPC port is 9357. In earlier releases, the default was 59357.
type: integer
minimum: 1
maximum: 65535
httpPort:
title: The port on which the SDK server binds the HTTP gRPC gateway server to accept incoming connections
description: |
The default HTTP port in Agones 1.0 was 59358 which is in the ephemeral port range and can
encounter conflicts in rare cases. The default will be changed to 9358 in a future release
of Agones.
Starting with Agones 1.2 the default HTTP port is 9358. In earlier releases, the default was 59358.
type: integer
minimum: 1
maximum: 65535
Expand Down
6 changes: 2 additions & 4 deletions pkg/apis/agones/v1/gameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,10 @@ func (gss *GameServerSpec) applySdkServerDefaults() {
gss.SdkServer.LogLevel = SdkServerLogLevelInfo
}
if gss.SdkServer.GRPCPort == 0 {
// TODO(roberthbailey): Change to 9357 in the 1.2.0 release
gss.SdkServer.GRPCPort = 59357
gss.SdkServer.GRPCPort = 9357
}
if gss.SdkServer.HTTPPort == 0 {
// TODO(roberthbailey): Change to 9358 in the 1.2.0 release
gss.SdkServer.HTTPPort = 59358
gss.SdkServer.HTTPPort = 9358
}
}

Expand Down
40 changes: 20 additions & 20 deletions pkg/apis/agones/v1/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
},
sdkServer: SdkServer{
LogLevel: SdkServerLogLevelInfo,
GRPCPort: 59357,
HTTPPort: 59358,
GRPCPort: 9357,
HTTPPort: 9358,
},
},
},
Expand All @@ -124,8 +124,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
},
sdkServer: SdkServer{
LogLevel: SdkServerLogLevelInfo,
GRPCPort: 59357,
HTTPPort: 59358,
GRPCPort: 9357,
HTTPPort: 9358,
},
},
},
Expand All @@ -151,8 +151,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
},
SdkServer: SdkServer{
LogLevel: SdkServerLogLevelInfo,
GRPCPort: 59357,
HTTPPort: 59358,
GRPCPort: 9357,
HTTPPort: 9358,
},
},
Status: GameServerStatus{State: "TestState"}},
Expand All @@ -170,8 +170,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
},
sdkServer: SdkServer{
LogLevel: SdkServerLogLevelInfo,
GRPCPort: 59357,
HTTPPort: 59358,
GRPCPort: 9357,
HTTPPort: 9358,
},
},
},
Expand All @@ -196,8 +196,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
},
sdkServer: SdkServer{
LogLevel: SdkServerLogLevelInfo,
GRPCPort: 59357,
HTTPPort: 59358,
GRPCPort: 9357,
HTTPPort: 9358,
},
},
},
Expand All @@ -220,8 +220,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
},
sdkServer: SdkServer{
LogLevel: SdkServerLogLevelInfo,
GRPCPort: 59357,
HTTPPort: 59358,
GRPCPort: 9357,
HTTPPort: 9358,
},
},
},
Expand Down Expand Up @@ -249,8 +249,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
health: Health{Disabled: true},
sdkServer: SdkServer{
LogLevel: SdkServerLogLevelInfo,
GRPCPort: 59357,
HTTPPort: 59358,
GRPCPort: 9357,
HTTPPort: 9358,
},
},
},
Expand Down Expand Up @@ -278,8 +278,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
},
sdkServer: SdkServer{
LogLevel: SdkServerLogLevelDebug,
GRPCPort: 59357,
HTTPPort: 59358,
GRPCPort: 9357,
HTTPPort: 9358,
},
},
},
Expand All @@ -289,8 +289,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
Ports: []GameServerPort{{ContainerPort: 999}},
SdkServer: SdkServer{
LogLevel: SdkServerLogLevelError,
GRPCPort: 9357,
HTTPPort: 9358,
GRPCPort: 19357,
HTTPPort: 19358,
},
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{Containers: []corev1.Container{
Expand All @@ -311,8 +311,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
},
sdkServer: SdkServer{
LogLevel: SdkServerLogLevelError,
GRPCPort: 9357,
HTTPPort: 9358,
GRPCPort: 19357,
HTTPPort: 19358,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion sdks/cpp/src/agones/sdk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct SDK::SDKImpl {

SDK::SDK() : pimpl_{std::make_unique<SDKImpl>()} {
const char* port = std::getenv("AGONES_SDK_GRPC_PORT");
pimpl_->host_ = std::string("localhost:") + (port ? port : "59357");
pimpl_->host_ = std::string("localhost:") + (port ? port : "9357");
pimpl_->channel_ =
grpc::CreateChannel(pimpl_->host_, grpc::InsecureChannelCredentials());
}
Expand Down
4 changes: 2 additions & 2 deletions sdks/go/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ type SDK struct {
}

// NewSDK starts a new SDK instance, and connects to
// localhost on port 59357. Blocks until connection and handshake are made.
// localhost on port 9357. Blocks until connection and handshake are made.
// Times out after 30 seconds.
func NewSDK() (*SDK, error) {
p := os.Getenv("AGONES_SDK_GRPC_PORT")
if p == "" {
p = "59357"
p = "9357"
}
addr := fmt.Sprintf("localhost:%s", p)
s := &SDK{
Expand Down
2 changes: 1 addition & 1 deletion sdks/nodejs/spec/agonesSDK.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('agones', () => {
describe('port', () => {
it('returns the default port if $AGONES_SDK_GRPC_PORT is not defined', async () => {
let port = agonesSDK.port;
expect(port).toEqual('59357');
expect(port).toEqual('9357');
});

it('returns a valid port set in $AGONES_SDK_GRPC_PORT', async () => {
Expand Down
2 changes: 1 addition & 1 deletion sdks/nodejs/src/agonesSDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AgonesSDK {
}

get port() {
return process.env.AGONES_SDK_GRPC_PORT || '59357';
return process.env.AGONES_SDK_GRPC_PORT || '9357';
}

async connect() {
Expand Down
4 changes: 2 additions & 2 deletions sdks/rust/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ pub struct Sdk {
}

impl Sdk {
/// Starts a new SDK instance, and connects to localhost on port 59357.
/// Starts a new SDK instance, and connects to localhost on port 9357.
/// Blocks until connection and handshake are made.
/// Times out after ~30 seconds.
pub fn new() -> Result<Sdk> {
let port = env::var("AGONES_SDK_GRPC_PORT").unwrap_or("59357".to_string());
let port = env::var("AGONES_SDK_GRPC_PORT").unwrap_or("9357".to_string());
let addr = format!("localhost:{}", port);
let env = Arc::new(grpcio::EnvBuilder::new().build());
let ch = grpcio::ChannelBuilder::new(env)
Expand Down
2 changes: 1 addition & 1 deletion sdks/unity/AgonesSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private struct KeyValueMessage
private void Start()
{
String port = Environment.GetEnvironmentVariable("AGONES_SDK_HTTP_PORT");
sidecarAddress = "http://localhost:" + (port ?? "59358");
sidecarAddress = "http://localhost:" + (port ?? "9358");
HealthCheckAsync();
}

Expand Down
2 changes: 1 addition & 1 deletion sdks/unreal/Agones/Source/Agones/AgonesHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DEFINE_LOG_CATEGORY(LogAgonesHook);
static FString GetSidecarAddress()
{
FString port = FPlatformMisc::GetEnvironmentVariable(TEXT("AGONES_SDK_HTTP_PORT"));
return FString(TEXT("http://localhost:")) + (!port.IsEmpty() ? port : FString(TEXT("59358")));
return FString(TEXT("http://localhost:")) + (!port.IsEmpty() ? port : FString(TEXT("9358")));
}

FAgonesHook::FAgonesHook()
Expand Down
Loading

0 comments on commit 71383df

Please sign in to comment.