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 error-log-level configmap key #342

Merged
merged 1 commit into from
Aug 20, 2018
Merged

Add error-log-level configmap key #342

merged 1 commit into from
Aug 20, 2018

Conversation

boranx
Copy link
Contributor

@boranx boranx commented Aug 17, 2018

Proposed changes

The log level in NGINX templates was hard coded. This PR allows you to inject the log level from K8s config map. The default value will be "notice". I also updated the example config. Tested and works well in K8s.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • [✔] I have read the CONTRIBUTING doc
  • [✔] I have added tests that prove my fix is effective or that my feature works
  • [✔] I have checked that all unit tests pass after adding my changes
  • [✔] I have updated necessary documentation
  • [✔] I have rebased my branch onto master
  • [✔] I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

Copy link
Contributor

@isaachawley isaachawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks. Just a few small changes.

Please add this config map key to the table in the customization example readme.

You've changed the default log level for NGINX OSS - I think that's fine, we'll need to add it to the release notes.

A small naming issue, I've commented.

Thanks!

@@ -49,6 +49,7 @@ type Config struct {
HealthCheckMandatory bool
HealthCheckMandatoryQueue int64
SlowStart string
LogLevel string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to MainLogLevel or MainErrorLogLevel -- settings that go in the main nginx config file have a "Main" prefix.

@pleshakov pleshakov added the enhancement Pull requests for new features/feature enhancements label Aug 17, 2018
@isaachawley
Copy link
Contributor

You may also want to rename the config map key to error-log-level.

Text for the customization readme:
"Sets the global error log level for NGINX."

Thanks

@boranx
Copy link
Contributor Author

boranx commented Aug 17, 2018

I renamed the config map key to error-log-level. Also changed the parameter name for MainErrorLogLevel. This will be better, I think so.

Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @boranx
please see a couple of additional suggestions.
apologies if we confused you with the MainErrorLogLevel name, but it is only required in the config.go file.

Could you also rebase against the master branch?

@@ -23,6 +23,7 @@ The table below summarizes all of the options. For some of them, there are examp
| N/A | `http2` | Enables HTTP/2 in servers with SSL enabled. | `False` |
| `nginx.org/redirect-to-https` | `redirect-to-https` | Sets the 301 redirect rule based on the value of the `http_x_forwarded_proto` header on the server block to force incoming traffic to be over HTTPS. Useful when terminating SSL in a load balancer in front of the Ingress controller — see [115](https://github.com/nginxinc/kubernetes-ingress/issues/115) | `False` | |
| `ingress.kubernetes.io/ssl-redirect` | `ssl-redirect` | Sets an unconditional 301 redirect rule for all incoming HTTP traffic to force incoming traffic over HTTPS. | `True` | |
| N/A | `error-log-level` | Sets the global error log level for NGINX. [error-log-level](http://nginx.org/en/docs/ngx_core_module.html#error_log). | See the [template file](../../nginx-controller/nginx/nginx.conf.tmpl). | |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you possible change the description to Sets the global [error log level](http://nginx.org/en/docs/ngx_core_module.html#error_log) for NGINX. ?

Could you put notice in the default column instead of a link to the template?

@@ -257,7 +259,9 @@ func ParseConfigMap(cfgm *api_v1.ConfigMap, nginxPlus bool) *Config {
sslDHParamFile = strings.Trim(sslDHParamFile, "\n")
cfg.MainServerSSLDHParamFileContent = &sslDHParamFile
}

if MainErrorLogLevel, exists := cfgm.Data["error-log-level"]; exists {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MainErrorLogLevel -> errorLogLevel

@@ -142,6 +142,7 @@ type NginxMainConfig struct {
ServerNamesHashBucketSize string
ServerNamesHashMaxSize string
LogFormat string
MainErrorLogLevel string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MainErrorLogLevel -> ErrorLogLevel

@boranx
Copy link
Contributor Author

boranx commented Aug 17, 2018

Sorry for bothering you, could you please check it again?

Copy link
Contributor

@isaachawley isaachawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@isaachawley isaachawley merged commit be3cdbd into nginxinc:master Aug 20, 2018
@pleshakov
Copy link
Contributor

@boranx thanks for the PR!!

@pleshakov pleshakov added the change Pull requests that introduce a change label Aug 20, 2018
@pleshakov pleshakov changed the title add log-level to the templates in order to injecting the log level from config map Add error-log-level configmap key Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change Pull requests that introduce a change enhancement Pull requests for new features/feature enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants