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

Add log level setting in allocator #1880

Merged
merged 3 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions 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 @@ -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()

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 @@ -116,6 +116,7 @@ agones:
install: true
apiServerQPS: 400
apiServerQPSBurst: 500
logLevel: info
annotations: {}
resources: {}
# requests:
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 @@ -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 | `{}` |
Expand Down