diff --git a/cmd/sdk-server/main.go b/cmd/sdk-server/main.go index 31af97da30..322ca93664 100644 --- a/cmd/sdk-server/main.go +++ b/cmd/sdk-server/main.go @@ -41,20 +41,22 @@ import ( ) const ( - grpcPort = 59357 - httpPort = 59358 + defaultGRPCPort = 59357 + defaultHTTPPort = 59358 // specifically env vars gameServerNameEnv = "GAMESERVER_NAME" podNamespaceEnv = "POD_NAMESPACE" // Flags (that can also be env vars) - localFlag = "local" - fileFlag = "file" - testFlag = "test" - addressFlag = "address" - delayFlag = "delay" - timeoutFlag = "timeout" + localFlag = "local" + fileFlag = "file" + testFlag = "test" + addressFlag = "address" + delayFlag = "delay" + timeoutFlag = "timeout" + grpcPortFlag = "grpc-port" + httpPortFlag = "http-port" ) var ( @@ -64,15 +66,8 @@ var ( func main() { ctlConf := parseEnvFlags() logger.WithField("version", pkg.Version). - WithField("grpcPort", grpcPort).WithField("httpPort", httpPort). WithField("ctlConf", ctlConf).Info("Starting sdk sidecar") - grpcEndpoint := fmt.Sprintf("%s:%d", ctlConf.Address, grpcPort) - lis, err := net.Listen("tcp", grpcEndpoint) - if err != nil { - logger.WithField("grpcPort", grpcPort).WithField("Address", ctlConf.Address).Fatalf("Could not listen on grpcPort") - } - if ctlConf.Delay > 0 { logger.Infof("Waiting %d seconds before starting", ctlConf.Delay) time.Sleep(time.Duration(ctlConf.Delay) * time.Second) @@ -88,7 +83,7 @@ func main() { mux := gwruntime.NewServeMux() httpServer := &http.Server{ - Addr: fmt.Sprintf("%s:%d", ctlConf.Address, httpPort), + Addr: fmt.Sprintf("%s:%d", ctlConf.Address, ctlConf.HTTPPort), Handler: mux, } defer httpServer.Close() // nolint: errcheck @@ -123,7 +118,7 @@ func main() { } } else { var config *rest.Config - config, err = rest.InClusterConfig() + config, err := rest.InClusterConfig() if err != nil { logger.WithError(err).Fatal("Could not create in cluster config") } @@ -156,7 +151,8 @@ func main() { sdk.RegisterSDKServer(grpcServer, s) } - go runGrpc(grpcServer, lis) + grpcEndpoint := fmt.Sprintf("%s:%d", ctlConf.Address, ctlConf.GRPCPort) + go runGrpc(grpcServer, grpcEndpoint) go runGateway(ctx, grpcEndpoint, mux, httpServer) select { @@ -203,8 +199,13 @@ func registerTestSdkServer(grpcServer *grpc.Server, ctlConf config) (localSDK *s } // runGrpc runs the grpc service -func runGrpc(grpcServer *grpc.Server, lis net.Listener) { - logger.Info("Starting SDKServer grpc service...") +func runGrpc(grpcServer *grpc.Server, grpcEndpoint string) { + lis, err := net.Listen("tcp", grpcEndpoint) + if err != nil { + logger.WithField("grpcEndpoint", grpcEndpoint).Fatal("Could not listen on grpc endpoint") + } + + logger.WithField("grpcEndpoint", grpcEndpoint).Info("Starting SDKServer grpc service...") if err := grpcServer.Serve(lis); err != nil { logger.WithError(err).Fatal("Could not serve grpc server") } @@ -221,7 +222,7 @@ func runGateway(ctx context.Context, grpcEndpoint string, mux *gwruntime.ServeMu logger.WithError(err).Fatal("Could not register grpc-gateway") } - logger.Info("Starting SDKServer grpc-gateway...") + logger.WithField("grpcEndpoint", grpcEndpoint).Info("Starting SDKServer grpc-gateway...") if err := httpServer.ListenAndServe(); err != nil { if err == http.ErrServerClosed { logger.WithError(err).Info("http server closed") @@ -241,10 +242,14 @@ func parseEnvFlags() config { viper.SetDefault(addressFlag, "localhost") viper.SetDefault(delayFlag, 0) viper.SetDefault(timeoutFlag, 0) + viper.SetDefault(grpcPortFlag, defaultGRPCPort) + viper.SetDefault(httpPortFlag, defaultHTTPPort) pflag.Bool(localFlag, viper.GetBool(localFlag), "Set this, or LOCAL env, to 'true' to run this binary in local development mode. Defaults to 'false'") pflag.StringP(fileFlag, "f", viper.GetString(fileFlag), "Set this, or FILE env var to the path of a local yaml or json file that contains your GameServer resoure configuration") pflag.String(addressFlag, viper.GetString(addressFlag), "The Address to bind the server grpcPort to. Defaults to 'localhost'") + pflag.Int(grpcPortFlag, viper.GetInt(grpcPortFlag), fmt.Sprintf("Port on which to bind the gRPC server. Defaults to %d", defaultGRPCPort)) + pflag.Int(httpPortFlag, viper.GetInt(httpPortFlag), fmt.Sprintf("Port on which to bind the HTTP server. Defaults to %d", defaultHTTPPort)) pflag.Int(delayFlag, viper.GetInt(delayFlag), "Time to delay (in seconds) before starting to execute main. Useful for tests") pflag.Int(timeoutFlag, viper.GetInt(timeoutFlag), "Time of execution (in seconds) before close. Useful for tests") pflag.String(testFlag, viper.GetString(testFlag), "List functions which shoud be called during the SDK Conformance test run.") @@ -258,6 +263,8 @@ func parseEnvFlags() config { runtime.Must(viper.BindEnv(podNamespaceEnv)) runtime.Must(viper.BindEnv(delayFlag)) runtime.Must(viper.BindEnv(timeoutFlag)) + runtime.Must(viper.BindEnv(grpcPortFlag)) + runtime.Must(viper.BindEnv(httpPortFlag)) runtime.Must(viper.BindPFlags(pflag.CommandLine)) return config{ @@ -267,6 +274,8 @@ func parseEnvFlags() config { Delay: viper.GetInt(delayFlag), Timeout: viper.GetInt(timeoutFlag), Test: viper.GetString(testFlag), + GRPCPort: viper.GetInt(grpcPortFlag), + HTTPPort: viper.GetInt(httpPortFlag), } } @@ -278,4 +287,6 @@ type config struct { Delay int Timeout int Test string + GRPCPort int + HTTPPort int } diff --git a/examples/fleet.yaml b/examples/fleet.yaml index 99a73a5c0c..2bb30f2a4b 100644 --- a/examples/fleet.yaml +++ b/examples/fleet.yaml @@ -62,9 +62,13 @@ spec: health: initialDelaySeconds: 30 periodSeconds: 60 - # logging parameters for game server sidecar - logging: - sdkServer: Info + # Parameters for game server sidecar + sdkServer: + # sdkServer log level parameter has three options: + # - "Info" (default) The SDK server will output all messages except for debug messages + # - "Debug" The SDK server will output all messages including debug messages + # - "Error" The SDK server will only output error messages + logLevel: Info # The GameServer's Pod template template: spec: diff --git a/examples/gameserver.yaml b/examples/gameserver.yaml index 4676bb6f86..6953b21d56 100644 --- a/examples/gameserver.yaml +++ b/examples/gameserver.yaml @@ -60,13 +60,20 @@ spec: # Minimum consecutive failures for the health probe to be considered failed after having succeeded. # Defaults to 3. Minimum value is 1 failureThreshold: 3 - # logging parameters for game server sidecar - logging: - # sdkServer logging parameter has three options: + # Parameters for game server sidecar + sdkServer: + # sdkServer log level parameter has three options: # - "Info" (default) The SDK server will output all messages except for debug messages # - "Debug" The SDK server will output all messages including debug messages # - "Error" The SDK server will only output error messages - sdkServer: Info + 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. + grpcPort: 9357 + httpPort: 9358 # Pod template configuration # https://v1-12.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#podtemplate-v1-core template: diff --git a/install/helm/agones/templates/crds/_gameserverspecvalidation.yaml b/install/helm/agones/templates/crds/_gameserverspecvalidation.yaml index 18b0c7fc52..240352d5c4 100644 --- a/install/helm/agones/templates/crds/_gameserverspecvalidation.yaml +++ b/install/helm/agones/templates/crds/_gameserverspecvalidation.yaml @@ -92,14 +92,14 @@ properties: type: integer minimum: 1 maximum: 65535 - logging: + sdkServer: type: object - title: Define logging levels for agones system components + title: Parameters for the SDK Server (sidecar) properties: - sdkServer: + logLevel: type: string description: | - sdkServer logging parameter has three options: + sdkServer log level parameter has three options: - "Info" (default) The SDK server will output all messages except for debug messages - "Debug" The SDK server will output all messages including debug messages - "Error" The SDK server will only output error messages @@ -107,6 +107,24 @@ properties: - Error - Info - Debug + 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. + 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. + type: integer + minimum: 1 + maximum: 65535 scheduling: type: string enum: diff --git a/install/yaml/install.yaml b/install/yaml/install.yaml index 5d83486f57..1e050a775c 100644 --- a/install/yaml/install.yaml +++ b/install/yaml/install.yaml @@ -339,14 +339,14 @@ spec: type: integer minimum: 1 maximum: 65535 - logging: + sdkServer: type: object - title: Define logging levels for agones system components + title: Parameters for the SDK Server (sidecar) properties: - sdkServer: + logLevel: type: string description: | - sdkServer logging parameter has three options: + sdkServer log level parameter has three options: - "Info" (default) The SDK server will output all messages except for debug messages - "Debug" The SDK server will output all messages including debug messages - "Error" The SDK server will only output error messages @@ -354,6 +354,24 @@ spec: - Error - Info - Debug + 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. + 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. + type: integer + minimum: 1 + maximum: 65535 scheduling: type: string enum: @@ -609,14 +627,14 @@ spec: type: integer minimum: 1 maximum: 65535 - logging: + sdkServer: type: object - title: Define logging levels for agones system components + title: Parameters for the SDK Server (sidecar) properties: - sdkServer: + logLevel: type: string description: | - sdkServer logging parameter has three options: + sdkServer log level parameter has three options: - "Info" (default) The SDK server will output all messages except for debug messages - "Debug" The SDK server will output all messages including debug messages - "Error" The SDK server will only output error messages @@ -624,6 +642,24 @@ spec: - Error - Info - Debug + 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. + 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. + type: integer + minimum: 1 + maximum: 65535 scheduling: type: string enum: @@ -893,14 +929,14 @@ spec: type: integer minimum: 1 maximum: 65535 - logging: + sdkServer: type: object - title: Define logging levels for agones system components + title: Parameters for the SDK Server (sidecar) properties: - sdkServer: + logLevel: type: string description: | - sdkServer logging parameter has three options: + sdkServer log level parameter has three options: - "Info" (default) The SDK server will output all messages except for debug messages - "Debug" The SDK server will output all messages including debug messages - "Error" The SDK server will only output error messages @@ -908,6 +944,24 @@ spec: - Error - Info - Debug + 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. + 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. + type: integer + minimum: 1 + maximum: 65535 scheduling: type: string enum: diff --git a/pkg/apis/agones/v1/gameserver.go b/pkg/apis/agones/v1/gameserver.go index 95bd317aa8..173a236633 100644 --- a/pkg/apis/agones/v1/gameserver.go +++ b/pkg/apis/agones/v1/gameserver.go @@ -70,6 +70,13 @@ const ( // This will mean that users will need to lookup what port has been opened through the server side SDK. Passthrough PortPolicy = "Passthrough" + // SdkServerLogLevelInfo will cause the SDK server to output all messages except for debug messages. + SdkServerLogLevelInfo SdkServerLogLevel = "Info" + // SdkServerLogLevelDebug will cause the SDK server to output all messages including debug messages. + SdkServerLogLevelDebug SdkServerLogLevel = "Debug" + // SdkServerLogLevelError will cause the SDK server to only output error messages. + SdkServerLogLevelError SdkServerLogLevel = "Error" + // RoleLabel is the label in which the Agones role is specified. // Pods from a GameServer will have the value "gameserver" RoleLabel = agones.GroupName + "/role" @@ -135,18 +142,12 @@ type GameServerSpec struct { Health Health `json:"health,omitempty"` // Scheduling strategy. Defaults to "Packed" Scheduling apis.SchedulingStrategy `json:"scheduling,omitempty"` - // Logging specifies log levels for Agones system containers - Logging Logging `json:"logging,omitempty"` + // SdkServer specifies parameters for the Agones SDK Server sidecar container + SdkServer SdkServer `json:"sdkServer,omitempty"` // Template describes the Pod that will be created for the GameServer Template corev1.PodTemplateSpec `json:"template"` } -// Logging specifies log levels for Agones system containers -type Logging struct { - // SdkServer is a log level for SDK server (sidecar) logs. Defaults to "Info" - SdkServer string `json:"sdkServer,omitempty"` -} - // GameServerState is the state for the GameServer type GameServerState string @@ -184,6 +185,19 @@ type GameServerPort struct { Protocol corev1.Protocol `json:"protocol,omitempty"` } +// SdkServerLogLevel is the log level for SDK server (sidecar) logs +type SdkServerLogLevel string + +// SdkServer specifies parameters for the Agones SDK Server sidecar container +type SdkServer struct { + // LogLevel for SDK server (sidecar) logs. Defaults to "Info" + LogLevel SdkServerLogLevel `json:"logLevel,omitempty"` + // GRPCPort is the port on which the SDK Server binds the gRPC server to accept incoming connections + GRPCPort int32 `json:"grpcPort,omitempty"` + // HTTPPort is the port on which the SDK Server binds the HTTP gRPC gateway server to accept incoming connections + HTTPPort int32 `json:"httpPort,omitempty"` +} + // GameServerStatus is the status for a GameServer resource type GameServerStatus struct { // GameServerState is the current state of a GameServer, e.g. Creating, Starting, Ready, etc @@ -221,13 +235,21 @@ func (gss *GameServerSpec) ApplyDefaults() { gss.applyPortDefaults() gss.applyHealthDefaults() gss.applySchedulingDefaults() - gss.applyLogLevelDefaults() + gss.applySdkServerDefaults() } -// applyLogLevelDefaults applies the log level default - "Info" -func (gss *GameServerSpec) applyLogLevelDefaults() { - if gss.Logging.SdkServer == "" { - gss.Logging.SdkServer = "Info" +// applySdkServerDefaults applies the default log level ("Info") for the sidecar +func (gss *GameServerSpec) applySdkServerDefaults() { + if gss.SdkServer.LogLevel == "" { + gss.SdkServer.LogLevel = SdkServerLogLevelInfo + } + if gss.SdkServer.GRPCPort == 0 { + // TODO(roberthbailey): Change to 9357 in the 1.2.0 release + gss.SdkServer.GRPCPort = 59357 + } + if gss.SdkServer.HTTPPort == 0 { + // TODO(roberthbailey): Change to 9358 in the 1.2.0 release + gss.SdkServer.HTTPPort = 59358 } } diff --git a/pkg/apis/agones/v1/gameserver_test.go b/pkg/apis/agones/v1/gameserver_test.go index 3f7905b8c0..5a6e140213 100644 --- a/pkg/apis/agones/v1/gameserver_test.go +++ b/pkg/apis/agones/v1/gameserver_test.go @@ -61,12 +61,12 @@ func TestGameServerApplyDefaults(t *testing.T) { t.Parallel() type expected struct { - protocol corev1.Protocol - state GameServerState - policy PortPolicy - health Health - scheduling apis.SchedulingStrategy - sdkServerLogLevel string + protocol corev1.Protocol + state GameServerState + policy PortPolicy + health Health + scheduling apis.SchedulingStrategy + sdkServer SdkServer } data := map[string]struct { gameServer GameServer @@ -94,7 +94,11 @@ func TestGameServerApplyDefaults(t *testing.T) { InitialDelaySeconds: 5, PeriodSeconds: 5, }, - sdkServerLogLevel: "Info", + sdkServer: SdkServer{ + LogLevel: SdkServerLogLevelInfo, + GRPCPort: 59357, + HTTPPort: 59358, + }, }, }, "defaults on passthrough": { @@ -118,7 +122,11 @@ func TestGameServerApplyDefaults(t *testing.T) { InitialDelaySeconds: 5, PeriodSeconds: 5, }, - sdkServerLogLevel: "Info", + sdkServer: SdkServer{ + LogLevel: SdkServerLogLevelInfo, + GRPCPort: 59357, + HTTPPort: 59358, + }, }, }, "defaults are already set": { @@ -141,7 +149,11 @@ func TestGameServerApplyDefaults(t *testing.T) { {Name: "testing", Image: "testing/image"}, {Name: "testing2", Image: "testing/image2"}}}, }, - Logging: Logging{SdkServer: "Info"}, + SdkServer: SdkServer{ + LogLevel: SdkServerLogLevelInfo, + GRPCPort: 59357, + HTTPPort: 59358, + }, }, Status: GameServerStatus{State: "TestState"}}, container: "testing2", @@ -156,7 +168,11 @@ func TestGameServerApplyDefaults(t *testing.T) { InitialDelaySeconds: 11, PeriodSeconds: 12, }, - sdkServerLogLevel: "Info", + sdkServer: SdkServer{ + LogLevel: SdkServerLogLevelInfo, + GRPCPort: 59357, + HTTPPort: 59358, + }, }, }, "set basic defaults on static gameserver": { @@ -178,7 +194,11 @@ func TestGameServerApplyDefaults(t *testing.T) { InitialDelaySeconds: 5, PeriodSeconds: 5, }, - sdkServerLogLevel: "Info", + sdkServer: SdkServer{ + LogLevel: SdkServerLogLevelInfo, + GRPCPort: 59357, + HTTPPort: 59358, + }, }, }, "health is disabled": { @@ -198,7 +218,11 @@ func TestGameServerApplyDefaults(t *testing.T) { health: Health{ Disabled: true, }, - sdkServerLogLevel: "Info", + sdkServer: SdkServer{ + LogLevel: SdkServerLogLevelInfo, + GRPCPort: 59357, + HTTPPort: 59358, + }, }, }, "convert from legacy single port to multiple": { @@ -218,19 +242,23 @@ func TestGameServerApplyDefaults(t *testing.T) { }, container: "testing", expected: expected{ - protocol: corev1.ProtocolTCP, - state: GameServerStateCreating, - policy: Static, - scheduling: apis.Packed, - health: Health{Disabled: true}, - sdkServerLogLevel: "Info", + protocol: corev1.ProtocolTCP, + state: GameServerStateCreating, + policy: Static, + scheduling: apis.Packed, + health: Health{Disabled: true}, + sdkServer: SdkServer{ + LogLevel: SdkServerLogLevelInfo, + GRPCPort: 59357, + HTTPPort: 59358, + }, }, }, "set Debug logging level": { gameServer: GameServer{ Spec: GameServerSpec{ - Ports: []GameServerPort{{ContainerPort: 999}}, - Logging: Logging{SdkServer: "Debug"}, + Ports: []GameServerPort{{ContainerPort: 999}}, + SdkServer: SdkServer{LogLevel: SdkServerLogLevelDebug}, Template: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{Containers: []corev1.Container{ {Name: "testing", Image: "testing/image"}, @@ -248,7 +276,44 @@ func TestGameServerApplyDefaults(t *testing.T) { InitialDelaySeconds: 5, PeriodSeconds: 5, }, - sdkServerLogLevel: "Debug", + sdkServer: SdkServer{ + LogLevel: SdkServerLogLevelDebug, + GRPCPort: 59357, + HTTPPort: 59358, + }, + }, + }, + "set gRPC and HTTP ports on SDK Server": { + gameServer: GameServer{ + Spec: GameServerSpec{ + Ports: []GameServerPort{{ContainerPort: 999}}, + SdkServer: SdkServer{ + LogLevel: SdkServerLogLevelError, + GRPCPort: 9357, + HTTPPort: 9358, + }, + Template: corev1.PodTemplateSpec{ + Spec: corev1.PodSpec{Containers: []corev1.Container{ + {Name: "testing", Image: "testing/image"}, + }}}}, + }, + container: "testing", + expected: expected{ + protocol: "UDP", + state: GameServerStatePortAllocation, + policy: Dynamic, + scheduling: apis.Packed, + health: Health{ + Disabled: false, + FailureThreshold: 3, + InitialDelaySeconds: 5, + PeriodSeconds: 5, + }, + sdkServer: SdkServer{ + LogLevel: SdkServerLogLevelError, + GRPCPort: 9357, + HTTPPort: 9358, + }, }, }, } @@ -264,9 +329,9 @@ func TestGameServerApplyDefaults(t *testing.T) { assert.Equal(t, test.container, spec.Container) assert.Equal(t, test.expected.protocol, spec.Ports[0].Protocol) assert.Equal(t, test.expected.state, test.gameServer.Status.State) - assert.Equal(t, test.expected.health, test.gameServer.Spec.Health) assert.Equal(t, test.expected.scheduling, test.gameServer.Spec.Scheduling) - assert.Equal(t, test.expected.sdkServerLogLevel, test.gameServer.Spec.Logging.SdkServer) + assert.Equal(t, test.expected.health, test.gameServer.Spec.Health) + assert.Equal(t, test.expected.sdkServer, test.gameServer.Spec.SdkServer) }) } } diff --git a/pkg/gameservers/controller.go b/pkg/gameservers/controller.go index 75d6b7bc3b..c78ed0e1aa 100644 --- a/pkg/gameservers/controller.go +++ b/pkg/gameservers/controller.go @@ -592,6 +592,14 @@ func (c *Controller) sidecar(gs *agonesv1.GameServer) corev1.Container { }, } + if gs.Spec.SdkServer.GRPCPort != 0 { + sidecar.Args = append(sidecar.Args, fmt.Sprintf("--grpc-port=%d", gs.Spec.SdkServer.GRPCPort)) + } + + if gs.Spec.SdkServer.HTTPPort != 0 { + sidecar.Args = append(sidecar.Args, fmt.Sprintf("--http-port=%d", gs.Spec.SdkServer.HTTPPort)) + } + if !c.sidecarCPURequest.IsZero() { sidecar.Resources.Requests = corev1.ResourceList{corev1.ResourceCPU: c.sidecarCPURequest} } diff --git a/pkg/gameservers/controller_test.go b/pkg/gameservers/controller_test.go index c30dc6e4fc..11692b41c9 100644 --- a/pkg/gameservers/controller_test.go +++ b/pkg/gameservers/controller_test.go @@ -198,10 +198,8 @@ func TestControllerSyncGameServerWithDevIP(t *testing.T) { expectedState := agonesv1.GameServerStateReady assert.Equal(t, expectedState, gs.Status.State) - if expectedState == agonesv1.GameServerStateReady { - assert.Equal(t, ipFixture, gs.Status.Address) - assert.NotEmpty(t, gs.Status.Ports[0].Port) - } + assert.Equal(t, ipFixture, gs.Status.Address) + assert.NotEmpty(t, gs.Status.Ports[0].Port) return true, gs, nil }) @@ -674,8 +672,8 @@ func TestControllerSyncGameServerCreatingState(t *testing.T) { defer cancel() gs, err := c.syncGameServerCreatingState(fixture) - assert.Equal(t, agonesv1.GameServerStateStarting, gs.Status.State) assert.Nil(t, err) + assert.Equal(t, agonesv1.GameServerStateStarting, gs.Status.State) assert.False(t, podCreated, "Pod should not have been created") assert.True(t, gsUpdated, "GameServer should have been updated") }) @@ -739,8 +737,8 @@ func TestControllerSyncGameServerStartingState(t *testing.T) { gsFixture := newFixture() gsFixture.ApplyDefaults() pod, err := gsFixture.Pod() - pod.Spec.NodeName = nodeFixtureName assert.Nil(t, err) + pod.Spec.NodeName = nodeFixtureName gsUpdated := false m.KubeClient.AddReactor("list", "nodes", func(action k8stesting.Action) (bool, runtime.Object, error) { @@ -961,8 +959,8 @@ func TestControllerSyncGameServerRequestReadyState(t *testing.T) { Spec: newSingleContainerSpec(), Status: agonesv1.GameServerStatus{State: agonesv1.GameServerStateRequestReady}} gsFixture.ApplyDefaults() pod, err := gsFixture.Pod() - pod.Spec.NodeName = nodeFixtureName assert.Nil(t, err) + pod.Spec.NodeName = nodeFixtureName gsUpdated := false ipFixture := "12.12.12.12" diff --git a/pkg/sdkserver/sdkserver.go b/pkg/sdkserver/sdkserver.go index b1b00547f3..535731389c 100644 --- a/pkg/sdkserver/sdkserver.go +++ b/pkg/sdkserver/sdkserver.go @@ -191,13 +191,13 @@ func (s *SDKServer) Run(stop <-chan struct{}) error { return err } - logLevel := "info" + logLevel := agonesv1.SdkServerLogLevelInfo // grab configuration details - if gs.Spec.Logging.SdkServer != "" { - logLevel = strings.ToLower(gs.Spec.Logging.SdkServer) + if gs.Spec.SdkServer.LogLevel != "" { + logLevel = gs.Spec.SdkServer.LogLevel } s.logger.WithField("logLevel", logLevel).Info("Setting LogLevel configuration") - level, err := logrus.ParseLevel(logLevel) + level, err := logrus.ParseLevel(strings.ToLower(string(logLevel))) if err == nil { s.logger.Logger.SetLevel(level) } else { diff --git a/site/content/en/docs/Reference/agones_crd_api_reference.html b/site/content/en/docs/Reference/agones_crd_api_reference.html index d1417b04a9..608e3c5bcd 100644 --- a/site/content/en/docs/Reference/agones_crd_api_reference.html +++ b/site/content/en/docs/Reference/agones_crd_api_reference.html @@ -2405,15 +2405,15 @@
logging
+sdkServer
-
-Logging
+
+SdkServer
Logging specifies log levels for Agones system containers
+SdkServer specifies parameters for the Agones SDK Server sidecar container
logging
+sdkServer
-
-Logging
+
+SdkServer
Logging specifies log levels for Agones system containers
+SdkServer specifies parameters for the Agones SDK Server sidecar container
logging
+sdkServer
-
-Logging
+
+SdkServer
Logging specifies log levels for Agones system containers
+SdkServer specifies parameters for the Agones SDK Server sidecar container
string
alias)+(Appears on: +GameServerPort) +
++
PortPolicy is the port policy for the GameServer
+ +(Appears on: GameServerSpec)
-
Logging specifies log levels for Agones system containers
+SdkServer specifies parameters for the Agones SDK Server sidecar container
-sdkServer
+logLevel
-string
+
+SdkServerLogLevel
+
+
+ |
+
+ LogLevel for SDK server (sidecar) logs. Defaults to “Info” + |
+
+grpcPort
+
+int32
+
+ |
+
+ GRPCPort is the port on which the SDK Server binds the gRPC server to accept incoming connections + |
+
+httpPort
+
+int32
|
- SdkServer is a log level for SDK server (sidecar) logs. Defaults to “Info” +HTTPPort is the port on which the SDK Server binds the HTTP gRPC gateway server to accept incoming connections |
string
alias)(Appears on: -GameServerPort) +SdkServer)
-
PortPolicy is the port policy for the GameServer
+SdkServerLogLevel is the log level for SDK server (sidecar) logs