Skip to content

Commit

Permalink
Add log level setting in allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
8398a7 committed Oct 30, 2020
1 parent 8c2fa6f commit 75cb93f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/allocator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -66,10 +67,19 @@ const (
func main() {
conf := parseEnvFlags()

logger.WithField("version", pkg.Version).WithField("ctlConf", conf).
logger.WithField("version", pkg.Version).WithField("conf", conf).
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()

Expand Down
6 changes: 6 additions & 0 deletions cmd/allocator/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
totalRemoteAllocationTimeoutFlag = "total-remote-allocation-timeout"
apiServerSustainedQPSFlag = "api-server-qps"
apiServerBurstQPSFlag = "api-server-qps-burst"
logLevelFlag = "log-level"
)

func init() {
Expand All @@ -54,6 +55,7 @@ type config struct {
Stackdriver bool
GCPProjectID string
StackdriverLabels string
LogLevel string
totalRemoteAllocationTimeout time.Duration
remoteAllocationTimeout time.Duration
}
Expand All @@ -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")
Expand All @@ -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()

Expand All @@ -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())

Expand All @@ -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),
}
Expand Down
2 changes: 2 additions & 0 deletions install/helm/agones/templates/service/allocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions install/helm/agones/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ agones:
install: true
apiServerQPS: 400
apiServerQPSBurst: 500
logLevel: info
annotations: {}
healthCheck:
initialDelaySeconds: 3
Expand Down
2 changes: 2 additions & 0 deletions install/yaml/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,8 @@ spec:
fieldPath: metadata.namespace
- name: CONTAINER_NAME
value: "agones-allocator"
- name: LOG_LEVEL
value: "info"
- name: FEATURE_GATES
value: ""
ports:
Expand Down
1 change: 1 addition & 0 deletions site/content/en/docs/Installation/Install Agones/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,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 | `{}` |
Expand Down

0 comments on commit 75cb93f

Please sign in to comment.