diff --git a/cmd/allocator/main.go b/cmd/allocator/main.go index 31ea24d80f..269a9f2674 100644 --- a/cmd/allocator/main.go +++ b/cmd/allocator/main.go @@ -39,6 +39,7 @@ import ( "agones.dev/agones/pkg/util/signals" "github.com/heptiolabs/healthcheck" "github.com/pkg/errors" + "github.com/sirupsen/logrus" "go.opencensus.io/plugin/ocgrpc" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -70,6 +71,15 @@ func main() { WithField("featureGates", runtime.EncodeFeatures()).WithField("sslPort", sslPort). Info("Starting agones-allocator") + logger.WithField("logLevel", conf.LogLevel).Info("Setting LogLevel configuration") + level, err := logrus.ParseLevel(strings.ToLower(conf.LogLevel)) + if err == nil { + runtime.SetLevel(level) + } else { + logger.WithError(err).Info("Specified wrong Logging.SdkServer. Setting default loglevel - Info") + runtime.SetLevel(logrus.InfoLevel) + } + health, closer := setupMetricsRecorder(conf) defer closer() diff --git a/cmd/allocator/metrics.go b/cmd/allocator/metrics.go index eeb9dcfdb7..5dccb95d16 100644 --- a/cmd/allocator/metrics.go +++ b/cmd/allocator/metrics.go @@ -39,6 +39,7 @@ const ( totalRemoteAllocationTimeoutFlag = "total-remote-allocation-timeout" apiServerSustainedQPSFlag = "api-server-qps" apiServerBurstQPSFlag = "api-server-qps-burst" + logLevelFlag = "log-level" ) func init() { @@ -54,6 +55,7 @@ type config struct { Stackdriver bool GCPProjectID string StackdriverLabels string + LogLevel string totalRemoteAllocationTimeout time.Duration remoteAllocationTimeout time.Duration } @@ -70,6 +72,7 @@ func parseEnvFlags() config { viper.SetDefault(tlsDisabledFlag, false) viper.SetDefault(remoteAllocationTimeoutFlag, 10*time.Second) viper.SetDefault(totalRemoteAllocationTimeoutFlag, 30*time.Second) + viper.SetDefault(logLevelFlag, "Info") pflag.Int32(apiServerSustainedQPSFlag, viper.GetInt32(apiServerSustainedQPSFlag), "Maximum sustained queries per second to send to the API server") pflag.Int32(apiServerBurstQPSFlag, viper.GetInt32(apiServerBurstQPSFlag), "Maximum burst queries per second to send to the API server") @@ -81,6 +84,7 @@ func parseEnvFlags() config { pflag.Bool(tlsDisabledFlag, viper.GetBool(tlsDisabledFlag), "Flag to enable/disable TLS in the allocator.") pflag.Duration(remoteAllocationTimeoutFlag, viper.GetDuration(remoteAllocationTimeoutFlag), "Flag to set remote allocation call timeout.") pflag.Duration(totalRemoteAllocationTimeoutFlag, viper.GetDuration(totalRemoteAllocationTimeoutFlag), "Flag to set total remote allocation timeout including retries.") + pflag.String(logLevelFlag, viper.GetString(logLevelFlag), "Agones Log level") runtime.FeaturesBindFlags() pflag.Parse() @@ -93,6 +97,7 @@ func parseEnvFlags() config { runtime.Must(viper.BindEnv(stackdriverLabels)) runtime.Must(viper.BindEnv(mTLSDisabledFlag)) runtime.Must(viper.BindEnv(tlsDisabledFlag)) + runtime.Must(viper.BindEnv(logLevelFlag)) runtime.Must(viper.BindPFlags(pflag.CommandLine)) runtime.Must(runtime.FeaturesBindEnv()) @@ -107,6 +112,7 @@ func parseEnvFlags() config { StackdriverLabels: viper.GetString(stackdriverLabels), MTLSDisabled: viper.GetBool(mTLSDisabledFlag), TLSDisabled: viper.GetBool(tlsDisabledFlag), + LogLevel: viper.GetString(logLevelFlag), remoteAllocationTimeout: viper.GetDuration(remoteAllocationTimeoutFlag), totalRemoteAllocationTimeout: viper.GetDuration(totalRemoteAllocationTimeoutFlag), } diff --git a/install/helm/agones/templates/service/allocation.yaml b/install/helm/agones/templates/service/allocation.yaml index f93eb621f2..48f81dd52d 100644 --- a/install/helm/agones/templates/service/allocation.yaml +++ b/install/helm/agones/templates/service/allocation.yaml @@ -153,6 +153,8 @@ spec: fieldPath: metadata.namespace - name: CONTAINER_NAME value: "agones-allocator" + - name: LOG_LEVEL + value: {{ .Values.agones.allocator.logLevel | quote }} - name: FEATURE_GATES value: {{ .Values.agones.featureGates | quote }} ports: diff --git a/install/helm/agones/values.yaml b/install/helm/agones/values.yaml index 418a90936b..111e1e37af 100644 --- a/install/helm/agones/values.yaml +++ b/install/helm/agones/values.yaml @@ -116,6 +116,7 @@ agones: install: true apiServerQPS: 400 apiServerQPSBurst: 500 + logLevel: info annotations: {} resources: {} # requests: diff --git a/install/yaml/install.yaml b/install/yaml/install.yaml index 1dfdffc2f6..a5de59a0f9 100644 --- a/install/yaml/install.yaml +++ b/install/yaml/install.yaml @@ -1599,6 +1599,8 @@ spec: fieldPath: metadata.namespace - name: CONTAINER_NAME value: "agones-allocator" + - name: LOG_LEVEL + value: "info" - name: FEATURE_GATES value: "" ports: diff --git a/site/content/en/docs/Installation/Install Agones/helm.md b/site/content/en/docs/Installation/Install Agones/helm.md index cd537f0bba..4885b11506 100644 --- a/site/content/en/docs/Installation/Install Agones/helm.md +++ b/site/content/en/docs/Installation/Install Agones/helm.md @@ -254,6 +254,7 @@ The following tables lists the configurable parameters of the Agones chart and t | `agones.allocator.apiServerQPSBurst` | Maximum burst queries per second that an allocator should be making against API Server | `500` | | `agones.allocator.allocationTimeout` | Remote allocation call timeout. | `10s` | | `agones.allocator.remoteAllocationTimeout` | Total remote allocation timeout including retries. | `30s` | +| `agones.allocator.logLevel` | Agones Allocator Log level. Log only entries with that severity and above | `info` | | `agones.controller.annotations` | [Annotations][annotations] added to the Agones controller pods | `{}` | | `agones.allocator.annotations` | [Annotations][annotations] added to the Agones allocator pods | `{}` | | `agones.ping.annotations` | [Annotations][annotations] added to the Agones ping pods | `{}` |